@@ -158,7 +158,8 @@ def generate_gyb_files(verbose, add_source_locations, destination=None):
158158def get_installed_dylib_name ():
159159 return 'libSwiftSyntax.dylib'
160160
161- def get_swiftpm_invocation (toolchain , action , build_dir , release ):
161+ def get_swiftpm_invocation (toolchain , action , build_dir , multiroot_data_file ,
162+ release ):
162163 swift_exec = os .path .join (toolchain , 'usr' , 'bin' , 'swift' )
163164
164165 swiftpm_call = [swift_exec , action ]
@@ -167,15 +168,18 @@ def get_swiftpm_invocation(toolchain, action, build_dir, release):
167168 swiftpm_call .extend (['--configuration' , 'release' ])
168169 if build_dir :
169170 swiftpm_call .extend (['--build-path' , build_dir ])
171+ if multiroot_data_file :
172+ swiftpm_call .extend (['--multiroot-data-file' , multiroot_data_file ])
170173
171174 return swiftpm_call
172175
173176class 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 ):
176179 self .swiftpm_call = get_swiftpm_invocation (toolchain = toolchain ,
177180 action = 'build' ,
178181 build_dir = build_dir ,
182+ multiroot_data_file = multiroot_data_file ,
179183 release = release )
180184 if disable_sandbox :
181185 self .swiftpm_call .append ('--disable-sandbox' )
@@ -189,7 +193,9 @@ def build(self, product_name, module_group_path=''):
189193 command .extend (['--product' , product_name ])
190194
191195 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'
193199 check_call (command , env = env , verbose = self .verbose )
194200
195201
@@ -212,7 +218,8 @@ def verify_generated_files(verbose):
212218 check_call (command )
213219
214220
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 ):
216223 print ('** Running SwiftSyntax Tests **' )
217224
218225 lit_success = run_lit_tests (toolchain = toolchain ,
@@ -225,6 +232,7 @@ def run_tests(toolchain, build_dir, release, filecheck_exec, verbose):
225232
226233 xctest_success = run_xctests (toolchain = toolchain ,
227234 build_dir = build_dir ,
235+ multiroot_data_file = multiroot_data_file ,
228236 release = release ,
229237 verbose = verbose )
230238 if not xctest_success :
@@ -259,6 +267,7 @@ def find_lit_test_helper_exec(toolchain, build_dir, release):
259267 swiftpm_call = get_swiftpm_invocation (toolchain = toolchain ,
260268 action = 'build' ,
261269 build_dir = build_dir ,
270+ multiroot_data_file = None ,
262271 release = release )
263272 swiftpm_call .extend (['--product' , 'lit-test-helper' ])
264273 swiftpm_call .extend (['--show-bin-path' ])
@@ -298,18 +307,23 @@ def run_lit_tests(toolchain, build_dir, release, filecheck_exec, verbose):
298307
299308## XCTest based tests
300309
301- def run_xctests (toolchain , build_dir , release , verbose ):
310+ def run_xctests (toolchain , build_dir , multiroot_data_file , release , verbose ):
302311 print ('** Running XCTests **' )
303312 swiftpm_call = get_swiftpm_invocation (toolchain = toolchain ,
304313 action = 'test' ,
305314 build_dir = build_dir ,
315+ multiroot_data_file = multiroot_data_file ,
306316 release = release )
307317
308318 if verbose :
309319 swiftpm_call .extend (['--verbose' ])
310320
321+ swiftpm_call .extend (['--test-product' , 'SwiftSyntaxPackageTests' ])
322+
311323 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'
313327 return call (swiftpm_call , env = env , verbose = verbose ) == 0
314328
315329def delete_rpath (rpath , binary ):
@@ -433,6 +447,11 @@ def main():
433447 help = 'The script only generates swift files from gyb '
434448 'and skips the rest of the build' )
435449
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+
436455 testing_group = parser .add_argument_group ('Testing' )
437456 testing_group .add_argument ('-t' , '--test' , action = 'store_true' ,
438457 help = 'Run tests' )
@@ -494,6 +513,7 @@ def main():
494513 try :
495514 builder = Builder (toolchain = args .toolchain ,
496515 build_dir = args .build_dir ,
516+ multiroot_data_file = args .multiroot_data_file ,
497517 release = args .release ,
498518 verbose = args .verbose ,
499519 disable_sandbox = args .disable_sandbox )
@@ -512,6 +532,7 @@ def main():
512532 try :
513533 success = run_tests (toolchain = args .toolchain ,
514534 build_dir = realpath (args .build_dir ),
535+ multiroot_data_file = args .multiroot_data_file ,
515536 release = args .release ,
516537 filecheck_exec = realpath (args .filecheck_exec ),
517538 verbose = args .verbose )
0 commit comments