|
| 1 | +CONFIG = Debug |
| 2 | + |
| 3 | +DERIVED_DATA_PATH = ~/.derivedData/$(CONFIG) |
| 4 | + |
| 5 | +PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M]) |
| 6 | +PLATFORM_MACOS = macOS |
| 7 | +PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst |
| 8 | +PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS,TV) |
| 9 | +PLATFORM_VISIONOS = visionOS Simulator,id=$(call udid_for,visionOS,Vision) |
| 10 | +PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS,Watch) |
| 11 | + |
| 12 | +PLATFORM = IOS |
| 13 | +DESTINATION = platform="$(PLATFORM_$(PLATFORM))" |
| 14 | + |
| 15 | +PLATFORM_ID = $(shell echo "$(DESTINATION)" | sed -E "s/.+,id=(.+)/\1/") |
| 16 | + |
| 17 | +WORKSPACE = Package.xcworkspace |
| 18 | +SCHEME = swift-existential-container |
| 19 | + |
| 20 | +XCODEBUILD_ARGUMENT = test |
| 21 | + |
| 22 | +XCODEBUILD_FLAGS = \ |
| 23 | + -configuration $(CONFIG) \ |
| 24 | + -derivedDataPath $(DERIVED_DATA_PATH) \ |
| 25 | + -destination $(DESTINATION) \ |
| 26 | + -scheme "$(SCHEME)" \ |
| 27 | + -skipMacroValidation \ |
| 28 | + -workspace $(WORKSPACE) |
| 29 | + |
| 30 | +XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS) |
| 31 | + |
| 32 | +ifneq ($(strip $(shell which xcbeautify)),) |
| 33 | + XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify --quiet |
| 34 | +else |
| 35 | + XCODEBUILD = $(XCODEBUILD_COMMAND) |
| 36 | +endif |
| 37 | + |
| 38 | +TEST_RUNNER_CI = $(CI) |
| 39 | + |
| 40 | +warm-simulator: |
| 41 | + @test "$(PLATFORM_ID)" != "" \ |
| 42 | + && xcrun simctl boot $(PLATFORM_ID) \ |
| 43 | + && open -a Simulator --args -CurrentDeviceUDID $(PLATFORM_ID) \ |
| 44 | + || exit 0 |
| 45 | + |
| 46 | +xcodebuild: warm-simulator |
| 47 | + $(XCODEBUILD) |
| 48 | + |
| 49 | +# Workaround for debugging Swift Testing tests: https://github.com/cpisciotta/xcbeautify/issues/313 |
| 50 | +xcodebuild-raw: warm-simulator |
| 51 | + $(XCODEBUILD_COMMAND) |
| 52 | + |
| 53 | +build-for-library-evolution: |
| 54 | + swift build \ |
| 55 | + -q \ |
| 56 | + -c release \ |
| 57 | + --target "$(SCHEME)" \ |
| 58 | + -Xswiftc -emit-module-interface \ |
| 59 | + -Xswiftc -enable-library-evolution |
| 60 | + |
| 61 | +.PHONY: build-for-library-evolution format warm-simulator xcodebuild xcodebuild-raw |
| 62 | + |
| 63 | +define udid_for |
| 64 | +$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }') |
| 65 | +endef |
0 commit comments