Skip to content

Commit 2d13ada

Browse files
polkovnikovindygreg
authored andcommitted
Use jom instead of nmake, for multi-core compile support.
1 parent 5046879 commit 2d13ada

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

cpython-windows/build.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
import sys
1616
import tempfile
1717
import zipfile
18+
import multiprocessing
1819

1920
from pythonbuild.downloads import DOWNLOADS
2021
from pythonbuild.cpython import parse_config_c, STDLIB_TEST_PACKAGES
2122
from pythonbuild.utils import (
2223
create_tar_from_directory,
2324
download_entry,
2425
extract_tar_to_directory,
26+
extract_zip_to_directory,
2527
compress_python_archive,
2628
)
2729

@@ -1093,20 +1095,26 @@ def build_openssl_for_arch(
10931095
nasm_archive,
10941096
build_root: pathlib.Path,
10951097
profile: str,
1098+
*,
1099+
jom_archive,
10961100
):
10971101
openssl_version = DOWNLOADS["openssl"]["version"]
10981102
nasm_version = DOWNLOADS["nasm-windows-bin"]["version"]
1099-
1103+
jom_version = DOWNLOADS["jom-windows-bin"]["version"]
1104+
11001105
log("extracting %s to %s" % (openssl_archive, build_root))
11011106
extract_tar_to_directory(openssl_archive, build_root)
11021107
log("extracting %s to %s" % (nasm_archive, build_root))
11031108
extract_tar_to_directory(nasm_archive, build_root)
1109+
log("extracting %s to %s" % (jom_archive, build_root))
1110+
extract_zip_to_directory(jom_archive, build_root / "jom")
11041111

11051112
nasm_path = build_root / ("cpython-bin-deps-nasm-%s" % nasm_version)
1106-
1113+
jom_path = build_root / "jom"
1114+
11071115
env = dict(os.environ)
11081116
# Add Perl and nasm paths to front of PATH.
1109-
env["PATH"] = "%s;%s;%s" % (perl_path.parent, nasm_path, env["PATH"])
1117+
env["PATH"] = "%s;%s;%s;%s" % (perl_path.parent, nasm_path, jom_path, env["PATH"])
11101118

11111119
source_root = build_root / ("openssl-%s" % openssl_version)
11121120

@@ -1150,10 +1158,14 @@ def build_openssl_for_arch(
11501158
"--prefix=/%s" % prefix,
11511159
],
11521160
source_root,
1153-
env,
1161+
{
1162+
**env,
1163+
'CFLAGS': env.get('CFLAGS', '') + ' /FS',
1164+
},
11541165
)
11551166

1156-
exec_and_log(["nmake"], source_root, env)
1167+
#exec_and_log(["nmake"], source_root, env)
1168+
exec_and_log([str(jom_path / "jom"), "/J", str(multiprocessing.cpu_count())], source_root, env)
11571169

11581170
# We don't care about accessory files, docs, etc. So just run `install_sw`
11591171
# target to get the main files.
@@ -1174,6 +1186,7 @@ def build_openssl(perl_path: pathlib.Path, arch: str, profile: str):
11741186
# First ensure the dependencies are in place.
11751187
openssl_archive = download_entry("openssl", BUILD)
11761188
nasm_archive = download_entry("nasm-windows-bin", BUILD)
1189+
jom_archive = download_entry("jom-windows-bin", BUILD)
11771190

11781191
with tempfile.TemporaryDirectory(prefix="openssl-build-") as td:
11791192
td = pathlib.Path(td)
@@ -1184,12 +1197,12 @@ def build_openssl(perl_path: pathlib.Path, arch: str, profile: str):
11841197
if arch == "x86":
11851198
root_32.mkdir()
11861199
build_openssl_for_arch(
1187-
perl_path, "x86", openssl_archive, nasm_archive, root_32, profile
1200+
perl_path, "x86", openssl_archive, nasm_archive, root_32, profile, jom_archive = jom_archive,
11881201
)
11891202
elif arch == "amd64":
11901203
root_64.mkdir()
11911204
build_openssl_for_arch(
1192-
perl_path, "amd64", openssl_archive, nasm_archive, root_64, profile
1205+
perl_path, "amd64", openssl_archive, nasm_archive, root_64, profile, jom_archive = jom_archive,
11931206
)
11941207
else:
11951208
raise ValueError("unhandled arch: %s" % arch)

pythonbuild/downloads.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@
104104
"sha256": "6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b",
105105
"version": "0.18",
106106
},
107+
"jom-windows-bin": {
108+
"url": "http://download.qt.io/official_releases/jom/jom_1_1_3.zip",
109+
"size": 1213852,
110+
"sha256": "128fdd846fe24f8594eed37d1d8929a0ea78df563537c0c1b1861a635013fff8",
111+
"version": "1.1.3",
112+
},
107113
"kbproto": {
108114
"url": "ftp://mirror.csclub.uwaterloo.ca/x.org/pub/current/src/proto/kbproto-1.0.7.tar.gz",
109115
"size": 325858,

pythonbuild/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import subprocess
1010
import sys
1111
import tarfile
12+
import zipfile
1213
import urllib.request
1314

1415
import zstandard
@@ -164,6 +165,10 @@ def extract_tar_to_directory(source: pathlib.Path, dest: pathlib.Path):
164165
with tarfile.open(source, "r") as tf:
165166
tf.extractall(dest)
166167

168+
def extract_zip_to_directory(source: pathlib.Path, dest: pathlib.Path):
169+
with zipfile.ZipFile(source, "r") as zf:
170+
zf.extractall(dest)
171+
167172

168173
def compress_python_archive(
169174
source_path: pathlib.Path, dist_path: pathlib.Path, basename: str

0 commit comments

Comments
 (0)