@@ -163,7 +163,7 @@ def get_installed_dylib_name():
163
163
return 'lib' + get_installed_name () + '.dylib'
164
164
165
165
def get_swiftpm_invocation (spm_exec , build_dir , parser_header_dir ,
166
- parser_lib_dir , release ):
166
+ parser_lib_dir , release , module_group = False ):
167
167
if spm_exec == 'swift build' :
168
168
swiftpm_call = ['swift' , 'build' ]
169
169
elif spm_exec == 'swift test' :
@@ -192,41 +192,47 @@ def get_swiftpm_invocation(spm_exec, build_dir, parser_header_dir,
192
192
swiftpm_call .extend (['-Xswiftc' , '-enforce-exclusivity=unchecked' ])
193
193
194
194
# To build the group information into the module documentation file
195
- # swiftpm_call.extend(['-Xswiftc', '-Xfrontend', '-Xswiftc', '-group-info-path'])
196
- # swiftpm_call.extend(['-Xswiftc', '-Xfrontend', '-Xswiftc', GROUP_INFO_PATH])
195
+ if module_group :
196
+ swiftpm_call .extend (['-Xswiftc' , '-Xfrontend' , '-Xswiftc' , '-group-info-path' ])
197
+ swiftpm_call .extend (['-Xswiftc' , '-Xfrontend' , '-Xswiftc' , GROUP_INFO_PATH ])
197
198
198
199
return swiftpm_call
199
200
200
- def build_swiftsyntax (swift_build_exec , swiftc_exec , build_dir ,
201
- parser_header_dir , parser_lib_dir ,
202
- build_test_util , release ,
203
- verbose , disable_sandbox = False ):
204
- print ('** Building SwiftSyntax **' )
205
-
206
- swiftpm_call = get_swiftpm_invocation (spm_exec = swift_build_exec ,
207
- build_dir = build_dir ,
208
- parser_header_dir = parser_header_dir ,
209
- parser_lib_dir = parser_lib_dir ,
210
- release = release )
211
- swiftpm_call .extend (['--product' , 'SwiftSyntax' ])
212
-
213
- if disable_sandbox :
214
- swiftpm_call .append ('--disable-sandbox' )
215
-
216
- # Only build lit-test-helper if we are planning to run tests
217
- if build_test_util :
218
- swiftpm_call .extend (['--product' , 'lit-test-helper' ])
219
-
220
- if verbose :
221
- swiftpm_call .extend (['--verbose' ])
222
- _environ = dict (os .environ )
223
- _environ ['SWIFT_EXEC' ] = swiftc_exec
224
- _environ ['SWIFT_SYNTAX_BUILD_SCRIPT' ] = ''
225
- check_call (swiftpm_call , env = _environ , verbose = verbose )
201
+ class Builder (object ):
202
+ def __init__ (self , swift_build_exec , swiftc_exec , build_dir ,
203
+ parser_header_dir , parser_lib_dir ,
204
+ release , verbose , disable_sandbox = False ):
205
+ self .swift_build_exec = swift_build_exec
206
+ self .swiftc_exec = swiftc_exec
207
+ self .build_dir = build_dir
208
+ self .parser_header_dir = parser_header_dir
209
+ self .parser_lib_dir = parser_lib_dir
210
+ self .release = release
211
+ self .verbose = verbose
212
+ self .disable_sandbox = disable_sandbox
213
+
214
+ def build (self , product_name , module_group = False ):
215
+ print ('** Building ' + product_name + ' **' )
216
+ swiftpm_call = get_swiftpm_invocation (spm_exec = self .swift_build_exec ,
217
+ build_dir = self .build_dir ,
218
+ parser_header_dir = self .parser_header_dir ,
219
+ parser_lib_dir = self .parser_lib_dir ,
220
+ release = self .release ,
221
+ module_group = module_group )
222
+ swiftpm_call .extend (['--product' , product_name ])
223
+
224
+ if self .disable_sandbox :
225
+ swiftpm_call .append ('--disable-sandbox' )
226
+
227
+ if self .verbose :
228
+ swiftpm_call .extend (['--verbose' ])
229
+ _environ = dict (os .environ )
230
+ _environ ['SWIFT_EXEC' ] = self .swiftc_exec
231
+ _environ ['SWIFT_SYNTAX_BUILD_SCRIPT' ] = ''
232
+ check_call (swiftpm_call , env = _environ , verbose = self .verbose )
226
233
227
234
228
235
## Testing
229
-
230
236
def run_tests (swift_test_exec , build_dir , parser_header_dir , parser_lib_dir ,
231
237
release , swift_build_exec , filecheck_exec , swiftc_exec , verbose ):
232
238
print ('** Running SwiftSyntax Tests **' )
@@ -541,15 +547,19 @@ def main():
541
547
sys .exit (0 )
542
548
543
549
try :
544
- build_swiftsyntax (swift_build_exec = args .swift_build_exec ,
550
+ builder = Builder (swift_build_exec = args .swift_build_exec ,
545
551
swiftc_exec = args .swiftc_exec ,
546
552
build_dir = args .build_dir ,
547
553
parser_header_dir = args .syntax_parser_header_dir ,
548
554
parser_lib_dir = args .syntax_parser_lib_dir ,
549
- build_test_util = args .test ,
550
555
release = args .release ,
551
556
verbose = args .verbose ,
552
557
disable_sandbox = args .disable_sandbox )
558
+ builder .build ('SwiftSyntax' , module_group = True )
559
+
560
+ # Only build lit-test-helper if we are planning to run tests
561
+ if args .test :
562
+ builder .build ('lit-test-helper' )
553
563
except subprocess .CalledProcessError as e :
554
564
printerr ('Error: Building SwiftSyntax failed' )
555
565
printerr ('Executing: %s' % ' ' .join (e .cmd ))
0 commit comments