-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (54 loc) · 2.65 KB
/
Makefile
File metadata and controls
64 lines (54 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
PLATFORM_MATRIX ?= \
"iOS,iOS Simulator,iPhone" \
"watchOS,watchOS Simulator,Watch" \
"xrOS,visionOS Simulator,Apple Vision Pro"
.PHONY: test test-package-platform build-examples build-example-ios build-example-vision build-example-macos build-example-watch
EXAMPLE_PROJECT ?= Example/Example.xcodeproj
IOS_SIM_DEST ?= generic/platform=iOS Simulator
VISIONOS_SIM_DEST ?= generic/platform=visionOS Simulator
MACOS_DEST ?= platform=macOS
WATCHOS_SIM_DEST ?= generic/platform=watchOS Simulator
build-examples: build-example-ios build-example-vision build-example-macos build-example-watch
build-example-ios:
@set -e; \
echo "==> Building VRMExample (iOS Simulator)"; \
xcodebuild -project "$(EXAMPLE_PROJECT)" -scheme VRMExample -destination "$(IOS_SIM_DEST)" build
build-example-vision:
@set -e; \
echo "==> Building VisionExample (visionOS Simulator)"; \
xcodebuild -project "$(EXAMPLE_PROJECT)" -scheme VisionExample -destination "$(VISIONOS_SIM_DEST)" build
build-example-macos:
@set -e; \
echo "==> Building MacExample (macOS)"; \
xcodebuild -project "$(EXAMPLE_PROJECT)" -scheme MacExample -destination "$(MACOS_DEST)" build
build-example-watch:
@set -e; \
echo "==> Building WatchExample (watchOS Simulator)"; \
xcodebuild -project "$(EXAMPLE_PROJECT)" -scheme "WatchExample Watch App" -destination "$(WATCHOS_SIM_DEST)" build
test:
@set -e; \
for entry in $(PLATFORM_MATRIX); do \
old_ifs="$$IFS"; IFS=,; set -- $$entry; IFS="$$old_ifs"; \
platform="$$1"; sim="$$2"; device="$$3"; \
echo "==> Testing $${platform} ($${device})"; \
$(MAKE) test-package-platform \
SIM_PLATFORM="$$sim" \
RUNTIME_PLATFORM="$$platform" \
DEVICE_NAME="$$device" || exit 1; \
done
test-package-platform:
@if [ -n "$(SIM_PLATFORM)" ] && [ -n "$(RUNTIME_PLATFORM)" ] && [ -n "$(DEVICE_NAME)" ]; then \
dest_id="$(call udid_for_latest,$(DEVICE_NAME),$(RUNTIME_PLATFORM))"; \
if [ -z "$$dest_id" ]; then \
echo "No simulator found for $(DEVICE_NAME) on $(RUNTIME_PLATFORM)" >&2; \
exit 1; \
fi; \
dest="platform=$(SIM_PLATFORM),id=$$dest_id"; \
xcodebuild test -scheme VRMKit-Package -destination "$$dest"; \
else \
echo "SIM_PLATFORM/RUNTIME_PLATFORM/DEVICE_NAME is required" >&2; \
exit 1; \
fi
define udid_for_latest
$(shell xcrun simctl list --json devices available | jq -r --arg name "$(1)" --arg platform "$(2)" 'def ver(k): (k | capture("SimRuntime\\." + $$platform + "-(?<major>\\d+)-(?<minor>\\d+)")) as $$m | [$$m.major|tonumber, $$m.minor|tonumber]; .devices | to_entries | map(select(.key | test("SimRuntime\\." + $$platform + "-\\d+-\\d+"))) | sort_by(ver(.key)) | last | .value | map(select(.name | contains($$name))) | last | .udid // empty')
endef