1
+ RUNNER_ARGS ?=
2
+
1
3
IOS_HOST = iphone
2
4
IOS_ARCH = arm64
3
5
IOS_PREFIX = /usr/local/opt/frida-objc-tests-$(IOS_ARCH )
4
6
5
7
frida_version := 12.3.3
6
8
7
9
cflags := -Wall -pipe -Os -g
8
- ldflags := -Wl,-framework,Foundation -lfrida-gumjs -lresolv -Wl,-dead_strip
10
+ ldflags := -Wl,-framework,Foundation -lfrida-gumjs -lresolv -Wl,-dead_strip
11
+ toolchain := $(shell dirname $(shell dirname $(shell dirname $(shell xcrun --toolchain XcodeDefault -f swift) ) ) )
9
12
10
13
macos_cc := $(shell xcrun --sdk macosx -f clang)
11
- macos_sysroot := $(shell xcrun --sdk macosx --show-sdk-path)
12
- macos_cflags := -isysroot "$(macos_sysroot ) " -arch x86_64 -mmacosx-version-min=10.9 $(cflags ) -DHAVE_MACOS
13
- macos_ldflags := $(ldflags )
14
+ macos_swift := $(shell xcrun --sdk macosx -f swift)
15
+ macos_sdk := $(shell xcrun --sdk macosx --show-sdk-path)
16
+ macos_cflags := -isysroot "$(macos_sdk ) " -arch x86_64 $(cflags ) -DHAVE_MACOS
17
+ macos_runtimedir := $(toolchain ) /usr/lib/swift/macosx
18
+ macos_ldflags := "-L$(macos_runtimedir ) " -lswiftObjectiveC "-Wl,-rpath,$(macos_runtimedir ) " $(ldflags )
14
19
15
20
ios_cc := $(shell xcrun --sdk iphoneos -f clang)
16
- ios_sysroot := $(shell xcrun --sdk iphoneos --show-sdk-path)
17
- ios_cflags := -isysroot "$(ios_sysroot ) " -arch $(IOS_ARCH ) -miphoneos-version-min=7.0 $(cflags ) -DHAVE_IOS
18
- ios_ldflags := $(ldflags )
21
+ ios_swift := $(shell xcrun --sdk iphoneos -f swift)
22
+ ios_sdk := $(shell xcrun --sdk iphoneos --show-sdk-path)
23
+ ios_cflags := -isysroot "$(ios_sdk ) " -arch $(IOS_ARCH ) -miphoneos-version-min=7.0 $(cflags ) -DHAVE_IOS
24
+ ios_runtimedir := $(toolchain ) /usr/lib/swift/iphoneos
25
+ ios_ldflags := "-L$(ios_runtimedir ) " -lswiftObjectiveC "-Wl,-rpath,$(IOS_PREFIX ) " $(ldflags )
19
26
ios_codesign := $(shell xcrun --sdk iphoneos -f codesign)
20
-
21
- sources := runner.m basics.m
22
- headers := fixture.m
27
+ ios_swift_libraries := \
28
+ $(ios_runtimedir ) /libswiftCore.dylib \
29
+ $(ios_runtimedir ) /libswiftCoreFoundation.dylib \
30
+ $(ios_runtimedir ) /libswiftCoreGraphics.dylib \
31
+ $(ios_runtimedir ) /libswiftDarwin.dylib \
32
+ $(ios_runtimedir ) /libswiftDispatch.dylib \
33
+ $(ios_runtimedir ) /libswiftFoundation.dylib \
34
+ $(ios_runtimedir ) /libswiftObjectiveC.dylib \
35
+ $(ios_runtimedir ) /libswiftSwiftOnoneSupport.dylib \
36
+ $(NULL )
37
+
38
+ objc_sources := runner.m basics.m
39
+ objc_headers := fixture.m
40
+ swift_sources := taylor.swift
23
41
24
42
js_sources := ../index.js
25
43
@@ -32,38 +50,77 @@ build-macos: build/macos-x86_64/runner
32
50
build-ios : build/ios-$(IOS_ARCH ) /runner
33
51
34
52
run-macos : build/macos-x86_64/runner build/frida-objc.js
35
- $<
36
- run-ios : build/ios-$(IOS_ARCH ) /runner build/frida-objc.js
37
- ssh $(IOS_HOST ) " rm -rf $( IOS_PREFIX) ; mkdir -p $( IOS_PREFIX) "
38
- scp $^ " $( IOS_HOST) :$( IOS_PREFIX) /"
39
- ssh $(IOS_HOST ) " $( IOS_PREFIX) /runner"
53
+ $< $(RUNNER_ARGS )
54
+ run-ios : build/ios-$(IOS_ARCH ) /runner build/frida-objc.js build/ios-$(IOS_ARCH ) /.swift-runtime-stamp
55
+ cd build/ios-$(IOS_ARCH ) / && rsync -rLz runner ../frida-objc.js * .dylib " $( IOS_HOST) :$( IOS_PREFIX) /"
56
+ ssh $(IOS_HOST ) " $( IOS_PREFIX) /runner $( RUNNER_ARGS) "
40
57
41
58
watch-macos : build/macos-x86_64/runner build/frida-objc.js
42
59
npm run watch &
43
60
./node_modules/.bin/chokidar \
44
61
build/frida-objc.js \
45
- -c ' build/macos-x86_64/runner'
62
+ -c ' build/macos-x86_64/runner $(RUNNER_ARGS) '
46
63
watch-ios : build/ios-$(IOS_ARCH ) /runner build/frida-objc.js
47
64
npm run watch &
48
65
./node_modules/.bin/chokidar \
49
66
build/frida-objc.js \
50
67
-c ' scp build/frida-objc.js "$(IOS_HOST):$(IOS_PREFIX)/" \
51
- && ssh $(IOS_HOST ) " $( IOS_PREFIX) /runner" '
68
+ && ssh $(IOS_HOST ) " $( IOS_PREFIX) /runner $( RUNNER_ARGS ) " '
52
69
53
- build/macos-x86_64/runner : $(sources ) $(headers ) build/macos-x86_64/libfrida-gumjs.a
54
- " $( macos_cc) " $(macos_cflags ) \
55
- $(sources ) \
70
+ build/macos-x86_64/runner : $(objc_sources ) $(objc_headers ) build/macos-x86_64/taylor.o build/macos-x86_64/libfrida-gumjs.a
71
+ " $( macos_cc) " \
72
+ $(macos_cflags ) \
73
+ $(objc_sources ) \
74
+ build/macos-x86_64/taylor.o \
56
75
-o $@ \
57
76
-Ibuild/macos-x86_64 -Lbuild/macos-x86_64 \
58
77
$(macos_ldflags )
59
- build/ios-$(IOS_ARCH ) /runner : $(sources ) $(headers ) runner.xcent build/ios-$(IOS_ARCH ) /libfrida-gumjs.a
60
- " $( ios_cc) " $(ios_cflags ) \
61
- $(sources ) \
78
+ build/ios-$(IOS_ARCH ) /runner : $(objc_sources ) $(objc_headers ) build/ios-$(IOS_ARCH ) /taylor.o runner.xcent build/ios-$(IOS_ARCH ) /libfrida-gumjs.a
79
+ " $( ios_cc) " \
80
+ $(ios_cflags ) \
81
+ $(objc_sources ) \
82
+ build/ios-$(IOS_ARCH ) /taylor.o \
62
83
-o $@ \
63
84
-Ibuild/ios-$(IOS_ARCH ) -Lbuild/ios-$(IOS_ARCH ) \
64
85
$(ios_ldflags )
65
86
" $( ios_codesign) " -f -s " $$ IOS_CERTID" --entitlements runner.xcent $@
66
87
88
+ build/macos-x86_64/taylor.o : taylor.swift
89
+ @mkdir -p $(@D )
90
+ " $( macos_swift) " \
91
+ -frontend \
92
+ -c \
93
+ -primary-file taylor.swift \
94
+ -sdk " $( macos_sdk) " \
95
+ -module-name FridaObjCTests \
96
+ -emit-module-path build/macos-x86_64/FridaObjCTests.swiftmodule \
97
+ -emit-objc-header-path build/macos-x86_64/taylor.h \
98
+ -enable-testing \
99
+ -enable-objc-interop \
100
+ -parse-as-library \
101
+ -o $@
102
+ build/ios-$(IOS_ARCH ) /taylor.o : taylor.swift
103
+ @mkdir -p $(@D )
104
+ " $( ios_swift) " \
105
+ -frontend \
106
+ -c \
107
+ -primary-file taylor.swift \
108
+ -target $(IOS_ARCH ) -apple-ios7.0-iphoneos \
109
+ -sdk " $( ios_sdk) " \
110
+ -module-name FridaObjCTests \
111
+ -emit-module-path build/ios-$(IOS_ARCH ) /FridaObjCTests.swiftmodule \
112
+ -emit-objc-header-path build/ios-$(IOS_ARCH ) /taylor.h \
113
+ -enable-testing \
114
+ -enable-objc-interop \
115
+ -parse-as-library \
116
+ -o $@
117
+
118
+ build/ios-$(IOS_ARCH ) /.swift-runtime-stamp : $(ios_swift_libraries )
119
+ @mkdir -p $(@D )
120
+ cp $^ $(@D )
121
+ " $( ios_codesign) " -f -s " $$ IOS_CERTID" $(@D ) /* .dylib
122
+ @touch $@
123
+
67
124
build/% /libfrida-gumjs.a :
68
125
@mkdir -p $(@D )
69
126
curl -Ls https://github.com/frida/frida/releases/download/$(frida_version ) /frida-gumjs-devkit-$(frida_version ) -$* .tar.xz | tar -xJf - -C $(@D )
0 commit comments