Skip to content

Commit

Permalink
Use parallel build for iOS (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
maroontress-tomohisa authored Aug 31, 2023
1 parent 08cd52a commit 98e8a1d
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 16 deletions.
68 changes: 59 additions & 9 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,74 @@ env:
BUILD_TYPE: Release

jobs:
build:
build_non_fat:
runs-on: macos-latest
timeout-minutes: 30

strategy:
max-parallel: 3
matrix:
abi: [x86_64, arm64]
sdk: [iphoneos, iphonesimulator]
exclude:
- abi: x86_64
sdk: iphoneos
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Configure
lfs: true
- name: Build ${{matrix.abi}}
run: |
sh ios.sh build configure
- name: Build
sh ios.sh build build-non-fat ${{matrix.sdk}} ${{matrix.abi}}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: build
if-no-files-found: error
install_and_test:
runs-on: macos-latest
timeout-minutes: 30
needs: build_non_fat
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: true
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Install fat files and XCFrameworks
run: |
sh ios.sh build build
- name: Install
sh ios.sh build install "$HOME/ios"
- name: Archive artifacts (xcframework)
uses: actions/upload-artifact@v3
with:
name: xcframework
path: ~/ios
if-no-files-found: error
- name: Run simulator
run: |
runtime=$(xcrun simctl list runtimes iOS -j | jq '.runtimes[].identifier' | tail -1)
udid=$(xcrun simctl list devices iPhone available -j | jq '.devices['$runtime']|.[].udid' | tail -1)
xcrun simctl bootstatus $(eval echo $udid) -b
- name: Test
run: |
sh ios.sh build install $HOME/ios
ctest --test-dir build/iphonesimulator-x86_64 -C Release
build-simply:
runs-on: macos-latest
timeout-minutes: 30
if: ${{false}}
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: true
- name: Configure
run: sh ios.sh build configure
- name: Build
run: sh ios.sh build build
- name: Install
run: sh ios.sh build install $HOME/ios
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
45 changes: 38 additions & 7 deletions ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if [ "$#" = "0" ] ; then
echo usage: $0 BUILD_DIR build
echo usage: $0 BUILD_DIR install INSTALL_DIR
echo usage: $0 BUILD_DIR test ARCH
echo usage: $0 BUILD_DIR build-non-fat SDK ARCH
exit 1
fi
root_build_dir="$1"
Expand Down Expand Up @@ -143,6 +144,28 @@ cmake_install() {
-- -sdk $sdk -destination "$destination" || exit 1
}

check_sdk() {
sdk="$1"
case "$sdk" in
iphoneos|iphonesimulator)
;;
*)
echo unknown SDK: $sdk
exit 1
esac
}

check_arch() {
arch="$1"
case "$arch" in
arm64|x86_64)
;;
*)
echo unknown ARCH: $arch
exit 1
esac
}

if [ "$#" = "0" ] ; then
echo COMMAND not specified
exit 1
Expand All @@ -154,6 +177,20 @@ sdk_list="iphoneos iphonesimulator"
all="iphoneos-arm64 iphonesimulator-arm64 iphonesimulator-x86_64"

case "$command" in
build-non-fat)
if [ "$#" -lt 2 ] ; then
echo SDK and ARCH not specified
exit 1
fi
sdk="$1"
arch="$2"
shift 2
check_sdk $sdk
check_arch $arch
rm -rf $root_build_dir || exit 1
configure $sdk $arch "$@" || exit 1
build $sdk $arch || exit 1
;;
configure)
rm -rf $root_build_dir || exit 1
for i in $all ; do
Expand Down Expand Up @@ -213,13 +250,7 @@ test)
fi
arch="$1"
shift
case "$arch" in
arm64|x86_64)
;;
*)
echo unknown ARCH: $arch
exit 1
esac
check_arch $arch
runtime=$(xcrun simctl list runtimes iOS -j \
| jq '.runtimes[].identifier' | tail -1)
udid=$(xcrun simctl list devices iPhone available -j \
Expand Down

0 comments on commit 98e8a1d

Please sign in to comment.