@@ -158,7 +158,8 @@ def generate_gyb_files(verbose, add_source_locations, destination=None):
158
158
def get_installed_dylib_name ():
159
159
return 'libSwiftSyntax.dylib'
160
160
161
- def get_swiftpm_invocation (toolchain , action , build_dir , release ):
161
+ def get_swiftpm_invocation (toolchain , action , build_dir , multiroot_data_file ,
162
+ release ):
162
163
swift_exec = os .path .join (toolchain , 'usr' , 'bin' , 'swift' )
163
164
164
165
swiftpm_call = [swift_exec , action ]
@@ -167,15 +168,18 @@ def get_swiftpm_invocation(toolchain, action, build_dir, release):
167
168
swiftpm_call .extend (['--configuration' , 'release' ])
168
169
if build_dir :
169
170
swiftpm_call .extend (['--build-path' , build_dir ])
171
+ if multiroot_data_file :
172
+ swiftpm_call .extend (['--multiroot-data-file' , multiroot_data_file ])
170
173
171
174
return swiftpm_call
172
175
173
176
class Builder (object ):
174
- def __init__ (self , toolchain , build_dir , release , verbose ,
175
- disable_sandbox = False ):
177
+ def __init__ (self , toolchain , build_dir , multiroot_data_file , release ,
178
+ verbose , disable_sandbox = False ):
176
179
self .swiftpm_call = get_swiftpm_invocation (toolchain = toolchain ,
177
180
action = 'build' ,
178
181
build_dir = build_dir ,
182
+ multiroot_data_file = multiroot_data_file ,
179
183
release = release )
180
184
if disable_sandbox :
181
185
self .swiftpm_call .append ('--disable-sandbox' )
@@ -189,7 +193,9 @@ def build(self, product_name, module_group_path=''):
189
193
command .extend (['--product' , product_name ])
190
194
191
195
env = dict (os .environ )
192
- env ['SWIFT_SYNTAX_CI_ENVIRONMENT' ] = '1'
196
+ env ['SWIFT_BUILD_SCRIPT_ENVIRONMENT' ] = '1'
197
+ # Tell other projects in the unified build to use local dependencies
198
+ env ['SWIFTCI_USE_LOCAL_DEPS' ] = '1'
193
199
check_call (command , env = env , verbose = self .verbose )
194
200
195
201
@@ -212,7 +218,8 @@ def verify_generated_files(verbose):
212
218
check_call (command )
213
219
214
220
215
- def run_tests (toolchain , build_dir , release , filecheck_exec , verbose ):
221
+ def run_tests (toolchain , build_dir , multiroot_data_file , release ,
222
+ filecheck_exec , verbose ):
216
223
print ('** Running SwiftSyntax Tests **' )
217
224
218
225
lit_success = run_lit_tests (toolchain = toolchain ,
@@ -225,6 +232,7 @@ def run_tests(toolchain, build_dir, release, filecheck_exec, verbose):
225
232
226
233
xctest_success = run_xctests (toolchain = toolchain ,
227
234
build_dir = build_dir ,
235
+ multiroot_data_file = multiroot_data_file ,
228
236
release = release ,
229
237
verbose = verbose )
230
238
if not xctest_success :
@@ -259,6 +267,7 @@ def find_lit_test_helper_exec(toolchain, build_dir, release):
259
267
swiftpm_call = get_swiftpm_invocation (toolchain = toolchain ,
260
268
action = 'build' ,
261
269
build_dir = build_dir ,
270
+ multiroot_data_file = None ,
262
271
release = release )
263
272
swiftpm_call .extend (['--product' , 'lit-test-helper' ])
264
273
swiftpm_call .extend (['--show-bin-path' ])
@@ -298,18 +307,23 @@ def run_lit_tests(toolchain, build_dir, release, filecheck_exec, verbose):
298
307
299
308
## XCTest based tests
300
309
301
- def run_xctests (toolchain , build_dir , release , verbose ):
310
+ def run_xctests (toolchain , build_dir , multiroot_data_file , release , verbose ):
302
311
print ('** Running XCTests **' )
303
312
swiftpm_call = get_swiftpm_invocation (toolchain = toolchain ,
304
313
action = 'test' ,
305
314
build_dir = build_dir ,
315
+ multiroot_data_file = multiroot_data_file ,
306
316
release = release )
307
317
308
318
if verbose :
309
319
swiftpm_call .extend (['--verbose' ])
310
320
321
+ swiftpm_call .extend (['--test-product' , 'SwiftSyntaxPackageTests' ])
322
+
311
323
env = dict (os .environ )
312
- env ['SWIFT_SYNTAX_CI_ENVIRONMENT' ] = '1'
324
+ env ['SWIFT_BUILD_SCRIPT_ENVIRONMENT' ] = '1'
325
+ # Tell other projects in the unified build to use local dependencies
326
+ env ['SWIFTCI_USE_LOCAL_DEPS' ] = '1'
313
327
return call (swiftpm_call , env = env , verbose = verbose ) == 0
314
328
315
329
def delete_rpath (rpath , binary ):
@@ -433,6 +447,11 @@ def main():
433
447
help = 'The script only generates swift files from gyb '
434
448
'and skips the rest of the build' )
435
449
450
+ build_group .add_argument ('--multiroot-data-file' ,
451
+ help = 'Path to an Xcode workspace to create a '
452
+ 'unified build of SwiftSyntax with other '
453
+ 'projects.' )
454
+
436
455
testing_group = parser .add_argument_group ('Testing' )
437
456
testing_group .add_argument ('-t' , '--test' , action = 'store_true' ,
438
457
help = 'Run tests' )
@@ -494,6 +513,7 @@ def main():
494
513
try :
495
514
builder = Builder (toolchain = args .toolchain ,
496
515
build_dir = args .build_dir ,
516
+ multiroot_data_file = args .multiroot_data_file ,
497
517
release = args .release ,
498
518
verbose = args .verbose ,
499
519
disable_sandbox = args .disable_sandbox )
@@ -512,6 +532,7 @@ def main():
512
532
try :
513
533
success = run_tests (toolchain = args .toolchain ,
514
534
build_dir = realpath (args .build_dir ),
535
+ multiroot_data_file = args .multiroot_data_file ,
515
536
release = args .release ,
516
537
filecheck_exec = realpath (args .filecheck_exec ),
517
538
verbose = args .verbose )
0 commit comments