@@ -58,10 +58,10 @@ def call(cmd, env=os.environ, stdout=None, stderr=subprocess.STDOUT,
58
58
return process .returncode
59
59
60
60
61
- def check_call (cmd , env = os .environ , verbose = False ):
61
+ def check_call (cmd , cwd = None , env = os .environ , verbose = False ):
62
62
if verbose :
63
63
print (' ' .join ([escapeCmdArg (arg ) for arg in cmd ]))
64
- return subprocess .check_call (cmd , env = env , stderr = subprocess .STDOUT )
64
+ return subprocess .check_call (cmd , cwd = cwd , env = env , stderr = subprocess .STDOUT )
65
65
66
66
67
67
def realpath (path ):
@@ -91,7 +91,7 @@ def check_rsync():
91
91
fatal_error ('Error: Could not find rsync.' )
92
92
93
93
94
- def generate_gyb_files (verbose , add_source_locations ):
94
+ def generate_gyb_files (verbose , add_source_locations , tar_path ):
95
95
print ('** Generating gyb Files **' )
96
96
97
97
check_gyb_exec ()
@@ -139,7 +139,14 @@ def generate_gyb_files(verbose, add_source_locations):
139
139
verbose = verbose )
140
140
141
141
print ('Done Generating gyb Files' )
142
-
142
+ if not tar_path :
143
+ return
144
+ tar_command = ['tar' , '-c' , '-z' , '-f' , tar_path ]
145
+ for degybed_file in os .listdir (generated_files_dir ):
146
+ if not degybed_file .endswith ('.swift' ):
147
+ continue
148
+ tar_command .append (degybed_file )
149
+ check_call (tar_command , cwd = generated_files_dir )
143
150
144
151
## Building swiftSyntax
145
152
@@ -443,6 +450,10 @@ def main():
443
450
help = 'The script only generates swift files from gyb '
444
451
'and skips the rest of the build' )
445
452
453
+ build_group .add_argument ('--degyb-tar-path' ,
454
+ help = 'The path to where we should tar the gyb-generated'
455
+ 'files' )
456
+
446
457
testing_group = parser .add_argument_group ('Testing' )
447
458
testing_group .add_argument ('-t' , '--test' , action = 'store_true' ,
448
459
help = 'Run tests' )
@@ -503,7 +514,8 @@ def main():
503
514
504
515
try :
505
516
generate_gyb_files (verbose = args .verbose ,
506
- add_source_locations = args .add_source_locations )
517
+ add_source_locations = args .add_source_locations ,
518
+ tar_path = args .degyb_tar_path )
507
519
# Skip the rest of the build if we should perform degyb only
508
520
if args .degyb_only :
509
521
sys .exit (0 )
0 commit comments