2 # Common definitions for test directories
5 XCRUN := /usr/bin/xcrun
6 SDKROOT ?= macosx.internal
8 # SDKROOT may be passed as a shorthand like "iphoneos.internal". We
9 # must resolve these to a full path and override SDKROOT.
11 SDKROOT_RESOLVED := $(shell xcrun -sdk $(SDKROOT) -show-sdk-path)
12 ifeq ($(strip $(SDKROOT)_$(SDKROOT_RESOLVED)),/_)
15 override SDKROOT = $(SDKROOT_RESOLVED)
17 SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version)
19 PLATFORMPATH := $(shell xcrun -sdk $(SDKROOT) -show-sdk-platform-path)
20 PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
22 ifeq ($(PLATFORM),watchOS)
26 SUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS BridgeOS
27 Embedded = $(if $(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),YES,NO)
30 # Deployment target flag
32 ifeq ($(PLATFORM),MacOSX)
33 DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION)
34 else ifeq ($(PLATFORM),WatchOS)
35 DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION)
36 else ifeq ($(PLATFORM),tvOS)
37 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
38 else ifeq ($(PLATFORM),AppleTVOS)
39 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
40 else ifeq ($(PLATFORM),BridgeOS)
41 DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION)
42 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
43 DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION)
44 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
45 DEPLOYMENT_TARGET_FLAGS =
47 DEPLOYMENT_TARGET_FLAGS =
50 DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM)
54 else ifeq ($(VERBOSE),YES)
60 # These are convenience functions for filtering based on substrings, as the
61 # normal filter functions only accept one wildcard.
62 FILTER_OUT_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),,$(string))))
63 FILTER_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),$(string),)))
65 #arch configs if not provided
67 ARCH_CONFIGS:=$(RC_ARCHS)
70 ifeq ($(ARCH_CONFIGS),)
71 PLATFORM_LOWERCASE:=$(shell echo "$(PLATFORM)" | tr A-Z a-z)
72 ARCH_CONFIGS:=$(shell /usr/bin/plutil -extract SupportedTargets.$(PLATFORM_LOWERCASE).Archs json -o - $(SDKROOT)/SDKSettings.plist | tr '",[]' ' ')
76 ARCH_CONFIGS_32:=$(call FILTER_OUT_SUBSTRING,64,$(ARCH_CONFIGS))
77 ARCH_CONFIGS_64:=$(call FILTER_SUBSTRING,64,$(ARCH_CONFIGS))
78 ARCH_CONFIGS_x86:=$(call FILTER_SUBSTRING,x86_64,$(ARCH_CONFIGS))
80 ARCH_FLAGS:=$(foreach argarch,$(ARCH_CONFIGS), -arch $(argarch) )
81 ARCH_FLAGS_32:=$(foreach argarch,$(ARCH_CONFIGS_32), -arch $(argarch) )
82 ARCH_FLAGS_64:=$(foreach argarch,$(ARCH_CONFIGS_64), -arch $(argarch) )
83 ARCH_FLAGS_x86:=$(foreach argarch,$(ARCH_CONFIGS_x86), -arch $(argarch) )