Skip to content

Commit

Permalink
CI script to setup/test aarch64-apple-ios-sim
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwsmith committed Feb 22, 2024
1 parent 5d13428 commit e340f53
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 8 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ (matrix.target == 'riscv64gc-unknown-linux-gnu' && '1.72.1') || 'stable' }}
toolchain: ${{ (matrix.target == 'riscv64gc-unknown-linux-gnu' && '1.72.1') || 'stable' }}
target: ${{ matrix.target }}
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
Expand All @@ -69,7 +69,6 @@ jobs:
matrix:
rust: [ stable ]
os: [ macos-13-xlarge ]
target: [ aarch64-apple-ios-sim ]
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -78,11 +77,10 @@ jobs:
id: toolchain
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
target: aarch64-apple-ios-sim
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
- name: Run cargo test
working-directory: ./aws-lc-rs
run: cargo test --features bindgen,unstable --target ${{ matrix.target }}
env:
DYLD_ROOT_PATH: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot"
- name: Install bash
run: brew install bash
- name: iOS Simulator Runner
run: ./scripts/ci/ios-simulator-runner.sh
81 changes: 81 additions & 0 deletions scripts/ci/ios-simulator-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -e

REPO_ROOT=$(git rev-parse --show-toplevel)

SIM_IMAGE_LIST_PATH='/Library/Developer/CoreSimulator/Images/images.plist'
SIM_IMAGE_MOUNT_BASE='/Volumes'

if [[ ! -r "${SIM_IMAGE_LIST_PATH}" ]]; then
echo ERROR: Image list not found: "${SIM_IMAGE_LIST_PATH}"
exit 1
fi

function plist_count_images() {
plutil -extract 'images' raw "${SIM_IMAGE_LIST_PATH}" -o -
}

function plist_image_id_for() {
plutil -extract "images.${1}.runtimeInfo.bundleIdentifier" raw "${SIM_IMAGE_LIST_PATH}" -o -
}

function plist_image_path_for() {
plutil -extract "images.${1}.path.relative" raw "${SIM_IMAGE_LIST_PATH}" -o - | sed -e 's/^file:\/\///'
}

function plist_image_build_for() {
plutil -extract "images.${1}.runtimeInfo.build" raw "${SIM_IMAGE_LIST_PATH}" -o -
}

function find_mount() {
hdiutil info | grep -s "${1}"
}

function find_runtime_root() {
find "${1}" -type d -name "RuntimeRoot" |head -n 1
}


IMAGE_LIST_SIZE=$(plist_count_images)
IMAGE_LIST_LAST_IDX=$(( "${IMAGE_LIST_SIZE}" - 1 ))
IMAGE_PATH=''
IMAGE_BUILD=''


for i in $(seq 0 "${IMAGE_LIST_LAST_IDX}"); do
if [[ $(plist_image_id_for "${i}") = *iOS-17* ]]; then
IMAGE_PATH=$(plist_image_path_for "${i}")
IMAGE_BUILD=$(plist_image_build_for "${i}")
fi
done

if [[ -z ${IMAGE_PATH} ]]; then
echo ERROR: iOS 17 image not found.
exit 1
fi

IMAGE_MOUNT_POINT="${SIM_IMAGE_MOUNT_BASE}/iOS_${IMAGE_BUILD}"

if ! find_mount "${IMAGE_MOUNT_POINT}"; then
sudo hdiutil attach "${IMAGE_PATH}" -mountpoint "${IMAGE_MOUNT_POINT}"
fi

if ! find_mount "${IMAGE_MOUNT_POINT}"; then
echo ERROR: Unable to mount runtime
exit 1
fi

DYLD_ROOT_PATH=''
DYLD_ROOT_PATH=$(find_runtime_root "${IMAGE_MOUNT_POINT}")

if [[ -z "${DYLD_ROOT_PATH}" ]]; then
echo ERROR: RuntimeRoot not found: "${IMAGE_MOUNT_POINT}"
exit 1
fi

export DYLD_ROOT_PATH
cd "${REPO_ROOT}"/aws-lc-rs
cargo test --features bindgen,unstable --target aarch64-apple-ios-sim

0 comments on commit e340f53

Please sign in to comment.