diff --git a/.github/actions/caching/action.yml b/.github/actions/caching/action.yml new file mode 100644 index 0000000..da7b6d7 --- /dev/null +++ b/.github/actions/caching/action.yml @@ -0,0 +1,16 @@ +name: caching + +inputs: + key-prefix: + required: true + +runs: + using: "composite" + steps: + - name: Cache build directory + uses: actions/cache@v4 + with: + path: | + build + external/vcpkg + key: ${{ inputs.key-prefix }}-2025-07-18 diff --git a/.github/actions/common-macos/action.yml b/.github/actions/common-macos/action.yml index e709921..ab78a4b 100644 --- a/.github/actions/common-macos/action.yml +++ b/.github/actions/common-macos/action.yml @@ -5,6 +5,10 @@ inputs: required: true build-preset: required: true + vcpkg-triplet: + required: true + arch: + required: true runs: using: "composite" @@ -17,7 +21,8 @@ runs: run: | cmake --preset ${{ inputs.config-preset }} \ -G Xcode \ - -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DVCPKG_TARGET_TRIPLET=${{ inputs.vcpkg-triplet }} \ + -DCMAKE_OSX_ARCHITECTURES=${{ inputs.arch }} \ -DCMAKE_OSX_DEPLOYMENT_TARGET=11.6 shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 73b8755..0695a7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,8 +13,14 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - - - uses: ./.github/actions/common-windows + + - name: Caching + uses: ./.github/actions/caching + with: + key-prefix: windows-build + + - name: Configure and build + uses: ./.github/actions/common-windows with: config-preset: Release build-preset: Release @@ -36,19 +42,43 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - - - uses: ./.github/actions/common-macos + + - name: Caching + uses: ./.github/actions/caching + with: + key-prefix: macos-build + + - name: Configure and build x64 + uses: ./.github/actions/common-macos with: config-preset: Release build-preset: Release + vcpkg-triplet: x64-osx + arch: x86_64 + + - name: Configure and build arm64 + uses: ./.github/actions/common-macos + with: + config-preset: Release + build-preset: Release + vcpkg-triplet: arm64-osx + arch: arm64 + + - name: Merge binaries + run: | + mkdir -p ./bin/Release + cp -R ./bin/x86_64/Release/PartStackerGUI.app ./bin/Release/PartStackerGUI.app + lipo -create \ + ./bin/x86_64/Release/PartStackerGUI.app/Contents/MacOS/PartStackerGUI \ + ./bin/arm64/Release/PartStackerGUI.app/Contents/MacOS/PartStackerGUI \ + -output ./bin/Release/PartStackerGUI.app/Contents/MacOS/PartStackerGUI - name: Package into DMG run: | - mkdir -p ./bin/Release/dmg-root - mv ./bin/Release/PartStackerGUI.app ./bin/Release/dmg-root/ + mkdir -p ./bin/Release hdiutil create \ -volname "PartStackerGUI" \ - -srcfolder ./bin/Release/dmg-root \ + -srcfolder ./bin/Release \ -format UDZO \ ./bin/Release/PartStackerGUI-mac.dmg diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d9ee6c..d6a970f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,14 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - - - uses: ./.github/actions/common-windows + + - name: Caching + uses: ./.github/actions/caching + with: + key-prefix: windows-build + + - name: Configure and build + uses: ./.github/actions/common-windows with: config-preset: Debug build-preset: Tests @@ -28,11 +34,19 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - - - uses: ./.github/actions/common-macos + + - name: Caching + uses: ./.github/actions/caching + with: + key-prefix: macos-build + + - name: Configure and build + uses: ./.github/actions/common-macos with: config-preset: Debug build-preset: Tests + vcpkg-triplet: arm64-osx + arch: arm64 - name: Run Tests run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 94fce5d..e4d9404 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,13 @@ cmake_minimum_required(VERSION 3.30) -if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - set(VCPKG_TARGET_TRIPLET "x64-windows-static-md" CACHE STRING "" FORCE) -elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") - set(VCPKG_TARGET_TRIPLET "x64-osx" CACHE STRING "" FORCE) -else() - message(FATAL_ERROR "Unsupported platform: ${CMAKE_HOST_SYSTEM_NAME}") +if(NOT DEFINED VCPKG_TARGET_TRIPLET) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(VCPKG_TARGET_TRIPLET "x64-windows-static-md" CACHE STRING "" FORCE) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(VCPKG_TARGET_TRIPLET "arm64-osx" CACHE STRING "" FORCE) + else() + message(FATAL_ERROR "Unsupported platform: ${CMAKE_HOST_SYSTEM_NAME}") + endif() endif() project(PartStacker LANGUAGES CXX) diff --git a/external/vcpkg b/external/vcpkg index f26ec39..66ddab6 160000 --- a/external/vcpkg +++ b/external/vcpkg @@ -1 +1 @@ -Subproject commit f26ec398c25c4980f33a50391f00a75f7ad62ef7 +Subproject commit 66ddab67e28a9c8f53abe2063e0fb5ccd16e7103 diff --git a/src/pstack/gui/CMakeLists.txt b/src/pstack/gui/CMakeLists.txt index 72e0f76..2e194b2 100644 --- a/src/pstack/gui/CMakeLists.txt +++ b/src/pstack/gui/CMakeLists.txt @@ -39,5 +39,5 @@ set(PSTACK_OUTPUT_FILE_NAME "PartStackerGUI") pstack_configure_target_info(pstack_gui) set_target_properties(pstack_gui PROPERTIES OUTPUT_NAME ${PSTACK_OUTPUT_FILE_NAME} - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin/${CMAKE_OSX_ARCHITECTURES}" )