diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ef20c4af..0fb4f1cd2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -366,7 +366,7 @@ jobs: sudo -u nobody makepkg - # Remplace the old file + # Replace the old file rm imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst mv *.pkg.tar.zst imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst @@ -377,12 +377,21 @@ jobs: path: | build/imhex-${{env.IMHEX_VERSION}}-ArchLinux.pkg.tar.zst - fedora-build-rawhide: - name: 🐧 Fedora Rawhide + fedora-build: + strategy: + matrix: + include: + - docker_image: fedora:latest + release: Latest + - docker_image: fedora:rawhide + release: Rawhide + + + name: 🐧 Fedora ${{ matrix.release }} runs-on: ubuntu-latest container: - image: fedora:rawhide + image: "${{ matrix.docker_image }}" steps: - name: ⬇️ Update all packages @@ -392,7 +401,6 @@ jobs: - name: ⬇️ Install setup dependencies run: | dnf install -y \ - capstone-devel \ ccache \ desktop-file-utils \ fmt-devel \ @@ -401,7 +409,6 @@ jobs: libcurl-devel \ llvm-devel \ mbedtls-devel \ - mock \ python3-devel \ rpm-build \ yara-devel @@ -420,15 +427,15 @@ jobs: with: path: | ~/.cache/ccache - key: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }} - restore-keys: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build + key: fedora-${{ matrix.release }}-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }} + restore-keys: fedora-${{ matrix.release }}-${{ secrets.CACHE_VERSION }}-build - name: 📜 Restore CMakeCache uses: actions/cache@v3 with: path: | - build/CMakeCache.txt - key: fedora-rawhide-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }} + ~/rpmbuild/BUILDROOT/CMakeCache.txt + key: fedora-${{ matrix.release }}-${{ secrets.CACHE_VERSION }}-build-${{ hashFiles('**/CMakeLists.txt') }} - name: 📜 Set version variable run: | @@ -436,70 +443,11 @@ jobs: - name: 📦 Build RPM run: | - rpmbuild -ba --define "_version ${{env.IMHEX_VERSION}}" --define "_src_path $GITHUB_WORKSPACE" $GITHUB_WORKSPACE/dist/rpm/imhex.spec + rpmbuild -ba --define "_version ${{env.IMHEX_VERSION}}" --define "_src_path $GITHUB_WORKSPACE" --define "_build_type $BUILD_TYPE" $GITHUB_WORKSPACE/dist/rpm/imhex.spec - name: ⬆️ Upload RPM uses: actions/upload-artifact@v3 with: - name: Fedora Rawhide RPM - path: | - ~/rpmbuild/RPMS/*/*.rpm - - - fedora-build-stable: - name: 🐧 Fedora Stable - runs-on: ubuntu-latest - - container: - image: fedora:latest - - steps: - - name: ⬇️ Update all packages - run: | - dnf upgrade -y - - - name: ⬇️ Install setup dependencies - run: | - dnf install -y \ - ccache \ - desktop-file-utils \ - fmt-devel \ - git \ - json-devel \ - libcurl-devel \ - llvm-devel \ - mbedtls-devel \ - python3-devel \ - rpm-build - - - name: 🧰 Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: ⬇️ Install ImHex dependencies - run: | - dist/get_deps_fedora.sh - - - name: 📜 Restore ccache - uses: actions/cache@v3 - with: - path: | - ~/.cache/ccache - key: fedora-stable-${{ secrets.CACHE_VERSION }}-build-${{ github.run_id }} - restore-keys: fedora-stable-${{ secrets.CACHE_VERSION }}-build - - - name: 📜 Set version variable - run: | - echo "IMHEX_VERSION=`cat VERSION`" >> $GITHUB_ENV - - - name: 📦 Build RPM - run: | - rpmbuild -ba --define "_version ${{env.IMHEX_VERSION}}" --define "_src_path $GITHUB_WORKSPACE" $GITHUB_WORKSPACE/dist/rpm/imhex.spec - - - name: ⬆️ Upload RPM - uses: actions/upload-artifact@v3 - with: - name: Fedora Stable RPM + name: Fedora ${{ matrix.release }} RPM path: | ~/rpmbuild/RPMS/*/*.rpm diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index affdddff1..76548e272 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -1,5 +1,12 @@ include(FetchContent) +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(CPACK_STRIP_FILES TRUE) +endif() + macro(addVersionDefines) if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git") # Get the current working branch @@ -219,9 +226,11 @@ macro(createPackage) install(FILES "$" DESTINATION "${CMAKE_INSTALL_LIBDIR}") downloadImHexPatternsFiles("./") elseif(UNIX AND NOT APPLE) - + + set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION}) + configure_file(${CMAKE_SOURCE_DIR}/dist/DEBIAN/control.in ${CMAKE_BINARY_DIR}/DEBIAN/control) - + install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/share/licenses/imhex) install(FILES ${CMAKE_SOURCE_DIR}/dist/imhex.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) install(FILES ${CMAKE_SOURCE_DIR}/resources/icon.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME imhex.png) @@ -231,6 +240,9 @@ macro(createPackage) if (CREATE_BUNDLE) include(PostprocessBundle) + + set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION}) + # Fix rpath add_custom_command(TARGET imhex_all POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/" $) diff --git a/dist/Arch/PKGBUILD b/dist/Arch/PKGBUILD index 3b5b7dd75..ccad239e6 100644 --- a/dist/Arch/PKGBUILD +++ b/dist/Arch/PKGBUILD @@ -26,7 +26,7 @@ package() { tar -xf imhex-$pkgver-ArchLinux.pkg.tar.zst install -DT $srcdir/usr/bin/imhex $pkgdir/usr/bin/imhex - install -DT $srcdir/usr/lib/libimhex.so $pkgdir/usr/lib/libimhex.so + install -DT $srcdir/usr/lib/libimhex.so.$pkgver $pkgdir/usr/lib/libimhex.so.$pkgver for plugin in $srcdir/usr/share/imhex/plugins/*.hexplug; do diff --git a/dist/rpm/imhex.spec b/dist/rpm/imhex.spec index 42be407fb..987705d26 100644 --- a/dist/rpm/imhex.spec +++ b/dist/rpm/imhex.spec @@ -47,11 +47,14 @@ cp -r %{_src_path}/* %{_builddir}/ %build %cmake \ + -DCMAKE_BUILD_TYPE=%{_build_type} \ -D IMHEX_OFFLINE_BUILD=ON \ -D USE_SYSTEM_NLOHMANN_JSON=ON \ -D USE_SYSTEM_FMT=ON \ -D USE_SYSTEM_CURL=ON \ -D USE_SYSTEM_LLVM=ON \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ %if 0%{?fedora} >= 37 -D USE_SYSTEM_YARA=ON \ # if fedora <= 36 get updated to yara 4.2.x then they should \ @@ -79,6 +82,6 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/imhex.desktop %dir %{_datadir}/imhex %{_datadir}/imhex/* %{_datadir}/applications/imhex.desktop -%{_prefix}/lib/libimhex.so +%{_prefix}/lib/libimhex.so.%{_version} %changelog