GitlabCI: use lipo to create universal darwin binary

This commit is contained in:
Alam Ed Arias 2025-02-06 22:12:22 -05:00
parent 1e47cb2061
commit 620bb5054f
4 changed files with 103 additions and 14 deletions

View file

@ -12,6 +12,7 @@ variables:
stages:
- build
- osxcross
default:
interruptible: true

View file

@ -5,10 +5,11 @@ osxcross arm64:
artifacts:
paths:
- "build.cmake/bin/"
- "build.cmake/src/config.h"
- "build.arm64/bin/"
- "build.arm64/dist/arm64.h"
- "build.arm64/src/config.h"
expose_as: "Mac arm64"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-arm64-apple-darwin21.4"
variables:
OSXCROSS_HOST: arm64-apple-darwin21.4
@ -18,8 +19,8 @@ osxcross arm64:
- - |
# apt_development
echo -e "\e[0Ksection_start:`date +%s`:macports_development[collapsed=true]\r\e[0KInstalling development packages"
- osxcross-macports install --arm64 libxmp wavpack libopenmpt opusfile
- osxcross-macports install --static --arm64 curl libsdl2_mixer libpng
- osxcross-macports install --arm64 libxmp wavpack libopenmpt opusfile || osxcross-macports install --arm64 libxmp wavpack libopenmpt opusfile
- osxcross-macports install --static --arm64 curl libsdl2_mixer libpng || osxcross-macports install --static --arm64 curl libsdl2_mixer libpng
- |
# apt_development
echo -e "\e[0Ksection_end:`date +%s`:macports_development\r\e[0K"
@ -27,7 +28,7 @@ osxcross arm64:
- - |
# cmake
echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
- cmake -B build.cmake --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_CONFIG_FORCE_NO_MS_BITFIELDS:BOOL=ON -DSRB2_CONFIG_USE_GME:BOOL=OFF
- cmake -B build.arm64 --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_CONFIG_FORCE_NO_MS_BITFIELDS:BOOL=ON -DSRB2_CONFIG_USE_GME:BOOL=OFF -DSRB2_SDL2_EXE_NAME=srb2_$CI_PIPELINE_ID
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
@ -35,7 +36,16 @@ osxcross arm64:
- - |
# make
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
- cmake --build build.cmake --parallel 1 --verbose
- cmake --build build.arm64 --parallel 1 --verbose
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
- - |
# copy config.h
echo -e "\e[0Ksection_start:`date +%s`:copy[collapsed=false]\r\e[0KCopying config.h"
- mkdir --parents --verbose build.arm64/dist
- cp --reflink=auto --sparse=always --verbose build.arm64/src/config.h build.arm64/dist/arm64.h
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:copy\r\e[0K"

View file

@ -29,10 +29,11 @@ osxcross x86_64:
artifacts:
paths:
- "build.cmake/bin/"
- "build.cmake/src/config.h"
- "build.x86_64/bin/"
- "build.x86_64/dist/x86_64.h"
- "build.x86_64/src/config.h"
expose_as: "Mac x86_64"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-x86_64-apple-darwin21.4"
variables:
OSXCROSS_HOST: x86_64-apple-darwin21.4
@ -63,8 +64,8 @@ osxcross x86_64:
- - |
# apt_development
echo -e "\e[0Ksection_start:`date +%s`:macports_development[collapsed=true]\r\e[0KInstalling development packages"
- osxcross-macports install libxmp wavpack libopenmpt opusfile
- osxcross-macports install --static curl libsdl2_mixer libpng
- osxcross-macports install libxmp wavpack libopenmpt opusfile || osxcross-macports install libxmp wavpack libopenmpt opusfile
- osxcross-macports install --static curl libsdl2_mixer libpng || osxcross-macports install --static curl libsdl2_mixer libpng
- |
# apt_development
echo -e "\e[0Ksection_end:`date +%s`:macports_development\r\e[0K"
@ -72,7 +73,7 @@ osxcross x86_64:
- - |
# cmake
echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
- cmake -B build.cmake --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_CONFIG_USE_GME:BOOL=OFF
- cmake -B build.x86_64 --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_CONFIG_USE_GME:BOOL=OFF -DSRB2_SDL2_EXE_NAME=srb2_$CI_PIPELINE_ID
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
@ -80,11 +81,21 @@ osxcross x86_64:
- - |
# make
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
- cmake --build build.cmake --parallel 1 --verbose
- cmake --build build.x86_64 --parallel 1 --verbose
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
- - |
# copy config.h
echo -e "\e[0Ksection_start:`date +%s`:copy[collapsed=false]\r\e[0KCopying config.h"
- mkdir --parents --verbose build.x86_64/dist
- cp --reflink=auto --sparse=always --verbose build.x86_64/src/config.h build.x86_64/dist/x86_64.h
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:copy\r\e[0K"
after_script:
- - |
# apt_clean

View file

@ -0,0 +1,67 @@
osxcross universal:
image: git.do.srb2.org:5050/stjr/srb2ci/srb2ci:stable
dependencies:
- osxcross arm64
- osxcross x86_64
needs:
- job: osxcross arm64
- job: osxcross x86_64
stage: osxcross
artifacts:
paths:
- "dist/bin"
- "dist/src"
expose_as: "Mac Universal"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-lipo-apple-darwin21.4"
script:
- - |
# mkdir
echo -e "\e[0Ksection_start:`date +%s`:mkdir[collapsed=true]\r\e[0KMaking dist folder"
mkdir --parents --verbose dist/src dist/bin
- |
# mkdir
echo -e "\e[0Ksection_end:`date +%s`:mkdir\r\e[0K"
- - |
# copy-config
echo -e "\e[0Ksection_start:`date +%s`:x86_64-config[collapsed=true]\r\e[0KCopying x86_64 config"
- cp --reflink=auto --sparse=always --verbose --target-directory=dist/src/ build.*/dist/*.h
- |
# x86_64-config
echo -e "\e[0Ksection_end:`date +%s`:x86_64-config\r\e[0K"
- - |
# copy-build
echo -e "\e[0Ksection_start:`date +%s`:copy-build[collapsed=true]\r\e[0KCopying ALL build"
- cp --reflink=auto --sparse=always --recursive --verbose --target-directory=dist/ build.*/bin/
- |
# copy-build
echo -e "\e[0Ksection_end:`date +%s`:copy-build\r\e[0K"
- - |
# link-build
echo -e "\e[0Ksection_start:`date +%s`:link-build[collapsed=true]\r\e[0KLinking universal build"
- lipo -create -output dist/bin/srb2_$CI_PIPELINE_ID.app/Contents/MacOS/srb2_$CI_PIPELINE_ID build.*/bin/srb2_$CI_PIPELINE_ID.app/Contents/MacOS/srb2_$CI_PIPELINE_ID
- |
# universal-build
echo -e "\e[0Ksection_end:`date +%s`:link-build\r\e[0K"
- - |
# arm64-verify
echo -e "\e[0Ksection_start:`date +%s`:arm64-verify[collapsed=true]\r\e[0KVerifying arm64"
- lipo dist/bin/srb2_$CI_PIPELINE_ID.app/Contents/MacOS/srb2_$CI_PIPELINE_ID -verify_arch arm64
- |
# arm64-verify
echo -e "\e[0Ksection_end:`date +%s`:arm64-verify\r\e[0K"
- - |
# x86_64-verify
echo -e "\e[0Ksection_start:`date +%s`:x86_64-verify[collapsed=true]\r\e[0KVerifying x86_64"
- lipo dist/bin/srb2_$CI_PIPELINE_ID.app/Contents/MacOS/srb2_$CI_PIPELINE_ID -verify_arch x86_64
- |
# x86_64-verify
echo -e "\e[0Ksection_end:`date +%s`:x86_64-verify\r\e[0K"