From 1744843956e5bb635dd1d063661c5339211abd97 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Tue, 6 Dec 2022 09:45:58 +0800 Subject: [PATCH] sonar:fix linux build --- .github/workflows/cmake build test.yml | 110 +++++++++++++++++++++++++ .gitmodules | 4 +- CMakeLists.txt | 28 +++++-- eb | 1 - thirdparty/eb | 1 + 5 files changed, 133 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/cmake build test.yml delete mode 160000 eb create mode 160000 thirdparty/eb diff --git a/.github/workflows/cmake build test.yml b/.github/workflows/cmake build test.yml new file mode 100644 index 00000000..b7965cb4 --- /dev/null +++ b/.github/workflows/cmake build test.yml @@ -0,0 +1,110 @@ +name: CMake Test +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + workflow_dispatch: + # push: + # branches: + # - dev + # pull_request: + # types: [opened, synchronize, reopened] +jobs: + job1: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v3 + with: + python-version: '3.9' + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: 6.3.2 + arch: gcc_64 + cached: 'false' + #serialport linuxdeploy need serialport to work. + modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia qtimageformats qtserialport + setup-python: 'false' + + - name: ubuntu install thirdparty dependencies + run: | + sudo apt-get install git pkg-config build-essential + sudo apt-get install libvorbis-dev zlib1g-dev libhunspell-dev x11proto-record-dev + sudo apt-get install libxtst-dev liblzo2-dev libbz2-dev + sudo apt-get install libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev + sudo apt-get install doxygen libzstd-dev libxkbcommon-dev libgstreamer-plugins-base1.0-0 libgstreamer-gl1.0-0 + sudo ln -sf /usr/bin/x86_64-linux-gnu-ld.gold /usr/bin/ld + + #build opencc + git clone https://github.com/BYVoid/OpenCC + cd OpenCC/ + make PREFIX=/usr -j$(nproc) + sudo make install + cd .. + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + submodules: true + + - name: Run build-wrapper + run: | + cmake . + cmake --build . + + job2: + name: Build and analyze + runs-on: windows-2019 + steps: + - uses: actions/setup-python@v3 + with: + python-version: '3.9' + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: 6.3.2 + arch: gcc_64 + cached: 'false' + #serialport linuxdeploy need serialport to work. + modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia qtimageformats qtserialport + setup-python: 'false' + - uses: ilammy/msvc-dev-cmd@v1 + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + submodules: true + + - name: Run build-wrapper + run: | + cmake . + cmake --build . + job3: + name: Build and analyze + runs-on: macos-12 + steps: + - uses: actions/setup-python@v3 + with: + python-version: '3.9' + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: 6.3.2 + arch: gcc_64 + cached: 'false' + #serialport linuxdeploy need serialport to work. + modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia qtimageformats qtserialport + setup-python: 'false' + - uses: ilammy/msvc-dev-cmd@v1 + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + submodules: true + - name: install dependencies + run: | + brew uninstall opencc hunspell ffmpeg@5 ffmpeg@4 libtiff xz lzo libogg libvorbis zstd || true + brew install create-dmg + - name: Run build-wrapper + run: | + cmake . + cmake --build . + \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index a1ff2db7..842f8e43 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "eb"] - path = eb - url = git@github.com:xiaoyifang/simple-eb.git + path = thirdparty/eb + url = https://github.com/xiaoyifang/simple-eb.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b2cee462..bf136187 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,14 +5,14 @@ cmake_minimum_required(VERSION 3.23) # LINUX, APPLE and MSVC are used to detect system option(WITH_FFMPEG_PLAYER "Enable support for FFMPEG player" ON) - +option(WITH_EPWING_SUPPORT "Enable epwing support" ON) # Remove this once cmake 5.25 becomes minimum version if(UNIX AND NOT APPLE) set(LINUX TRUE) endif() if (APPLE) - add_subdirectory(eb) + add_subdirectory(thirdparty/eb) endif () project(goldendict @@ -76,9 +76,12 @@ if(LINUX) find_package(X11 REQUIRED) pkg_check_modules (LIBXTST IMPORTED_TARGET xtst) - add_library(libeb SHARED IMPORTED) - set_target_properties(libeb PROPERTIES IMPORTED_LOCATION /usr/lib/libeb.so) - set_target_properties(libeb PROPERTIES INCLUDE_DIRECTORIES /usr/include/) + if(WITH_EPWING_SUPPORT) + add_subdirectory(thirdparty/eb EXCLUDE_FROM_ALL) + endif() + # add_library(libeb SHARED IMPORTED) + # set_target_properties(libeb PROPERTIES IMPORTED_LOCATION /usr/lib/libeb.so) + # set_target_properties(libeb PROPERTIES INCLUDE_DIRECTORIES /usr/include/) endif() #### Compile time files and preprocessor flags @@ -144,7 +147,7 @@ set(UI_SRC scanpopup.ui sources.ui ) - +if(WITH_EPWING_SUPPORT) set(EPWING_SUPPORT_SRC epwing.cc epwing.hh @@ -153,6 +156,9 @@ set(EPWING_SUPPORT_SRC epwing_charmap.cc epwing_charmap.hh ) +else() + add_compile_definitions(NO_EPWING_SUPPORT) +endif() if (APPLE) set(MAC_SRC @@ -489,10 +495,12 @@ if(APPLE) endif() if(UNIX) + target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE + ${PROJECT_SOURCE_DIR}/thirdparty) + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE # pkg-config packages need manually link PkgConfig::PKGCONFIG_DEPS - BZip2::BZip2 ZLIB::ZLIB #hidden requirement of dsl_details.cc and more? ) @@ -507,7 +515,11 @@ endif() if(LINUX) - target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE libeb X11 PkgConfig::LIBXTST) + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE X11 PkgConfig::LIBXTST) + + if(WITH_EPWING_SUPPORT) + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE eb ) + endif() endif () if(APPLE) diff --git a/eb b/eb deleted file mode 160000 index cda41734..00000000 --- a/eb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cda417343ceedcb4b44e37e54590979f59c748c9 diff --git a/thirdparty/eb b/thirdparty/eb new file mode 160000 index 00000000..b4d020be --- /dev/null +++ b/thirdparty/eb @@ -0,0 +1 @@ +Subproject commit b4d020bee71b10c8fc1d15beb5849c5b19fd5fa1