]>
Commit | Line | Data |
---|---|---|
f427ee49 A |
1 | PROJECT := xnu/darwintests |
2 | ||
3 | ifdef BASEDSTROOT | |
4 | override DSTROOT = $(BASEDSTROOT) | |
5 | endif | |
6 | INVALID_ARCHS = i386 | |
7 | ENABLE_LTE_TESTS=YES | |
8 | ||
9 | OTHER_LTE_INCLUDE_FILES += \ | |
10 | /System/Library/PrivateFrameworks/LoggingSupport.framework, \ | |
11 | /System/Library/PrivateFrameworks/MobileKeyBag.framework, \ | |
12 | /System/Library/Frameworks/IOSurface.framework, \ | |
13 | /usr/local/lib/libdarwintest_utils.dylib, \ | |
14 | /usr/lib/libapple_crypto.dylib, | |
15 | ||
16 | DEVELOPER_DIR ?= $(shell xcode-select -p) | |
17 | ||
18 | # the xnu build system will only ever call us with the default target | |
19 | .DEFAULT_GOAL := install | |
20 | ||
21 | SDKROOT ?= driverkit.internal | |
22 | ||
23 | include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common | |
24 | ||
25 | DRIVERKIT_DIR := $(TARGETSDK)/System/DriverKit | |
26 | DRIVERKIT_TARGET := x86_64-apple-driverkit$(shell xcrun --sdk driverkit.internal --show-sdk-version) | |
27 | ||
28 | IIG := $(shell xcrun --sdk "$(SDKROOT)" -f iig) | |
29 | ||
30 | # Enumerate all directories in this folder, excluding the "build" directory | |
31 | DEXT_SRCS = $(filter-out build,$(shell find . -type d -depth 1 | sed -e "s:./::g")) | |
32 | ||
33 | # hack: reuse the default CXXFLAGS and LDFLAGS but remove -mmacosx-version-min and -arch. Also adds a few other required flags | |
34 | # These are used for both iig and clang | |
35 | DEXT_SHARED_CXXFLAGS := $(filter-out -mmacosx-version-min=%, $(shell echo $(CXXFLAGS) $(OTHER_CXXFLAGS) | sed -e "s/-arch [a-zA-Z0-9_]*//g")) -isystem$(DRIVERKIT_DIR)/usr/include -iframework$(DRIVERKIT_DIR)/System/Library/Frameworks -std=gnu++14 | |
36 | ||
37 | # These are used just for clang | |
38 | DEXT_CXXFLAGS := $(DEXT_SHARED_CXXFLAGS) -target $(DRIVERKIT_TARGET) | |
39 | ||
40 | # These are used just for iig | |
41 | IIGFLAGS := -- $(DEXT_SHARED_CXXFLAGS) -D__IIG=1 -x c++ | |
42 | ||
43 | # Used just for clang. LDFLAGS are not needed for iig | |
44 | DEXT_LDFLAGS := $(filter-out -mmacosx-version-min=%, $(shell echo $(LDFLAGS) $(OTHER_LDFLAGS) | sed -e "s/-arch [a-zA-Z0-9_]*//g")) -target $(DRIVERKIT_TARGET) -L$(DRIVERKIT_DIR)/usr/lib -F$(DRIVERKIT_DIR)/System/Library/Frameworks -framework DriverKit | |
45 | ||
46 | ||
47 | # This generates rules to create dexts from each directory specified in DEXT_SRCS | |
48 | define GENERATE_DEXT_RULE | |
49 | ## Given the following directory structure: | |
50 | ## test_driver_123/ | |
51 | ## Info.plist | |
52 | ## test_driver_123.entitlements | |
53 | ## [cpp and iig files] | |
54 | ## This produces a dext called com.apple.test_driver_123.dext: | |
55 | ## com.apple.test_driver_123.dext/ | |
56 | ## com.apple.test_driver_123 [dext executable] | |
57 | ## Info.plist | |
58 | ## _CodeSignature/ | |
59 | ||
60 | CUSTOM_TARGETS += com.apple.$1.dext | |
61 | ||
62 | com.apple.$1.dext : $(patsubst $1/%.cpp,$(OBJROOT)/$1/%.o,$(wildcard $1/*.cpp)) $(patsubst $1/%.iig,$(OBJROOT)/$1/DerivedSources/%.iig.o,$(wildcard $1/*.iig)) | |
63 | # Create bundle directory | |
64 | mkdir -p $(SYMROOT)/$$@ | |
65 | # Link object files | |
66 | $(CXX) $(DEXT_LDFLAGS) $$^ -o $(SYMROOT)/$$@/com.apple.$1 | |
67 | # Copy Info.plist and sign | |
68 | cp $1/Info.plist $(SYMROOT)/$$@ | |
69 | codesign -vvv --force --sign - --entitlements $1/$1.entitlements --timestamp=none $(SYMROOT)/$$@ | |
70 | ||
71 | install-com.apple.$1.dext: com.apple.$1.dext | |
72 | mkdir -p $(INSTALLDIR) | |
73 | cp -R $(SYMROOT)/com.apple.$1.dext $(INSTALLDIR) | |
74 | ||
75 | $(OBJROOT)/$1/DerivedSources/%.iig.o: $(OBJROOT)/$1/DerivedSources/%.iig.cpp | |
76 | mkdir -p $(OBJROOT)/$1/DerivedSources | |
77 | # Compile *.iig.cpp to object file | |
78 | $(CXX) $(DEXT_CXXFLAGS) -I$1/ -I$(OBJROOT)/$1/DerivedSources -c $$^ -o $$@ | |
79 | ||
80 | $(OBJROOT)/$1/DerivedSources/%.iig.cpp: $1/%.iig | |
81 | mkdir -p $(OBJROOT)/$1/DerivedSources | |
82 | # Generate *.iig.cpp and *.h header files from *.iig | |
83 | $(IIG) --def $$^ --impl $$@ --header $$(patsubst %.iig.cpp,%.h,$$@) $(IIGFLAGS) | |
84 | ||
85 | # Tell make not to delete the intermediate *.iig.cpp file since it is useful for debugging | |
86 | .PRECIOUS :: $(OBJROOT)/$1/DerivedSources/%.iig.cpp | |
87 | ||
88 | $(OBJROOT)/$1/%.o: $1/%.cpp $(patsubst $1/%.iig,$(OBJROOT)/$1/DerivedSources/%.iig.o,$(wildcard $1/*.iig)) | |
89 | # Compile c++ file. The additional dependency is for headers emitted by iig | |
90 | $(CXX) $(DEXT_CXXFLAGS) -I$1/ -I$(OBJROOT)/$1/DerivedSources -c $$< -o $$@ | |
91 | endef | |
92 | ||
93 | ||
94 | ifeq ($(PLATFORM),MacOSX) | |
95 | $(foreach DEXTSRCDIR,$(DEXT_SRCS),$(eval $(call GENERATE_DEXT_RULE,$(DEXTSRCDIR)))) | |
96 | else | |
97 | EXCLUDED_SOURCES += $(DEXT_SRCS) | |
98 | endif | |
99 | ||
100 | include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets |