@@ -86,13 +86,14 @@ def test(self, sandbox_profile, stdout=sys.stdout, stderr=sys.stderr,
86
86
class XcodeTarget (ProjectTarget ):
87
87
"""An Xcode workspace scheme."""
88
88
89
- def __init__ (self , swiftc , project , target , destination , env ,
89
+ def __init__ (self , swiftc , project , target , destination , pretargets , env ,
90
90
added_xcodebuild_flags , is_workspace , has_scheme ,
91
91
clean_build ):
92
92
self ._swiftc = swiftc
93
93
self ._project = project
94
94
self ._target = target
95
95
self ._destination = destination
96
+ self ._pretargets = pretargets
96
97
self ._env = env
97
98
self ._added_xcodebuild_flags = added_xcodebuild_flags
98
99
self ._is_workspace = is_workspace
@@ -124,7 +125,7 @@ def get_build_command(self, incremental=False):
124
125
build_dir = os .path .join (build_parent_dir , 'build' )
125
126
126
127
build = []
127
- if self ._clean_build and not incremental :
128
+ if self ._clean_build and not incremental and not self . _pretargets :
128
129
build += ['clean' ]
129
130
build += ['build' ]
130
131
@@ -154,6 +155,55 @@ def get_build_command(self, incremental=False):
154
155
155
156
return command
156
157
158
+ def get_prebuild_command (self , incremental = False ):
159
+ project_param = self .project_param
160
+ target_param = self .target_param
161
+ try :
162
+ build_parent_dir = common .check_execute_output ([
163
+ 'git' , '-C' , os .path .dirname (self ._project ),
164
+ 'rev-parse' , '--show-toplevel' ]).rstrip ()
165
+ except common .ExecuteCommandFailure as error :
166
+ build_parent_dir = os .path .dirname (self ._project )
167
+
168
+ build_dir = os .path .join (build_parent_dir , 'build' )
169
+
170
+ build = []
171
+ if self ._clean_build and not incremental :
172
+ build += ['clean' ]
173
+
174
+ if self ._pretargets :
175
+ build += ['build' ]
176
+
177
+ dir_override = []
178
+ if self ._has_scheme :
179
+ dir_override += ['-derivedDataPath' , build_dir ]
180
+ elif not 'SYMROOT' in self ._env :
181
+ dir_override += ['SYMROOT=' + build_dir ]
182
+ dir_override += [k + "=" + v for k , v in self ._env .items ()]
183
+
184
+ project_target_params = [project_param , self ._project ,
185
+ '-destination' , self ._destination ]
186
+ for pretarget in self ._pretargets :
187
+ project_target_params += [target_param , pretarget ]
188
+
189
+ command = (['xcodebuild' ]
190
+ + build
191
+ + project_target_params
192
+ + dir_override
193
+ + ['CODE_SIGN_IDENTITY=' ,
194
+ 'CODE_SIGNING_REQUIRED=NO' ,
195
+ 'ENTITLEMENTS_REQUIRED=NO' ,
196
+ 'ENABLE_BITCODE=NO' ,
197
+ 'INDEX_ENABLE_DATA_STORE=NO' ,
198
+ 'GCC_TREAT_WARNINGS_AS_ERRORS=NO' ,
199
+ 'SWIFT_TREAT_WARNINGS_AS_ERRORS=NO' ])
200
+ command += self ._added_xcodebuild_flags
201
+
202
+ if self ._destination == 'generic/platform=watchOS' :
203
+ command += ['ARCHS=armv7k' ]
204
+
205
+ return command
206
+
157
207
def get_test_command (self , incremental = False ):
158
208
project_param = self .project_param
159
209
target_param = self .target_param
@@ -180,6 +230,10 @@ def build(self, sandbox_profile, stdout=sys.stdout, stderr=sys.stderr,
180
230
incremental = False , time_reporter = None ):
181
231
"""Build the project target."""
182
232
233
+ if self ._pretargets :
234
+ common .check_execute (self .get_prebuild_command (incremental = incremental ),
235
+ sandbox_profile = sandbox_profile ,
236
+ stdout = stdout , stderr = stdout )
183
237
start_time = None
184
238
if time_reporter :
185
239
start_time = time .time ()
@@ -360,6 +414,10 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
360
414
if 'environment' in action :
361
415
build_env = action ['environment' ]
362
416
417
+ pretargets = []
418
+ if 'pretargets' in action :
419
+ pretargets = action ['pretargets' ]
420
+
363
421
other_swift_flags = []
364
422
if swift_version :
365
423
if '.' not in swift_version :
@@ -393,6 +451,7 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
393
451
project_path ,
394
452
action [match .group (3 ).lower ()],
395
453
action ['destination' ],
454
+ pretargets ,
396
455
build_env ,
397
456
initial_xcodebuild_flags + added_xcodebuild_flags ,
398
457
is_workspace ,
0 commit comments