diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70ea4f45a..d148e75a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -262,6 +262,19 @@ jobs: mv build/AppDir.deb imhex-${{env.IMHEX_VERSION}}.deb rm -rf build/AppDir/DEBIAN + - name: 🛠️ Reconfigure build for AppImage + run: | + # Reconfigure CMake to include a flag needed for AppImage + # Other flags are kept from old configuration + + cd build + cmake \ + -DIMHEX_PLUGINS_IN_SHARE=ON \ + .. + + rm -rf AppDir + make -j 4 install DESTDIR=AppDir + - name: 📦 Bundle AppImage run: | cd build @@ -445,10 +458,11 @@ jobs: - name: 📦 Build RPM run: | rpmbuild -ba --define "_version ${{env.IMHEX_VERSION}}" --define "_src_path $GITHUB_WORKSPACE" --define "_build_type $BUILD_TYPE" $GITHUB_WORKSPACE/dist/rpm/imhex.spec + mv ~/rpmbuild/RPMS/x86_64/*.rpm imhex-${{env.IMHEX_VERSION}}-Fedora-${{matrix.release}}.rpm - name: ⬆️ Upload RPM uses: actions/upload-artifact@v3 with: name: Fedora ${{ matrix.release }} RPM path: | - ~/rpmbuild/RPMS/*/*.rpm + imhex-${{env.IMHEX_VERSION}}-Fedora-${{matrix.release}}.rpm diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d40233192..fe7a3b9c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,9 +63,7 @@ jobs: - name: ⬆️ Upload everything to release uses: softprops/action-gh-release@v1 with: - files: | - '*' - '*/*.rpm' + files: '*' - name: ✒️ Prepare PKGBUILD run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d5d96cd1..3832b24db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.16) # Options +option(IMHEX_PLUGINS_IN_SHARE "Put the plugins in share/imhex/plugins instead of lib[..]/imhex/plugins" OFF) +option(IMHEX_STRIP_RELEASE "Strip the release builds" ON) option(IMHEX_OFFLINE_BUILD "Enable offline build" OFF) option(IMHEX_IGNORE_BAD_CLONE "Disabled the bad clone prevention checks" OFF) option(IMHEX_PATTERNS_PULL_MASTER "Download latest files from master branch of the ImHex-Patterns repo" OFF) diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 8df34e3a7..970dd83bf 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -1,10 +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(IMHEX_STRIP_RELEASE) + 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) + if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(CPACK_STRIP_FILES TRUE) + endif() endif() macro(addVersionDefines) @@ -90,9 +92,16 @@ macro(detectOS) enable_language(OBJCXX) elseif (UNIX AND NOT APPLE) add_compile_definitions(OS_LINUX) - set(CMAKE_INSTALL_BINDIR "bin") - set(CMAKE_INSTALL_LIBDIR "lib") - set(PLUGINS_INSTALL_LOCATION "share/imhex/plugins") + include(GNUInstallDirs) + + if(IMHEX_PLUGINS_IN_SHARE) + set(PLUGINS_INSTALL_LOCATION "share/imhex/plugins") + else() + set(PLUGINS_INSTALL_LOCATION "${CMAKE_INSTALL_LIBDIR}/imhex/plugins") + # Warning : Do not work with portable versions such as appimage (because the path is hardcoded) + add_compile_definitions(SYSTEM_PLUGINS_LOCATION="${CMAKE_INSTALL_FULL_LIBDIR}/imhex") # "plugins" will be appended from the app + endif() + else () message(FATAL_ERROR "Unknown / unsupported system!") endif() diff --git a/dist/Arch/PKGBUILD b/dist/Arch/PKGBUILD index ccad239e6..c8acdb033 100644 --- a/dist/Arch/PKGBUILD +++ b/dist/Arch/PKGBUILD @@ -28,11 +28,12 @@ package() { install -DT $srcdir/usr/bin/imhex $pkgdir/usr/bin/imhex install -DT $srcdir/usr/lib/libimhex.so.$pkgver $pkgdir/usr/lib/libimhex.so.$pkgver - for plugin in $srcdir/usr/share/imhex/plugins/*.hexplug; + for plugin in $srcdir/usr/lib/imhex/plugins/*.hexplug; do - install -DT $plugin $pkgdir/usr/share/imhex/plugins/`basename $plugin` + install -DT $plugin $pkgdir/usr/lib/imhex/plugins/`basename $plugin` done + mkdir -p $pkgdir/usr/share/imhex cp -r $srcdir/usr/share/imhex/{constants,encodings,includes,magic,patterns} $pkgdir/usr/share/imhex cp -r $srcdir/usr/share/{applications,licenses} $pkgdir/usr/share install -d $pkgdir/usr/share diff --git a/dist/rpm/imhex.spec b/dist/rpm/imhex.spec index 987705d26..b14a831a8 100644 --- a/dist/rpm/imhex.spec +++ b/dist/rpm/imhex.spec @@ -48,13 +48,13 @@ 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 \ + -D IMHEX_PATTERNS_PULL_MASTER=ON \ %if 0%{?fedora} >= 37 -D USE_SYSTEM_YARA=ON \ # if fedora <= 36 get updated to yara 4.2.x then they should \ @@ -78,10 +78,11 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/imhex.desktop %license %{_datadir}/licenses/imhex/LICENSE %doc README.md %{_bindir}/imhex -%{_datadir}/pixmaps/imhex.png %dir %{_datadir}/imhex %{_datadir}/imhex/* +%{_datadir}/pixmaps/imhex.png %{_datadir}/applications/imhex.desktop -%{_prefix}/lib/libimhex.so.%{_version} +%{_prefix}/lib64/libimhex.so.%{_version} +%{_prefix}/lib64/imhex/plugins/* %changelog diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 6921b9bd0..55dc08b2c 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -179,17 +179,25 @@ namespace hex::fs { #endif } + constexpr std::vector appendPath(std::vector paths, const std::fs::path &folder) { + for (auto &path : paths) + path = path / folder; + + return paths; + }; + + std::vector getPluginPaths() { + std::vector paths = getDataPaths(); + #if defined(OS_LINUX) && defined(SYSTEM_PLUGINS_LOCATION) + paths.push_back(SYSTEM_PLUGINS_LOCATION); + #endif + return paths; + } + std::vector getDefaultPaths(ImHexPath path, bool listNonExisting) { std::vector result; - constexpr auto appendPath = [](std::vector paths, const std::fs::path &folder) { - for (auto &path : paths) - path = path / folder; - - return paths; - }; - switch (path) { case ImHexPath::Constants: result = appendPath(getDataPaths(), "constants"); @@ -204,7 +212,7 @@ namespace hex::fs { result = appendPath(getConfigPaths(), "logs"); break; case ImHexPath::Plugins: - result = appendPath(getDataPaths(), "plugins"); + result = appendPath(getPluginPaths(), "plugins"); break; case ImHexPath::Resources: result = appendPath(getDataPaths(), "resources");