Skip to content

Commit

Permalink
build(MacOS): Fully replace Xcode by CMake for MacOS build (endless-s…
Browse files Browse the repository at this point in the history
  • Loading branch information
quyykk authored Jan 7, 2023
1 parent 08f285d commit 6c3abe8
Show file tree
Hide file tree
Showing 24 changed files with 143 additions and 2,072 deletions.
12 changes: 0 additions & 12 deletions .github/path-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ data:
game_code: &build
- 'source/**'

macos:
- 'XCode/**'
- '**/*.xcodeproj'
- 'icons/endless-sky.iconset/**'
- 'utils/fetch_sdl2_framework.sh'
- 'utils/set_dylibs_rpath.sh'
- *build

windows:
- '**/*.cbp'
- EndlessSky.workspace
Expand All @@ -45,10 +37,6 @@ integration_tests:
codespell:
- .codespell.exclude

xcode_files:
- 'EndlessSky.xcodeproj/**'
- 'utils/check_xcode.sh'

codeblocks_files:
- '*.cbp'
- 'utils/check_codeblocks.sh'
Expand Down
36 changes: 17 additions & 19 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,30 @@ jobs:
name: ${{ env.OUTPUT }}
path: ${{ env.OUTPUT }}

cd_macos_x86_64:
cd_macos_x64:
name: MacOS
runs-on: macos-latest
runs-on: macos-12
env:
OUTPUT: EndlessSky-macOS-continuous.zip
SDL2_FRAMEWORK: build/SDL2.framework
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Update Homebrew
run: brew update
- name: Install dependencies
run: brew install libpng jpeg-turbo
- name: Restore cached SDL2 framework
uses: actions/cache@v3
- name: Setup sccache
uses: ./.github/sccache
with:
path: ${{ env.SDL2_FRAMEWORK }}
key: macos-latest-sdl2-${{ hashFiles('EndlessSky.xcodeproj/**', 'utils/set_dylibs_rpath.sh', 'utils/fetch_sdl2_framework.sh') }}
- name: Adjust version strings
run: ./utils/cd_update_versions.sh
shell: bash
- name: Build Application
run: xcodebuild -configuration "Release" -jobs $(sysctl -n hw.logicalcpu) -quiet
read-only: 'true'
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
with:
vcpkgGitCommitId: '163fe7bd3d67c41200617caaa245b5ba2ba854e6'
- uses: lukka/run-cmake@v10
with:
configurePreset: 'macos-release'
buildPreset: 'macos-ci-release'
- name: Package Application
run: |
cd build/Release
7z a ${{ github.workspace }}/${{ env.OUTPUT }} Endless\ Sky.app
cmake --install build/release
7z a ${{ env.OUTPUT }} "./install/release/*"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -129,7 +127,7 @@ jobs:
needs:
- cd_appimage_x86_64
- cd_windows_win64
- cd_macos_x86_64
- cd_macos_x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OUTPUT_APPIMAGE: endless-sky-x86_64-continuous.AppImage
Expand Down
70 changes: 38 additions & 32 deletions .github/workflows/cd_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,48 @@ jobs:
asset_name: ${{ env.OUTPUT }}
asset_content_type: application/octet-stream

dmg_macos:
name: MacOS
runs-on: macos-latest

release_macos_universal:
name: MacOS Universal
runs-on: macos-12
env:
OUTPUT: endless-sky-macos-${{ github.event.release.tag_name }}
SDL2_FRAMEWORK: build/SDL2.framework
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OUTPUT: Endless-Sky-${{ github.event.release.tag_name }}
steps:
- uses: actions/checkout@v3
- name: Update Homebrew
run: brew update
- name: Install dependencies
run: brew install libpng jpeg-turbo
- name: Restore cached SDL2 framework
uses: actions/cache@v3
- name: Setup sccache
uses: ./.github/sccache
with:
path: ${{ env.SDL2_FRAMEWORK }}
key: macos-latest-sdl2-${{ hashFiles('EndlessSky.xcodeproj/**', 'utils/set_dylibs_rpath.sh', 'utils/fetch_sdl2_framework.sh') }}
- name: Build Application
run: xcodebuild -configuration "Release" -jobs $(sysctl -n hw.logicalcpu) -quiet
- name: Package Application
read-only: 'true'
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
with:
vcpkgGitCommitId: '163fe7bd3d67c41200617caaa245b5ba2ba854e6'
- uses: lukka/run-cmake@v10
with:
configurePreset: 'macos-arm-release'
buildPreset: 'macos-ci-release'
- name: Prepare for x64 app bundle
run: |
cd build/Release
mkdir ${{ env.OUTPUT }}
mv Endless\ Sky.app ${{ env.OUTPUT }}
ln -s /Applications ${{ env.OUTPUT }}
hdiutil create -ov -fs HFS+ -format UDZO -imagekey zlib-level=9 -srcfolder ${{ env.OUTPUT }} ${{ github.workspace }}/${{ env.OUTPUT }}.dmg
- name: Upload artifact
uses: actions/upload-artifact@v3
mv "build/release/Endless Sky.app" "Endless Sky.app.arm"
rm -rf build/release
- uses: lukka/run-cmake@v10
with:
name: ${{ env.OUTPUT }}.dmg
path: ${{ env.OUTPUT }}.dmg
- name: Upload disk image
uses: actions/[email protected]
configurePreset: 'macos-release'
buildPreset: 'macos-ci-release'
- name: Create universal binary
run: |
mv "build/release/Endless Sky.app" "Endless Sky.app.x64"
cp -r "Endless Sky.app.arm" "Endless Sky.app"
lipo -create -output "Endless Sky.app/Contents/MacOS/Endless Sky" "Endless Sky.app.arm/Contents/MacOS/Endless Sky" "Endless Sky.app.x64/Contents/MacOS/Endless Sky"
for lib in "Endless Sky.app/Contents/Frameworks/"*; do lipo -create -output "$lib" "Endless Sky.app.arm/Contents/Frameworks/$(basename "$lib")" "Endless Sky.app.x64/Contents/Frameworks/$(basename "$lib")"; done
- name: Package Application
run: |
mkdir "${{ env.OUTPUT }}"
cp -r "Endless Sky.app" "${{ env.OUTPUT }}"
ln -s /Applications "${{ env.OUTPUT }}"
hdiutil create -ov -fs HFS+ -format UDZO -imagekey zlib-level=9 -srcfolder "${{ env.OUTPUT }}" "${{ github.workspace }}/${{ env.OUTPUT }}.dmg"
- name: Upload Release
uses: softprops/action-gh-release@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.OUTPUT }}.dmg
asset_name: ${{ env.OUTPUT }}.dmg
asset_content_type: application/octet-stream
files: ${{ env.OUTPUT }}.dmg
65 changes: 20 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ on:
- 'source/**'
- 'data/**'
- 'tests/**'
- 'EndlessSky.xcodeproj/**'
- 'XCode/**'
- '.github/workflows/**'
- keys.txt
- SConstruct
Expand All @@ -39,8 +37,6 @@ on:
- 'source/**'
- 'data/**'
- 'tests/**'
- 'EndlessSky.xcodeproj/**'
- 'XCode/**'
- '.github/workflows/**'
- keys.txt
- SConstruct
Expand Down Expand Up @@ -253,28 +249,30 @@ jobs:
build_macos:
name: MacOS
needs: changed
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.xcode_files == 'true' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
runs-on: macos-12
env:
ARTIFACT: Endless Sky
SDL2_FRAMEWORK: build/SDL2.framework
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
brew update
brew install libpng jpeg-turbo
- name: Restore cached SDL2 framework
uses: actions/cache@v3
- name: Setup sccache
uses: ./.github/sccache
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
with:
path: ${{ env.SDL2_FRAMEWORK }}
key: ${{ matrix.os }}-sdl2-${{ hashFiles('.github/workflows/ci.yml', 'EndlessSky.xcodeproj/**', 'utils/set_dylibs_rpath.sh', 'utils/fetch_sdl2_framework.sh') }}
- name: Compile
if: steps.cache-artifact.outputs.cache-hit != 'true'
run: xcodebuild -configuration "Release" -jobs $(sysctl -n hw.logicalcpu) -quiet
vcpkgGitCommitId: '163fe7bd3d67c41200617caaa245b5ba2ba854e6'
- uses: lukka/run-cmake@v10
with:
configurePreset: 'macos-ci'
buildPreset: 'macos-ci'
testPreset: 'macos-ci'
- name: Run Benchmarks
run: ctest --preset macos-ci-benchmark
- name: Prevent saving cache on failure
run: |
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
if: ${{ failure() || cancelled() }}
shell: bash


test_ubuntu-integration:
Expand Down Expand Up @@ -484,29 +482,6 @@ jobs:
if: ${{ failure() || cancelled() }}
shell: bash

build_macos_cmake:
name: MacOS (CMake)
needs: changed
if: ${{ needs.changed.outputs.game_code == 'true' || needs.changed.outputs.unit_tests == 'true' || needs.changed.outputs.cmake_files == 'true' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: lukka/get-cmake@latest
- uses: lukka/run-vcpkg@v10
with:
vcpkgGitCommitId: '163fe7bd3d67c41200617caaa245b5ba2ba854e6'
- uses: lukka/run-cmake@v10
with:
configurePreset: 'macos-ci'
buildPreset: 'macos-ci'
testPreset: 'macos-ci'
- name: Run Benchmarks
run: ctest --preset macos-ci-benchmark
- name: Prevent saving cache on failure
run: |
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
if: ${{ failure() || cancelled() }}
shell: bash

build_windows_clang_cmake:
name: Windows Clang (CMake)
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/compute-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
value: ${{ jobs.changed.outputs.data }}
game_code:
value: ${{ jobs.changed.outputs.game_code }}
macos:
value: ${{ jobs.changed.outputs.macos }}
windows:
value: ${{ jobs.changed.outputs.windows }}
linux:
Expand All @@ -17,8 +15,6 @@ on:
value: ${{ jobs.changed.outputs.integration_tests }}
codespell:
value: ${{ jobs.changed.outputs.codespell }}
xcode_files:
value: ${{ jobs.changed.outputs.xcode_files }}
codeblocks_files:
value: ${{ jobs.changed.outputs.codeblocks_files }}
cmake_files:
Expand All @@ -32,13 +28,11 @@ jobs:
outputs:
data: ${{ steps.filter.outputs.data }}
game_code: ${{ steps.filter.outputs.game_code }}
macos: ${{ steps.filter.outputs.macos }}
windows: ${{ steps.filter.outputs.windows }}
linux: ${{ steps.filter.outputs.linux }}
unit_tests: ${{ steps.filter.outputs.unit_tests }}
integration_tests: ${{ steps.filter.outputs.integration_tests }}
codespell: ${{ steps.filter.outputs.codespell }}
xcode_files: ${{ steps.filter.outputs.xcode_files }}
codeblocks_files: ${{ steps.filter.outputs.codeblocks_files }}
cmake_files: ${{ steps.filter.outputs.cmake_files }}
copyright: ${{ steps.filter.outputs.copyright }}
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/projects_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
paths:
- '.github/workflows/projects_check.yml'
- 'copyright'
- 'EndlessSky.xcodeproj/**'
- '*.cbp'
- 'source/**'
- 'tests/unit/**'
Expand All @@ -18,7 +17,6 @@ on:
paths:
- '.github/workflows/projects_check.yml'
- 'copyright'
- 'EndlessSky.xcodeproj/**'
- '*.cbp'
- 'source/**'
- 'tests/unit/**'
Expand All @@ -32,25 +30,6 @@ jobs:
changed:
uses: ./.github/workflows/compute-changes.yml

check-xcode:
name: XCode
needs: changed
if: ${{ needs.changed.outputs.xcode_files || needs.changed.outputs.game_code }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install dependencies
run: python3 -m pip install --user docopt openstep_parser pbxproj
- name: Validate XCode .pbxproj file
run: ./utils/check_xcode.sh
- name: Upload XCode patch
if: failure()
uses: actions/upload-artifact@v3
with:
name: xcode-project.patch
path: xcode-project.patch

check-codeblocks:
name: CodeBlocks
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if(APPLE AND ES_CREATE_BUNDLE)

# Add plist to bundle.
set_target_properties(EndlessSky PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/XCode/EndlessSky-Info.plist"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/resources/EndlessSky-Info.plist"
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME endless-sky)
set_target_properties(EndlessSky PROPERTIES OUTPUT_NAME "Endless Sky")
elseif(WIN32)
Expand Down
Loading

0 comments on commit 6c3abe8

Please sign in to comment.