Skip to content

Commit c120317

Browse files
committed
windows: define build profiles
We only want to support specific configurations. Let's enumerate them.
1 parent bc53a30 commit c120317

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

cpython-windows/build.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,11 +1462,9 @@ def find_additional_dependencies(project: pathlib.Path):
14621462
return res
14631463

14641464

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
14701468

14711469
msbuild = find_msbuild()
14721470
log("found MSBuild at %s" % msbuild)
@@ -1763,16 +1761,10 @@ def build_cpython(arch: str, pgo=False, build_mode="static"):
17631761
with (out_dir / "python" / "PYTHON.json").open("w", encoding="utf8") as fh:
17641762
json.dump(python_info, fh, sort_keys=True, indent=4)
17651763

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,)
17701767
)
1771-
if pgo:
1772-
basename += "-pgo"
1773-
basename += ".tar"
1774-
1775-
dest_path = BUILD / basename
17761768

17771769
with dest_path.open("wb") as fh:
17781770
create_tar_from_directory(fh, td / "out")
@@ -1794,14 +1786,11 @@ def main():
17941786

17951787
parser = argparse.ArgumentParser()
17961788
parser.add_argument(
1797-
"--build-mode",
1798-
choices={"static", "shared"},
1789+
"--profile",
1790+
choices={"static", "shared", "shared-pgo"},
17991791
default="static",
18001792
help="How to compile Python",
18011793
)
1802-
parser.add_argument(
1803-
"--pgo", action="store_true", help="Enable profile-guided optimization"
1804-
)
18051794

18061795
args = parser.parse_args()
18071796

@@ -1822,7 +1811,7 @@ def main():
18221811
build_openssl(perl_path, arch)
18231812

18241813
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)
18261815

18271816
compress_python_archive(
18281817
tar_path, DIST, "%s-%s" % (tar_path.stem, now.strftime("%Y%m%dT%H%M")),

0 commit comments

Comments
 (0)