@@ -285,7 +285,7 @@ def process_setup_line(line):
285
285
return bi
286
286
287
287
288
- def build_cpython ():
288
+ def build_cpython (optimized = False ):
289
289
python_archive = download_entry ('cpython-3.7' , BUILD )
290
290
python_version = DOWNLOADS ['cpython-3.7' ]['version' ]
291
291
@@ -343,7 +343,8 @@ def build_cpython():
343
343
env ['MACOSX_DEPLOYMENT_TARGET' ] = MACOSX_DEPLOYMENT_TARGET
344
344
env ['NUM_CPUS' ] = '%s' % multiprocessing .cpu_count ()
345
345
346
- env ['CPYTHON_OPTIMIZED' ] = '1'
346
+ if optimized :
347
+ env ['CPYTHON_OPTIMIZED' ] = '1'
347
348
348
349
exec_and_log ([SUPPORT / 'build-cpython.sh' ], td , env )
349
350
@@ -367,7 +368,14 @@ def build_cpython():
367
368
with (td / 'out' / 'python' / 'PYTHON.json' ).open ('w' ) as fh :
368
369
json .dump (python_info , fh , sort_keys = True , indent = 4 )
369
370
370
- dest_path = BUILD / 'cpython-macos.tar'
371
+ basename = 'cpython-macos'
372
+
373
+ if optimized :
374
+ basename += '-pgo'
375
+
376
+ basename += '.tar'
377
+
378
+ dest_path = BUILD / basename
371
379
372
380
with dest_path .open ('wb' ) as fh :
373
381
create_tar_from_directory (fh , td / 'out' )
@@ -377,6 +385,7 @@ def main():
377
385
BUILD .mkdir (exist_ok = True )
378
386
379
387
parser = argparse .ArgumentParser ()
388
+ parser .add_argument ('--optimized' , action = 'store_true' )
380
389
parser .add_argument ('action' )
381
390
382
391
args = parser .parse_args ()
@@ -396,7 +405,7 @@ def main():
396
405
build_clang ()
397
406
398
407
elif action == 'cpython' :
399
- build_cpython ()
408
+ build_cpython (optimized = args . optimized )
400
409
401
410
else :
402
411
print ('unknown build action: %s' % action )
0 commit comments