Skip to content

Commit

Permalink
Feature: Build macOS build as a universal binary
Browse files Browse the repository at this point in the history
  • Loading branch information
orudge committed Jan 15, 2021
1 parent 0e62a39 commit e4d3975
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions .github/workflows/release.yml
Expand Up @@ -362,12 +362,6 @@ jobs:

strategy:
fail-fast: false
matrix:
include:
- arch: x64
full_arch: x86_64
- arch: arm64
full_arch: arm64

runs-on: macos-10.15
env:
Expand Down Expand Up @@ -397,8 +391,7 @@ jobs:
vcpkgDirectory: '/usr/local/share/vcpkg'
doNotUpdateVcpkg: false
vcpkgGitCommitId: 2a42024b53ebb512fb5dd63c523338bf26c8489c
vcpkgArguments: 'freetype liblzma lzo'
vcpkgTriplet: '${{ matrix.arch }}-osx'
vcpkgArguments: 'freetype:x64-osx liblzma:x64-osx lzo:x64-osx freetype:arm64-osx liblzma:arm64-osx lzo:arm64-osx'

- name: Build tools
run: |
Expand Down Expand Up @@ -430,15 +423,35 @@ jobs:
# If this is run on a fork, there may not be a certificate set up - continue in this case
continue-on-error: true

- name: Build
- name: Build arm64
run: |
mkdir build-arm64
cd build-arm64
echo "::group::CMake"
cmake ${GITHUB_WORKSPACE} \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DVCPKG_TARGET_TRIPLET=arm64-osx \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
# EOF
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(sysctl -n hw.logicalcpu) cores"
make -j$(sysctl -n hw.logicalcpu)
echo "::endgroup::"
- name: Build x86_64
run: |
mkdir build
cd build
echo "::group::CMake"
cmake ${GITHUB_WORKSPACE} \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.full_arch }} \
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-osx \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DVCPKG_TARGET_TRIPLET=x64-osx \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
Expand All @@ -456,6 +469,23 @@ jobs:
# the end of this workflow.
rm -f bundles/*.sha256
- name: Build package
run: |
cd build
# Combine the `openttd` binaries from each build into a single file
mv openttd openttd-x64
lipo -create -output openttd openttd-x64 ../build-arm64/openttd
echo "::group::Build"
echo "Running on $(sysctl -n hw.logicalcpu) cores"
make -j$(sysctl -n hw.logicalcpu) package
echo "::endgroup::"
# Remove the sha256 files CPack generates; we will do this ourself at
# the end of this workflow.
rm -f bundles/*.sha256
- name: Install gon
env:
HOMEBREW_NO_AUTO_UPDATE: 1
Expand All @@ -475,7 +505,7 @@ jobs:
- name: Store bundles
uses: actions/upload-artifact@v2
with:
name: openttd-macos-${{ matrix.arch }}
name: openttd-macos-universal
path: build/bundles
retention-days: 5

Expand Down

0 comments on commit e4d3975

Please sign in to comment.