@@ -141,7 +141,8 @@ def get_installed_name():
141
141
def get_installed_dylib_name ():
142
142
return 'lib' + get_installed_name () + '.dylib'
143
143
144
- def get_swiftpm_invocation (spm_exec , build_dir , release ):
144
+ def get_swiftpm_invocation (spm_exec , build_dir , parser_header_dir ,
145
+ parser_lib_dir , release ):
145
146
if spm_exec == 'swift build' :
146
147
swiftpm_call = ['swift' , 'build' ]
147
148
elif spm_exec == 'swift test' :
@@ -158,17 +159,29 @@ def get_swiftpm_invocation(spm_exec, build_dir, release):
158
159
# Swift compiler needs to know the module link name.
159
160
swiftpm_call .extend (['-Xswiftc' , '-module-link-name' , '-Xswiftc' , get_installed_name ()])
160
161
162
+ # To find the syntax parser library.
163
+ if parser_header_dir :
164
+ swiftpm_call .extend (['-Xswiftc' , '-I' , '-Xswiftc' , parser_header_dir ])
165
+ if parser_lib_dir :
166
+ swiftpm_call .extend (['-Xswiftc' , '-L' , '-Xswiftc' , parser_lib_dir ])
167
+ if platform .system () == 'Darwin' :
168
+ swiftpm_call .extend (['-Xlinker' , '-rpath' , '-Xlinker' , parser_lib_dir ])
169
+
161
170
# To speed up compilation.
162
171
swiftpm_call .extend (['-Xswiftc' , '-enforce-exclusivity=unchecked' ])
163
172
return swiftpm_call
164
173
165
174
166
- def build_swiftsyntax (swift_build_exec , swiftc_exec , build_dir , build_test_util , release ,
175
+ def build_swiftsyntax (swift_build_exec , swiftc_exec , build_dir ,
176
+ parser_header_dir , parser_lib_dir ,
177
+ build_test_util , release ,
167
178
verbose , disable_sandbox = False ):
168
179
print ('** Building SwiftSyntax **' )
169
180
170
181
swiftpm_call = get_swiftpm_invocation (spm_exec = swift_build_exec ,
171
182
build_dir = build_dir ,
183
+ parser_header_dir = parser_header_dir ,
184
+ parser_lib_dir = parser_lib_dir ,
172
185
release = release )
173
186
swiftpm_call .extend (['--product' , 'SwiftSyntax' ])
174
187
@@ -189,8 +202,9 @@ def build_swiftsyntax(swift_build_exec, swiftc_exec, build_dir, build_test_util,
189
202
190
203
## Testing
191
204
192
- def run_tests (swift_test_exec , build_dir , release , swift_build_exec ,
193
- filecheck_exec , swiftc_exec , swift_syntax_test_exec , verbose ):
205
+ def run_tests (swift_test_exec , build_dir , parser_header_dir , parser_lib_dir ,
206
+ release , swift_build_exec , filecheck_exec , swiftc_exec ,
207
+ swift_syntax_test_exec , verbose ):
194
208
print ('** Running SwiftSyntax Tests **' )
195
209
196
210
optional_swiftc_exec = swiftc_exec
@@ -199,6 +213,8 @@ def run_tests(swift_test_exec, build_dir, release, swift_build_exec,
199
213
200
214
lit_success = run_lit_tests (swift_build_exec = swift_build_exec ,
201
215
build_dir = build_dir ,
216
+ parser_header_dir = parser_header_dir ,
217
+ parser_lib_dir = parser_lib_dir ,
202
218
release = release ,
203
219
swiftc_exec = optional_swiftc_exec ,
204
220
filecheck_exec = filecheck_exec ,
@@ -209,6 +225,8 @@ def run_tests(swift_test_exec, build_dir, release, swift_build_exec,
209
225
210
226
xctest_success = run_xctests (swift_test_exec = swift_test_exec ,
211
227
build_dir = build_dir ,
228
+ parser_header_dir = parser_header_dir ,
229
+ parser_lib_dir = parser_lib_dir ,
212
230
release = release ,
213
231
swiftc_exec = swiftc_exec ,
214
232
verbose = verbose )
@@ -240,9 +258,12 @@ def check_incr_transfer_roundtrip_exec():
240
258
''' )
241
259
242
260
243
- def find_lit_test_helper_exec (swift_build_exec , build_dir , release ):
261
+ def find_lit_test_helper_exec (swift_build_exec , parser_header_dir , parser_lib_dir ,
262
+ build_dir , release ):
244
263
swiftpm_call = get_swiftpm_invocation (spm_exec = swift_build_exec ,
245
264
build_dir = build_dir ,
265
+ parser_header_dir = parser_header_dir ,
266
+ parser_lib_dir = parser_lib_dir ,
246
267
release = release )
247
268
swiftpm_call .extend (['--product' , 'lit-test-helper' ])
248
269
swiftpm_call .extend (['--show-bin-path' ])
@@ -251,8 +272,9 @@ def find_lit_test_helper_exec(swift_build_exec, build_dir, release):
251
272
return bin_dir .strip () + '/lit-test-helper'
252
273
253
274
254
- def run_lit_tests (swift_build_exec , build_dir , release , swiftc_exec ,
255
- filecheck_exec , swift_syntax_test_exec , verbose ):
275
+ def run_lit_tests (swift_build_exec , build_dir , parser_header_dir , parser_lib_dir ,
276
+ release , swiftc_exec , filecheck_exec , swift_syntax_test_exec ,
277
+ verbose ):
256
278
print ('** Running lit-based tests **' )
257
279
258
280
check_lit_exec ()
@@ -261,6 +283,8 @@ def run_lit_tests(swift_build_exec, build_dir, release, swiftc_exec,
261
283
lit_test_helper_exec = \
262
284
find_lit_test_helper_exec (swift_build_exec = swift_build_exec ,
263
285
build_dir = build_dir ,
286
+ parser_header_dir = parser_header_dir ,
287
+ parser_lib_dir = parser_lib_dir ,
264
288
release = release )
265
289
266
290
lit_call = [LIT_EXEC ]
@@ -288,10 +312,13 @@ def run_lit_tests(swift_build_exec, build_dir, release, swiftc_exec,
288
312
289
313
## XCTest based tests
290
314
291
- def run_xctests (swift_test_exec , build_dir , release , swiftc_exec , verbose ):
315
+ def run_xctests (swift_test_exec , build_dir , parser_header_dir , parser_lib_dir ,
316
+ release , swiftc_exec , verbose ):
292
317
print ('** Running XCTests **' )
293
318
swiftpm_call = get_swiftpm_invocation (spm_exec = swift_test_exec ,
294
319
build_dir = build_dir ,
320
+ parser_header_dir = parser_header_dir ,
321
+ parser_lib_dir = parser_lib_dir ,
295
322
release = release )
296
323
297
324
if verbose :
@@ -353,7 +380,7 @@ def main():
353
380
parser = argparse .ArgumentParser (
354
381
formatter_class = argparse .RawDescriptionHelpFormatter ,
355
382
description = '''
356
- Build and test script for SwiftSytnax .
383
+ Build and test script for SwiftSyntax .
357
384
358
385
Build SwiftSyntax by generating all necessary files form the corresponding
359
386
.swift.gyb files first. For this, SwiftSyntax needs to be check out alongside
@@ -422,6 +449,18 @@ def main():
422
449
Path to the swift executable. If not specified the swiftc exeuctable
423
450
will be inferred from PATH.
424
451
''' )
452
+ testing_group .add_argument ('--syntax-parser-header-dir' , default = None ,
453
+ help = '''
454
+ Path to the header and modulemap for the syntax parser library.
455
+ If not specified no extra search path will be provided, it will be assumed
456
+ that the library is in swift's default search paths.
457
+ ''' )
458
+ testing_group .add_argument ('--syntax-parser-lib-dir' , default = None ,
459
+ help = '''
460
+ Path to the syntax parser shared library. If not specified no extra search
461
+ path will be provided, it will be assumed that the library is in swift's
462
+ default search paths.
463
+ ''' )
425
464
testing_group .add_argument ('--swift-syntax-test-exec' , default = None ,
426
465
help = '''
427
466
Path to the swift-syntax-test executable that was built from the main
@@ -463,6 +502,8 @@ def main():
463
502
build_swiftsyntax (swift_build_exec = args .swift_build_exec ,
464
503
swiftc_exec = args .swiftc_exec ,
465
504
build_dir = args .build_dir ,
505
+ parser_header_dir = args .syntax_parser_header_dir ,
506
+ parser_lib_dir = args .syntax_parser_lib_dir ,
466
507
build_test_util = args .test ,
467
508
release = args .release ,
468
509
verbose = args .verbose ,
@@ -477,6 +518,8 @@ def main():
477
518
try :
478
519
success = run_tests (swift_test_exec = args .swift_test_exec ,
479
520
build_dir = realpath (args .build_dir ),
521
+ parser_header_dir = args .syntax_parser_header_dir ,
522
+ parser_lib_dir = args .syntax_parser_lib_dir ,
480
523
release = args .release ,
481
524
swift_build_exec = args .swift_build_exec ,
482
525
filecheck_exec = realpath (args .filecheck_exec ),
0 commit comments