From d62abaed8d873362b6d438d50707be4afcc181ac Mon Sep 17 00:00:00 2001 From: Nik Date: Fri, 9 Jan 2026 17:42:51 +0100 Subject: [PATCH] build: Add support for x86 macOS 10.15 and ARM64 macOS 11.0 (#2607) This PR drops the use of brew for dependency management in favor of macports so we can support lower macOS versions instead of just the lowest one supported by Apple Closes #2586 --- .github/workflows/build.yml | 81 ++++++------------- dist/macOS/arm64.Dockerfile | 6 +- dist/macOS/osx_10_15/x64-osx.cmake | 11 +++ dist/web/source/wasm-config.js | 2 +- lib/libimhex/source/helpers/utils_macos.m | 12 ++- .../imgui/backend/source/imgui_impl_glfw.cpp | 6 +- main/gui/source/init/splash_window.cpp | 2 +- main/gui/source/window/platform/web.cpp | 1 - 8 files changed, 54 insertions(+), 67 deletions(-) create mode 100644 dist/macOS/osx_10_15/x64-osx.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ab64fc29..aa33faad8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -251,7 +251,6 @@ jobs: - name: ⬇️ Install dependencies run: | cp dist/vcpkg.json vcpkg.json - vcpkg install - name: ⬇️ Install CMake and Ninja uses: lukka/get-cmake@latest @@ -390,18 +389,7 @@ jobs: id-token: write attestations: write - strategy: - fail-fast: false - matrix: - include: - - file_suffix: "-NoGPU" - name_suffix: "NoGPU" - custom_glfw: true - - file_suffix: "" - name_suffix: "" - custom_glfw: false - - name: 🍎 macOS 15 x86_64 ${{ matrix.name_suffix }} + name: 🍎 macOS 10.15 x86_64 steps: - name: 🧰 Checkout @@ -416,61 +404,40 @@ jobs: - name: 📜 Setup ccache uses: hendrikmuhs/ccache-action@v1 with: - key: ${{ runner.os }}${{ matrix.file_suffix }}-ccache-${{ github.run_id }} - restore-keys: ${{ runner.os }}${{ matrix.file_suffix }}-ccache + key: ${{ runner.os }}-ccache-${{ github.run_id }} + restore-keys: ${{ runner.os }}-ccache max-size: 1G - name: Set Xcode version - run: sudo xcode-select -s /Library/Developer/CommandLineTools + run: | + sudo xcode-select --install || true + sudo xcode-select -s /Library/Developer/CommandLineTools + + - name: 📦 Install MacPorts + run: | + wget https://github.com/macports/macports-base/releases/download/v2.11.6/MacPorts-2.11.6-15-Sequoia.pkg + sudo installer -pkg MacPorts-2.11.6-15-Sequoia.pkg -target / + export PATH=/opt/local/bin:/opt/local/sbin:$PATH + echo "PATH=/opt/local/bin:/opt/local/sbin:$PATH" >> $GITHUB_ENV + echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV + echo "universal_target 10.15" | sudo tee -a /opt/local/etc/macports/macports.conf + echo "macos_deployment_target 10.15" | sudo tee -a /opt/local/etc/macports/macports.conf + echo "macosx_sdk_version 10.15" | sudo tee -a /opt/local/etc/macports/macports.conf + sudo port selfupdate - name: ⬇️ Install dependencies env: # Make brew not display useless errors HOMEBREW_TESTS: 1 run: | - brew reinstall python --quiet || true - brew link --overwrite --quiet python 2>/dev/null || true - brew bundle --quiet --file dist/macOS/Brewfile || true - rm -rf /usr/local/Cellar/capstone - - - name: ⬇️ Install classic glfw - if: ${{! matrix.custom_glfw }} - run: | - brew install --quiet glfw || true + brew install llvm automake + sudo -E port install mbedtls3 nlohmann-json ccache freetype libmagic pkgconfig curl glfw ninja zlib xz bzip2 zstd libssh2 md4c - name: ⬇️ Install .NET uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.100' - - name: 🧰 Checkout glfw - if: ${{ matrix.custom_glfw }} - uses: actions/checkout@v4 - with: - repository: glfw/glfw - path: glfw - - # GLFW custom build (to allow software rendering) - - name: ⬇️ Patch and install custom glfw - if: ${{ matrix.custom_glfw }} - run: | - set -x - cd glfw - git apply ../dist/macOS/0001-glfw-SW.patch - - mkdir build - cd build - - cmake -G "Ninja" \ - -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ - -DBUILD_SHARED_LIBS=ON \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_OBJC_COMPILER_LAUNCHER=ccache \ - -DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \ - .. - ninja install - # MacOS cmake build - name: 🛠️ Configure CMake run: | @@ -481,8 +448,8 @@ jobs: CXX=$(brew --prefix llvm)/bin/clang++ \ OBJC=$(brew --prefix llvm)/bin/clang \ OBJCXX=$(brew --prefix llvm)/bin/clang++ \ - PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig":"$(brew --prefix)/lib/pkgconfig" \ cmake -G "Ninja" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \ -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DIMHEX_GENERATE_PACKAGE=ON \ -DIMHEX_SYSTEM_LIBRARY_PATH="$(brew --prefix llvm)/lib;$(brew --prefix llvm)/lib/unwind;$(brew --prefix llvm)/lib/c++;$(brew --prefix)/lib" \ @@ -531,7 +498,7 @@ jobs: break; fi done - mv *.dmg ../../imhex-${{ env.IMHEX_VERSION }}-macOS${{ matrix.file_suffix }}-x86_64.dmg + mv *.dmg ../../imhex-${{ env.IMHEX_VERSION }}-macOS-x86_64.dmg - name: 🗝️ Generate build provenance attestations uses: actions/attest-build-provenance@v2 @@ -544,12 +511,12 @@ jobs: uses: actions/upload-artifact@v4 with: if-no-files-found: error - name: macOS DMG ${{ matrix.name_suffix }} x86_64 + name: macOS DMG x86_64 path: ./*.dmg macos-arm64: runs-on: ubuntu-24.04 - name: 🍎 macOS 15 arm64 + name: 🍎 macOS 11 arm64 outputs: IMHEX_VERSION: ${{ steps.build.outputs.IMHEX_VERSION }} diff --git a/dist/macOS/arm64.Dockerfile b/dist/macOS/arm64.Dockerfile index a78befb97..4e7d13e4b 100644 --- a/dist/macOS/arm64.Dockerfile +++ b/dist/macOS/arm64.Dockerfile @@ -1,7 +1,7 @@ # This base image is also known as "crosscompile". See arm64.crosscompile.Dockerfile -FROM ghcr.io/werwolv/macos-crosscompile:4c4af2d1a6a102fab93cc9cd660280c2ec9d72af as build +FROM ghcr.io/werwolv/macos-crosscompile:6d89b20ac5ebedb6f680f94637591c94cb36f40b as build -ENV MACOSX_DEPLOYMENT_TARGET 13.0 +ENV MACOSX_DEPLOYMENT_TARGET 11.0 # -- DOWNLOADING STUFF @@ -132,6 +132,7 @@ if [ "$CUSTOM_GLFW" ]; then mkdir build cd build CC=o64-clang CXX=o64-clang++ cmake -G "Ninja" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DBUILD_SHARED_LIBS=ON \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ @@ -168,6 +169,7 @@ RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/ -DIMHEX_STRICT_WARNINGS=OFF \ -DIMHEX_PATTERNS_PULL_MASTER=ON \ -DCMAKE_INSTALL_PREFIX=/mnt/ImHex/build/install \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ -B build ## Build ImHex RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/_deps <CanvasSelector, &canvas_width, &canvas_height); - glfwSetWindowSize(bd->Window, (int)canvas_width, (int)canvas_height); + double scale = emscripten_get_device_pixel_ratio(); + glfwSetWindowSize(bd->Window, (int)canvas_width * scale, (int)canvas_height * scale); return true; } @@ -1210,7 +1211,8 @@ static EM_BOOL ImGui_ImplEmscripten_FullscreenChangeCallback(int event_type, con ImGui_ImplGlfw_Data* bd = (ImGui_ImplGlfw_Data*)user_data; double canvas_width, canvas_height; emscripten_get_element_css_size(bd->CanvasSelector, &canvas_width, &canvas_height); - glfwSetWindowSize(bd->Window, (int)canvas_width, (int)canvas_height); + double scale = emscripten_get_device_pixel_ratio(); + glfwSetWindowSize(bd->Window, (int)canvas_width * scale, (int)canvas_height * scale); return true; } diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index 7ac7f121c..73681e405 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -513,7 +513,7 @@ namespace hex::init { if (meanScale <= 0.0F) meanScale = 1.0F; - #if !defined(OS_LINUX) + #if !defined(OS_LINUX) && !defined(OS_WEB) meanScale /= hex::ImHexApi::System::getBackingScaleFactor(); #endif diff --git a/main/gui/source/window/platform/web.cpp b/main/gui/source/window/platform/web.cpp index 552bf6d93..5fc4f63ca 100644 --- a/main/gui/source/window/platform/web.cpp +++ b/main/gui/source/window/platform/web.cpp @@ -168,7 +168,6 @@ namespace hex { ImHexApi::System::impl::setNativeScale(currScaleFactor); ThemeManager::reapplyCurrentTheme(); - ImGui::GetStyle().ScaleAllSizes(currScaleFactor / prevScaleFactor); } prevScaleFactor = currScaleFactor;