@@ -58,10 +58,10 @@ def call(cmd, env=os.environ, stdout=None, stderr=subprocess.STDOUT,
5858 return process .returncode
5959
6060
61- def check_call (cmd , env = os .environ , verbose = False ):
61+ def check_call (cmd , cwd = None , env = os .environ , verbose = False ):
6262 if verbose :
6363 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 )
6565
6666
6767def realpath (path ):
@@ -91,7 +91,7 @@ def check_rsync():
9191 fatal_error ('Error: Could not find rsync.' )
9292
9393
94- def generate_gyb_files (verbose , add_source_locations ):
94+ def generate_gyb_files (verbose , add_source_locations , tar_path ):
9595 print ('** Generating gyb Files **' )
9696
9797 check_gyb_exec ()
@@ -139,7 +139,14 @@ def generate_gyb_files(verbose, add_source_locations):
139139 verbose = verbose )
140140
141141 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 )
143150
144151## Building swiftSyntax
145152
@@ -443,6 +450,10 @@ def main():
443450 help = 'The script only generates swift files from gyb '
444451 'and skips the rest of the build' )
445452
453+ build_group .add_argument ('--degyb-tar-path' ,
454+ help = 'The path to where we should tar the gyb-generated'
455+ 'files' )
456+
446457 testing_group = parser .add_argument_group ('Testing' )
447458 testing_group .add_argument ('-t' , '--test' , action = 'store_true' ,
448459 help = 'Run tests' )
@@ -503,7 +514,8 @@ def main():
503514
504515 try :
505516 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 )
507519 # Skip the rest of the build if we should perform degyb only
508520 if args .degyb_only :
509521 sys .exit (0 )
0 commit comments