From 303b1061370ef4983253fb5986c97ed2cef298c6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 7 Dec 2024 19:38:35 +0100 Subject: [PATCH 1/4] CMake: support CMAKE_OSX_ARCHITECTURES (one arch/build) --- CMakeLists.txt | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e476d1e77..e956f1c9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,26 +217,51 @@ if(ENABLE_LUAJIT) target_link_libraries(AlberCore PRIVATE libluajit) endif() -# Check for x64 -if (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86-64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +# Detect target architecture +if (NOT APPLE OR "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") + # Normal target detection + if (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86-64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") set(HOST_X64 TRUE) + else() + set(HOST_X64 FALSE) + endif() + + if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + set(HOST_ARM64 TRUE) + else() + set(HOST_ARM64 FALSE) + endif() +else() + # Apple target detection + if("x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) + set(HOST_X64 TRUE) + else() + set(HOST_X64 FALSE) + endif() + + if("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES) + set(HOST_ARM64 TRUE) + else() + set(HOST_ARM64 FALSE) + endif() + + if (HOST_ARM64 AND HOST_X64) + message(FATAL_ERROR "Universal builds not supported like this! Please compile separately and stitch together") + endif() +endif() + +if (HOST_X64) add_subdirectory(third_party/xbyak) # Add xbyak submodule for x86 JITs include_directories(third_party/xbyak) add_compile_definitions(PANDA3DS_DYNAPICA_SUPPORTED) add_compile_definitions(PANDA3DS_X64_HOST) -else() - set(HOST_X64 FALSE) endif() -# Check for arm64 -if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") - set(HOST_ARM64 TRUE) +if (HOST_ARM64) add_subdirectory(third_party/oaknut) # Add Oaknut submodule for arm64 JITs include_directories(third_party/oaknut/include) add_compile_definitions(PANDA3DS_DYNAPICA_SUPPORTED) add_compile_definitions(PANDA3DS_ARM64_HOST) -else() - set(HOST_ARM64 FALSE) endif() # Enable SSE4.1 if it's not explicitly disabled From 60b0e3db855f1a1e102d4d6bc7ca9b083910477d Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 8 Dec 2024 09:43:21 +0100 Subject: [PATCH 2/4] Bump LuaJIT --- third_party/LuaJIT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/LuaJIT b/third_party/LuaJIT index 41edf0959..8bf7686d8 160000 --- a/third_party/LuaJIT +++ b/third_party/LuaJIT @@ -1 +1 @@ -Subproject commit 41edf0959b9504d36dd85f5f16893c004ea7d7ba +Subproject commit 8bf7686d820f868eae1a522c481fee09c18c90b9 From 700a7575d70d32d0fa1d4b0c3b1705062c777dda Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 8 Dec 2024 09:47:20 +0100 Subject: [PATCH 3/4] Qt build: build Mac ARM64 and Universal binaries --- .github/workflows/Qt_Build.yml | 58 ++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Qt_Build.yml b/.github/workflows/Qt_Build.yml index cc8055e51..ebd856c6a 100644 --- a/.github/workflows/Qt_Build.yml +++ b/.github/workflows/Qt_Build.yml @@ -51,6 +51,11 @@ jobs: path: upload MacOS: + strategy: + matrix: + arch: [x86_64, arm64] + + name: MacOS-${{ matrix.arch }} runs-on: macos-13 steps: @@ -69,11 +74,17 @@ jobs: run: | brew install dylibbundler imagemagick - - name: Install qt - run: brew install qt && which macdeployqt + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + aqtversion: '==3.1.*' + version: '6.8.1' + host: 'mac' + target: 'desktop' + arch: 'clang_64' - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_USER_BUILD=ON -DENABLE_QT_GUI=ON + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_USER_BUILD=ON -DENABLE_QT_GUI=ON -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} @@ -87,13 +98,48 @@ jobs: run: codesign --force -s - -vvvv Alber.app - name: Zip it up - run: zip -r Alber Alber.app + run: zip -r Alber-${{ matrix.arch }} Alber.app - name: Upload MacOS App uses: actions/upload-artifact@v4 with: - name: MacOS Alber App Bundle - path: 'Alber.zip' + name: MacOS Alber App Bundle (${{ matrix.arch }}) + path: Alber-${{ matrix.arch }}.zip + + MacOS-Universal: + name: MacOS-Universal + needs: [MacOS] + runs-on: macos-13 + + steps: + - name: Download x86_64 + uses: actions/download-artifact@v4 + with: + name: MacOS Alber App Bundle (x86_64) + path: x86_64 + - name: Download ARM64 + uses: actions/download-artifact@v4 + with: + name: MacOS Alber App Bundle (arm64) + path: arm64 + - name: Combine app bundles + shell: bash + run: | + set -x + unzip x86_64/*.zip -d x86_64 + unzip arm64/*.zip -d arm64 + lipo {x86_64,arm64}/Alber.app/Contents/MacOS/Alber -create -output Alber + cp -v -a arm64/Alber.app Alber.app + cp -v Alber Alber.app/Contents/MacOS/Alber + # Mix in x86_64 files that do not appear in the ARM64 build (e.g. libvulkan) + cp -v -R -n x86_64/Alber.app/* Alber.app/ || true + codesign --force -s - -vvvv Alber.app + zip -r -y Alber-universal.zip Alber.app + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: MacOS Alber App Bundle (universal) + path: Alber-universal.zip Linux: runs-on: ubuntu-24.04 From 1c9af52ca22dedc026c889b566326e5da42c7569 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 8 Dec 2024 09:48:16 +0100 Subject: [PATCH 4/4] MacOS build: build ARM64 and Universal binaries --- .github/workflows/MacOS_Build.yml | 52 ++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/.github/workflows/MacOS_Build.yml b/.github/workflows/MacOS_Build.yml index 76b75bd4b..a0c09bbfe 100644 --- a/.github/workflows/MacOS_Build.yml +++ b/.github/workflows/MacOS_Build.yml @@ -12,10 +12,11 @@ env: jobs: build: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + strategy: + matrix: + arch: [x86_64, arm64] + + name: MacOS-${{ matrix.arch }} runs-on: macos-13 steps: @@ -33,7 +34,7 @@ jobs: - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_USER_BUILD=ON + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_USER_BUILD=ON -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} - name: Build # Build your program with the given configuration @@ -49,10 +50,45 @@ jobs: run: codesign --force -s - -vvvv Alber.app - name: Zip it up - run: zip -r Alber Alber.app + run: zip -r Alber-${{ matrix.arch }} Alber.app - name: Upload MacOS App uses: actions/upload-artifact@v4 with: - name: MacOS Alber App Bundle - path: 'Alber.zip' + name: MacOS Alber App Bundle (${{ matrix.arch }}) + path: Alber-${{ matrix.arch }}.zip + + MacOS-Universal: + name: MacOS-Universal + needs: [build] + runs-on: macos-13 + + steps: + - name: Download x86_64 + uses: actions/download-artifact@v4 + with: + name: MacOS Alber App Bundle (x86_64) + path: x86_64 + - name: Download ARM64 + uses: actions/download-artifact@v4 + with: + name: MacOS Alber App Bundle (arm64) + path: arm64 + - name: Combine app bundles + shell: bash + run: | + set -x + unzip x86_64/*.zip -d x86_64 + unzip arm64/*.zip -d arm64 + lipo {x86_64,arm64}/Alber.app/Contents/MacOS/Alber -create -output Alber + cp -v -a arm64/Alber.app Alber.app + cp -v Alber Alber.app/Contents/MacOS/Alber + # Mix in x86_64 files that do not appear in the ARM64 build (e.g. libvulkan) + cp -v -R -n x86_64/Alber.app/* Alber.app/ || true + codesign --force -s - -vvvv Alber.app + zip -r -y Alber-universal.zip Alber.app + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: MacOS Alber App Bundle (universal) + path: Alber-universal.zip