Skip to content

Commit ac395c7

Browse files
committed
CI for iOS
1 parent 01ea6bf commit ac395c7

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

.github/workflows/cross-test.yml

+13
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,17 @@ jobs:
109109
env:
110110
CFLAGS: "-Wno-string-compare"
111111
run: tests/ci/run_cross_tests.sh s390x s390x-ibm-linux-gnu "-DCMAKE_BUILD_TYPE=Release"
112+
ios-aarch64:
113+
if: github.repository_owner == 'aws'
114+
name: iOS aarch64 cross-platform build
115+
runs-on: macos-latest
116+
steps:
117+
- uses: actions/checkout@v3
118+
- uses: actions/setup-go@v4
119+
with:
120+
go-version: '>=1.18'
121+
- run: |
122+
brew install llvm bash
123+
- name: iOS Simulator Runner
124+
run: tests/ci/run_ios_sim_tests.sh
112125

tests/ci/run_ios_sim_tests.sh

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0 OR ISC
4+
5+
set -e
6+
7+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
8+
SCRIPT_DIR="$(readlink -f "${SCRIPT_DIR}")"
9+
10+
source "${SCRIPT_DIR}/common_posix_setup.sh"
11+
12+
SIM_IMAGE_LIST_PATH='/Library/Developer/CoreSimulator/Images/images.plist'
13+
SIM_IMAGE_MOUNT_BASE='/Volumes'
14+
SIM_IMAGE_PATTERN='iOS-17'
15+
16+
if [[ ! -r "${SIM_IMAGE_LIST_PATH}" ]]; then
17+
echo ERROR: Image list not found: "${SIM_IMAGE_LIST_PATH}"
18+
exit 1
19+
fi
20+
21+
function plist_count_images() {
22+
plutil -extract 'images' raw "${SIM_IMAGE_LIST_PATH}" -o -
23+
}
24+
25+
function plist_image_id_for() {
26+
plutil -extract "images.${1}.runtimeInfo.bundleIdentifier" raw "${SIM_IMAGE_LIST_PATH}" -o -
27+
}
28+
29+
function plist_image_path_for() {
30+
plutil -extract "images.${1}.path.relative" raw "${SIM_IMAGE_LIST_PATH}" -o - | sed -e 's/^file:\/\///'
31+
}
32+
33+
function plist_image_build_for() {
34+
plutil -extract "images.${1}.runtimeInfo.build" raw "${SIM_IMAGE_LIST_PATH}" -o -
35+
}
36+
37+
function find_mount() {
38+
hdiutil info | grep -s "${1}"
39+
}
40+
41+
function find_runtime_root() {
42+
find "${1}" -type d -name "RuntimeRoot" |head -n 1
43+
}
44+
45+
46+
IMAGE_LIST_SIZE=$(plist_count_images)
47+
IMAGE_LIST_LAST_IDX=$(( "${IMAGE_LIST_SIZE}" - 1 ))
48+
IMAGE_PATH=''
49+
IMAGE_BUILD=''
50+
51+
52+
for i in $(seq 0 "${IMAGE_LIST_LAST_IDX}"); do
53+
if [[ $(plist_image_id_for "${i}") == *"${SIM_IMAGE_PATTERN}"* ]]; then
54+
IMAGE_PATH=$(plist_image_path_for "${i}")
55+
IMAGE_BUILD=$(plist_image_build_for "${i}")
56+
fi
57+
done
58+
59+
if [[ -z ${IMAGE_PATH} ]]; then
60+
echo ERROR: ${SIM_IMAGE_PATTERN} image not found.
61+
exit 1
62+
fi
63+
64+
IMAGE_MOUNT_POINT="${SIM_IMAGE_MOUNT_BASE}/iOS_${IMAGE_BUILD}"
65+
66+
if ! find_mount "${IMAGE_MOUNT_POINT}"; then
67+
sudo hdiutil attach "${IMAGE_PATH}" -mountpoint "${IMAGE_MOUNT_POINT}"
68+
fi
69+
70+
if ! find_mount "${IMAGE_MOUNT_POINT}"; then
71+
echo ERROR: Unable to mount runtime
72+
exit 1
73+
fi
74+
75+
DYLD_ROOT_PATH=''
76+
DYLD_ROOT_PATH=$(find_runtime_root "${IMAGE_MOUNT_POINT}")
77+
78+
if [[ -z "${DYLD_ROOT_PATH}" ]]; then
79+
echo ERROR: RuntimeRoot not found: "${IMAGE_MOUNT_POINT}"
80+
exit 1
81+
fi
82+
83+
export DYLD_ROOT_PATH
84+
85+
pushd "${SRC_ROOT}"
86+
87+
CMAKE_PARAMS=("-DCMAKE_OSX_ARCHITECTURES=arm64" "-DCMAKE_SYSTEM_PROCESSOR=arm64" "-DCMAKE_OSX_SYSROOT=iphonesimulator" "-DCMAKE_THREAD_LIBS_INIT=-lpthread" "-DBUILD_TOOL=0")
88+
run_build "${CMAKE_PARAMS[@]}"
89+
90+
popd
91+
92+
93+

0 commit comments

Comments
 (0)