@@ -1462,11 +1462,9 @@ def find_additional_dependencies(project: pathlib.Path):
1462
1462
return res
1463
1463
1464
1464
1465
- def build_cpython (arch : str , pgo = False , build_mode = "static" ):
1466
- if pgo and build_mode == "static" :
1467
- raise Exception ("PGO not supported for static build mode" )
1468
-
1469
- static = build_mode == "static"
1465
+ def build_cpython (arch : str , profile ):
1466
+ static = profile == "static"
1467
+ pgo = "-pgo" in profile
1470
1468
1471
1469
msbuild = find_msbuild ()
1472
1470
log ("found MSBuild at %s" % msbuild )
@@ -1763,16 +1761,10 @@ def build_cpython(arch: str, pgo=False, build_mode="static"):
1763
1761
with (out_dir / "python" / "PYTHON.json" ).open ("w" , encoding = "utf8" ) as fh :
1764
1762
json .dump (python_info , fh , sort_keys = True , indent = 4 )
1765
1763
1766
- basename = "cpython-%s-windows-%s-%s" % (
1767
- DOWNLOADS ["cpython-3.7" ]["version" ],
1768
- arch ,
1769
- build_mode ,
1764
+ dest_path = BUILD / (
1765
+ "cpython-%s-windows-%s-%s.tar"
1766
+ % (DOWNLOADS ["cpython-3.7" ]["version" ], arch , profile ,)
1770
1767
)
1771
- if pgo :
1772
- basename += "-pgo"
1773
- basename += ".tar"
1774
-
1775
- dest_path = BUILD / basename
1776
1768
1777
1769
with dest_path .open ("wb" ) as fh :
1778
1770
create_tar_from_directory (fh , td / "out" )
@@ -1794,14 +1786,11 @@ def main():
1794
1786
1795
1787
parser = argparse .ArgumentParser ()
1796
1788
parser .add_argument (
1797
- "--build-mode " ,
1798
- choices = {"static" , "shared" },
1789
+ "--profile " ,
1790
+ choices = {"static" , "shared" , "shared-pgo" },
1799
1791
default = "static" ,
1800
1792
help = "How to compile Python" ,
1801
1793
)
1802
- parser .add_argument (
1803
- "--pgo" , action = "store_true" , help = "Enable profile-guided optimization"
1804
- )
1805
1794
1806
1795
args = parser .parse_args ()
1807
1796
@@ -1822,7 +1811,7 @@ def main():
1822
1811
build_openssl (perl_path , arch )
1823
1812
1824
1813
LOG_PREFIX [0 ] = "cpython"
1825
- tar_path = build_cpython (arch , build_mode = args .build_mode , pgo = args . pgo )
1814
+ tar_path = build_cpython (arch , profile = args .profile )
1826
1815
1827
1816
compress_python_archive (
1828
1817
tar_path , DIST , "%s-%s" % (tar_path .stem , now .strftime ("%Y%m%dT%H%M" )),
0 commit comments