move logic inside runner == macos if

This commit is contained in:
Bruno Alexandre Rosa 2025-10-10 15:11:42 -03:00
parent 0647e0b6e3
commit 42fe2d7f73

View file

@ -11,7 +11,7 @@
# --debug or --release sets the build type ie CMAKE_BUILD_TYPE
# --ccache [<size>] uses ccache and shows stats, optionally provide size
# --dir <dir> sets the name of the build dir, default is "build"
# --target-macos-version <version> sets the min os version - only used for x86 (Intel) macOS builds
# --target-macos-version <version> sets the min os version - only used for macOS builds
# uses env: BUILDTYPE MAKE_INSTALL MAKE_PACKAGE PACKAGE_TYPE PACKAGE_SUFFIX MAKE_SERVER MAKE_TEST USE_CCACHE CCACHE_SIZE BUILD_DIR CMAKE_GENERATOR
# (correspond to args: --debug/--release --install --package <package type> --suffix <suffix> --server --test --ccache <ccache_size> --dir <dir>)
# exitcode: 1 for failure, 3 for invalid arguments
@ -133,26 +133,6 @@ fi
if [[ $USE_VCPKG ]]; then
flags+=("-DUSE_VCPKG=1")
fi
if [[ $TARGET_MACOS_VERSION ]]; then
# CMAKE_OSX_DEPLOYMENT_TARGET is a vanilla cmake flag needed to compile to target macOS version
flags+=("-DCMAKE_OSX_DEPLOYMENT_TARGET=${TARGET_MACOS_VERSION}")
# vcpkg dependencies need a vcpkg triplet file to compile to the target macOS version
# an easy way is to copy the x64-osx.cmake file and modify it
TRIPLETS_DIR="../cmake/triplets"
mkdir -p "$TRIPLETS_DIR"
# Replace dots with hyphens in triplet name for vcpkg compatibility
TRIPLET_VERSION=$(echo "${TARGET_MACOS_VERSION}" | sed 's/\./-/g')
TRIPLET_FILE="$TRIPLETS_DIR/x64-osx-${TRIPLET_VERSION}.cmake"
cp ../vcpkg/triplets/x64-osx.cmake "$TRIPLET_FILE"
echo "set(VCPKG_CMAKE_SYSTEM_VERSION ${TARGET_MACOS_VERSION})" >> "$TRIPLET_FILE"
echo "set(VCPKG_OSX_DEPLOYMENT_TARGET ${TARGET_MACOS_VERSION})" >> "$TRIPLET_FILE"
flags+=("-DVCPKG_OVERLAY_TRIPLETS=$TRIPLETS_DIR")
flags+=("-DVCPKG_TARGET_TRIPLET=x64-osx-${TRIPLET_VERSION}")
echo "::group::Generated triplet $TRIPLET_FILE"
cat "$TRIPLET_FILE"
echo "::endgroup::"
fi
# Add cmake --build flags
buildflags=(--config "$BUILDTYPE")
@ -169,6 +149,27 @@ function ccachestatsverbose() {
# Compile
if [[ $RUNNER_OS == macOS ]]; then
if [[ $TARGET_MACOS_VERSION ]]; then
# CMAKE_OSX_DEPLOYMENT_TARGET is a vanilla cmake flag needed to compile to target macOS version
flags+=("-DCMAKE_OSX_DEPLOYMENT_TARGET=${TARGET_MACOS_VERSION}")
# vcpkg dependencies need a vcpkg triplet file to compile to the target macOS version
# an easy way is to copy the x64-osx.cmake file and modify it
TRIPLETS_DIR="../cmake/triplets"
mkdir -p "$TRIPLETS_DIR"
# Replace dots with hyphens in triplet name for vcpkg compatibility
TRIPLET_VERSION=$(echo "${TARGET_MACOS_VERSION}" | sed 's/\./-/g')
TRIPLET_FILE="$TRIPLETS_DIR/x64-osx-${TRIPLET_VERSION}.cmake"
cp ../vcpkg/triplets/x64-osx.cmake "$TRIPLET_FILE"
echo "set(VCPKG_CMAKE_SYSTEM_VERSION ${TARGET_MACOS_VERSION})" >> "$TRIPLET_FILE"
echo "set(VCPKG_OSX_DEPLOYMENT_TARGET ${TARGET_MACOS_VERSION})" >> "$TRIPLET_FILE"
flags+=("-DVCPKG_OVERLAY_TRIPLETS=$TRIPLETS_DIR")
flags+=("-DVCPKG_TARGET_TRIPLET=x64-osx-${TRIPLET_VERSION}")
echo "::group::Generated triplet $TRIPLET_FILE"
cat "$TRIPLET_FILE"
echo "::endgroup::"
fi
echo "::group::Signing Certificate"
if [[ -n "$MACOS_CERTIFICATE_NAME" ]]; then
echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12