Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternative build method "CMakeLists.txt" #218

Merged
merged 13 commits into from
Nov 26, 2022

Conversation

shenlebantongying
Copy link
Collaborator

@shenlebantongying shenlebantongying commented Nov 21, 2022

Build executable to build_dir

cmake -S . -B build_dir \
      --install-prefix=/usr/local \
      -G Ninja \
      -DCMAKE_BUILD_TYPE=Release
cmake --build build_dir --parallel 7

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 21, 2022

I just built on arm64 mac with CMake. The CMakeLists.txt look like absolute garbage right now.

Goldendict 22.11.20.ea5d4445 on
macos darwin 22.1.0 Qt 6.4.0 arm64-little_endian-lp64
Clang 14.0.0 (clang-1400.0.29.202)
Flags: NO_EPWING_SUPPORT MAKE_CHINESE_CONVERSION_SUPPORT

@xiaoyifang
Copy link
Owner

xiaoyifang commented Nov 21, 2022

https://github.com/xiaoyifang/goldendict/tree/feature/cmake

a try in the above branch but has not finished and tested

For your reference.

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 22, 2022

I think I can copy some of your CMake code later.

I successfully built with CMake+vcpkg with MSVC

The vcpkg uses a vcpkg.json which will automatically install necessary packages when loading the CmakeLists.txt. https://github.com/microsoft/vcpkg/blob/master/docs/users/manifests.md

I only tested on Clion, but I think there should be no problem using VS assuming two paths are set correctly.

There is a new .md under /docs describing how

@shenlebantongying
Copy link
Collaborator Author

Also, I find no script that you use to generate libeb.lib and libeb.dylib. Where do they come from? I am not sure how to build them.

The upstream seems to be dead, maybe we should vendor the code into our tree like we already do to qsingleapplication.

@xiaoyifang
Copy link
Owner

xiaoyifang commented Nov 22, 2022

o generate libeb.lib and libeb.dylib. Where do they come from?

check github/workflow/**macos-hombrew.yml

on Windows
https://github.com/xiaoyifang/simple-eb

to make it easier , cmakefiles.txt can support qt6 only

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 22, 2022

Both Homebrew and MacPorts have speex support for FFmpeg, I think they are pretty good to use.

https://github.com/Homebrew/homebrew-core/blob/f2bf2901996558acd9fe3a57b01eb4c6cb5e07b0/Formula/ffmpeg.rb#L50

https://github.com/macports/macports-ports/blob/8fa5e44c75c30244ac51a282f510c8986769c1df/multimedia/ffmpeg/Portfile#L151


For windows, the build time for FFmpeg is insanely long. Also, vcpkg is pulling things from everywhere which is problematic. Reuse the /winlib should still be optimal choice rather than vcpkg.


Before stopping support qt5, I don't think we have to switch the build system. So, I think this can be merged and I have no plan to improve it further before switching. Can you merge this @xiaoyifang ? I think I should prioritize something else.

@xiaoyifang
Copy link
Owner

xiaoyifang commented Nov 23, 2022

Both Homebrew and MacPorts have speex support for FFmpeg, I think they are pretty good to use.

the homebrew version( which has speex support) seems does not work .
I have tried the homebrew version in https://github.com/xiaoyifang/goldendict/blob/staged/.github/workflows/macos-homebrew.yml before ,it can not play spx file. At last I have to compile the ffmpeg from source.

Does the cmakefiles support libeb(epwing ) on Windows?

config.cc Outdated Show resolved Hide resolved
@shenlebantongying
Copy link
Collaborator Author

Does the cmakefiles support libeb(epwing ) on Windows?

I think I will remove vcpkg related things and build with /winlibs/ for windows.

There is no upstream for libeb. To avoid including a eb.dylib on mac, maybe we should consider moving your simple-eb into this repo so that both win & mac can easily support epwing format?

@xiaoyifang
Copy link
Owner

your simple-eb

I'm afraid this repo only support windows

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 23, 2022

There is a type of mismatching:

We call the function of ssize_t
https://github.com/xiaoyifang/goldendict/blob/aa9ed9bc38e288dbced2b86c010b5da969b88906/epwing_book.cc#L1246-L1248

but it seems changed to size_t for some reason.
xiaoyifang/simple-eb@7c16921

This isn't allowed on my compiler.

Does MSVC have trouble with ssize_t? We have to unify them.

P.S. CLion cannot refactor C89 syntax, lol

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 23, 2022

Unix's standard: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html

size_t
    Used for sizes of objects.
ssize_t
    Used for a count of bytes or an error indication.

ssize_t is in linux's doc https://man7.org/linux/man-pages/man7/system_data_types.7.html

The major difference is that ssize_t can be a negative value, but does the length**** even becomes negative??

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 23, 2022

I added epwing with simple-eb, it adds a submodule under my name for now, until the changes are merged.

However, I think we should embed the sources directly instead of submodule.

@xiaoyifang
Copy link
Owner

size_t
Used for sizes of objects.
ssize_t
Used for a count of bytes or an error indication.

the commit which introuduced in the simple-eb can be reverted

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 24, 2022

I think the Linux build is pretty much done. We can ship to archlinux with CMake first.

.
./bin
./bin/goldendict
./share
./share/applications
./share/applications/org.goldendict.GoldenDict.desktop
./share/metainfo
./share/metainfo/org.goldendict.GoldenDict.metainfo.xml
./share/pixmaps
./share/pixmaps/goldendict.png
./share/goldendict
./share/goldendict/locale
./share/goldendict/locale/ar_SA.qm
./share/goldendict/locale/ay_WI.qm
./share/goldendict/locale/be_BY.qm
./share/goldendict/locale/be_BY@latin.qm
./share/goldendict/locale/bg_BG.qm
./share/goldendict/locale/cs_CZ.qm
./share/goldendict/locale/de_CH.qm
./share/goldendict/locale/de_DE.qm
./share/goldendict/locale/el_GR.qm
./share/goldendict/locale/eo_EO.qm
./share/goldendict/locale/es_AR.qm
./share/goldendict/locale/es_BO.qm
./share/goldendict/locale/es_ES.qm
./share/goldendict/locale/fa_IR.qm
./share/goldendict/locale/fi_FI.qm
./share/goldendict/locale/fr_FR.qm
./share/goldendict/locale/hi_IN.qm
./share/goldendict/locale/ie_001.qm
./share/goldendict/locale/it_IT.qm
./share/goldendict/locale/ja_JP.qm
./share/goldendict/locale/jb_JB.qm
./share/goldendict/locale/ko_KR.qm
./share/goldendict/locale/lt_LT.qm
./share/goldendict/locale/mk_MK.qm
./share/goldendict/locale/nl_NL.qm
./share/goldendict/locale/pl_PL.qm
./share/goldendict/locale/pt_BR.qm
./share/goldendict/locale/qt_es.qm
./share/goldendict/locale/qt_it.qm
./share/goldendict/locale/qt_lt.qm
./share/goldendict/locale/qu_WI.qm
./share/goldendict/locale/ru_RU.qm
./share/goldendict/locale/sk_SK.qm
./share/goldendict/locale/sq_AL.qm
./share/goldendict/locale/sr_SR.qm
./share/goldendict/locale/sv_SE.qm
./share/goldendict/locale/tg_TJ.qm
./share/goldendict/locale/tk_TM.qm
./share/goldendict/locale/tr_TR.qm
./share/goldendict/locale/uk_UA.qm
./share/goldendict/locale/vi_VN.qm
./share/goldendict/locale/zh_CN.qm
./share/goldendict/locale/zh_TW.qm
./share/goldendict/help
./share/goldendict/help/gdhelp_en.qch
./share/goldendict/help/gdhelp_ru.qch

@shenlebantongying
Copy link
Collaborator Author

Also, I just learned why /winlibs/ used to be a submodule. If user don't need them, they can just don't do git submodule init so the generated tarball won't include them.

The current auto-generated tarball by github is 43Mb which could be just 3Mb.

@xiaoyifang
Copy link
Owner

xiaoyifang commented Nov 24, 2022

Also, I just learned why /winlibs/ used to be a submodule. If user don't need them, they can just don't do git submodule init so the generated tarball won't include them.

that's right.

from my personal perspective,I just do not like the submodules which has to depedent on another folder. and invoke submodule init manually.

after all, this winlibs can be changed into submodule anyway , we can leave it for a later time.

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 25, 2022

vcpkg is removed from the windows build and use /winlibs/ instead.


For mac homebrew build, I think we are pretty much facing the same rpath problem. macdeployqt cannot use the qt6 in homebrew right now. The solution should be the same.

https://github.com/xiaoyifang/goldendict/blob/df2bb387e2c789973dc6c367df36d308f6b3148e/.github/workflows/macos-homebrew.yml#L44


Since we still support qt5, I think we can wait for the next qt6 release and set up CI at that time and deal with unforeseen problems in another PR.


This PR is done.

@xiaoyifang
Copy link
Owner

I think config.cc should move into another PR
@shenlebantongying

@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Nov 25, 2022

The config.cc change is reverted.

@xiaoyifang xiaoyifang merged commit b7e4afb into xiaoyifang:staged Nov 26, 2022
@shenlebantongying shenlebantongying deleted the cmake-build branch March 21, 2023 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants