Skip to content

Commit

Permalink
Improvements to Makefile for running simulator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedrick committed Jan 11, 2024
1 parent 48e1d20 commit bd8bdcb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[target.aarch64-apple-ios-sim]
runner = "cargo dinghy -p auto-ios-aarch64-sim runner"

[target.aarch64-apple-ios]
runner = "cargo dinghy -p auto-ios-aarch64 runner"

[target.x86_64-apple-ios]
runner = "cargo dinghy -p auto-ios-x86_64 runner"
29 changes: 18 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
.PHONEY: test

#RUNTIME_ID=$(shell xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1)
DEVICE_ID?=$(shell xcrun simctl list devices 'iOS' --json | jq '.devices | with_entries( select(.key|contains("iOS"))) | .[] | [ .[].name ] | map( select(contains("iPhone")) ) | sort | .[0] ' | jq -r)
BOOTED_SIM=$(shell xcrun simctl list devices --json | jq -r '.devices | to_entries | map(select( .key | contains("iOS") )) | sort_by(.key) | reverse | .[0].value | map(select( (.name|contains("${DEVICE_ID}")) and .state == "Booted" ) ) | sort_by(.name) | .[0].name')

DEVICE_ID=$(shell xcrun simctl list devices 'iOS' --json | jq '.devices | with_entries( select(.key|contains("iOS"))) | .[] | [ .[].name ] | map( select(contains("iPhone")) ) | sort | .[0] ' | jq -r)

TARGET=aarch64-apple-ios
TARGET?=aarch64-apple-ios-sim

build:
cargo build --target $(TARGET)
@echo TARGET: ${TARGET}
cargo build --target ${TARGET}

run-example:
cargo run --example accelerometer

build-macos:
cargo build --target aarch64-apple-darwin

boot-sim:
@echo DEVICE ID: $(DEVICE_ID)
xcrun simctl list devices
xcrun simctl list devices booted | grep iPhone || xcrun simctl boot "$(DEVICE_ID)"
@echo DEVICE ID: ${DEVICE_ID}, BOOTED: ${BOOTED_SIM}
ifeq ($(BOOTED_SIM),null)
@echo BOOTING SIM: ${DEVICE_ID}
xcrun simctl boot "${DEVICE_ID}"
endif

test: boot-sim
cargo dinghy --platform auto-ios-x86_64 test
test-sim: boot-sim
@echo DEVICE ID: ${DEVICE_ID}
cargo dinghy --platform auto-ios-aarch64-sim --device "${DEVICE_ID}" test
xcrun simctl shutdown "${DEVICE_ID}"

bundle:
cargo bundle --format ios --target $(TARGET) --release
cargo bundle --format ios --target ${TARGET} --release

.EXPORT_ALL_VARIABLES:
LLVM_CONFIG_PATH=$(shell brew --prefix llvm)/bin/llvm-config

0 comments on commit bd8bdcb

Please sign in to comment.