@@ -532,7 +532,7 @@ def process_setup_line(line):
532
532
return bi
533
533
534
534
535
- def build_cpython (client , image , platform ):
535
+ def build_cpython (client , image , platform , optimized = False ):
536
536
"""Build CPythin in a Docker image'"""
537
537
python_archive = download_entry ('cpython-3.7' , BUILD )
538
538
@@ -587,10 +587,12 @@ def build_cpython(client, image, platform):
587
587
archive_path = 'Makefile.extra' )
588
588
589
589
env = {
590
- 'CPYTHON_OPTIMIZED' : '1' ,
591
590
'PYTHON_VERSION' : DOWNLOADS ['cpython-3.7' ]['version' ],
592
591
}
593
592
593
+ if optimized :
594
+ env ['CPYTHON_OPTIMIZED' ] = '1'
595
+
594
596
container_exec (container , '/build/build-cpython.sh' ,
595
597
environment = env )
596
598
@@ -617,7 +619,14 @@ def build_cpython(client, image, platform):
617
619
'/build/out/python' ,
618
620
archive_path = 'PYTHON.json' )
619
621
620
- dest_path = BUILD / ('cpython-%s.tar' % platform )
622
+ basename = 'cpython-%s' % platform
623
+
624
+ if optimized :
625
+ basename += '-pgo'
626
+
627
+ basename += '.tar'
628
+
629
+ dest_path = BUILD / basename
621
630
data , stat = container .get_archive ('/build/out/python' )
622
631
623
632
with dest_path .open ('wb' ) as fh :
@@ -637,17 +646,21 @@ def main():
637
646
638
647
parser = argparse .ArgumentParser ()
639
648
parser .add_argument ('--platform' )
649
+ parser .add_argument ('--optimized' , action = 'store_true' )
640
650
parser .add_argument ('action' )
641
651
642
652
args = parser .parse_args ()
643
653
644
654
action = args .action
645
655
646
- log_path = BUILD / ('build.%s.log' % action )
647
- LOG_PREFIX [0 ] = action
656
+ name = action
648
657
if args .platform :
649
- log_path = BUILD / ('build.%s-%s.log' % (action , args .platform ))
650
- LOG_PREFIX [0 ] = '%s-%s' % (action , args .platform )
658
+ name += '-%s' % args .platform
659
+ if args .optimized :
660
+ name += '-pgo'
661
+
662
+ log_path = BUILD / ('build.%s.log' % name )
663
+ LOG_PREFIX [0 ] = name
651
664
652
665
with log_path .open ('wb' ) as log_fh :
653
666
LOG_FH [0 ] = log_fh
@@ -676,7 +689,8 @@ def main():
676
689
build_tcltk (client , get_image (client , 'build' ), platform = args .platform )
677
690
678
691
elif action == 'cpython' :
679
- build_cpython (client , get_image (client , 'build' ), platform = args .platform )
692
+ build_cpython (client , get_image (client , 'build' ), platform = args .platform ,
693
+ optimized = args .optimized )
680
694
681
695
else :
682
696
print ('unknown build action: %s' % action )
0 commit comments