From 4943d4268acc357364a45a1367bc641ed639dccd Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Wed, 26 Oct 2022 15:52:24 +0200 Subject: bootstrap: Support building bootstrap_just in parallel --- bin/bootstrap.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'bin/bootstrap.py') diff --git a/bin/bootstrap.py b/bin/bootstrap.py index 098662d7..41b91e49 100755 --- a/bin/bootstrap.py +++ b/bin/bootstrap.py @@ -24,9 +24,12 @@ import tempfile import platform from pathlib import Path +from concurrent.futures import ThreadPoolExecutor # path within the repository (constants) +DEBUG = os.environ.get("DEBUG") + REPOS = "etc/repos.json" BOOTSTRAP_CC = ["clang++", "-std=c++20", "-DBOOTSTRAP_BUILD_TOOL"] MAIN_MODULE = "" @@ -238,11 +241,12 @@ def bootstrap(): if f.endswith(".cpp"): cpp_files.append(os.path.join(root, f)) object_files = [] - for f in cpp_files: - obj_file_name = f[:-len(".cpp")] + ".o" - object_files.append(obj_file_name) - cmd = BOOTSTRAP_CC + flags + ["-c", f, "-o", obj_file_name] - run(cmd, cwd=src_wrkdir) + with ThreadPoolExecutor(max_workers=1 if DEBUG else None) as ts: + for f in cpp_files: + obj_file_name = f[:-len(".cpp")] + ".o" + object_files.append(obj_file_name) + cmd = BOOTSTRAP_CC + flags + ["-c", f, "-o", obj_file_name] + ts.submit(run, cmd, cwd=src_wrkdir) bootstrap_just = os.path.join(WRKDIR, "bootstrap-just") cmd = BOOTSTRAP_CC + ["-o", bootstrap_just ] + object_files + dep_flags["link"] @@ -264,7 +268,7 @@ def bootstrap(): "--dump-artifacts-to-build", TO_BUILD, MAIN_MODULE, MAIN_TARGET ], cwd=src_wrkdir) - if "DEBUG" in os.environ: + if DEBUG: traverser = "./bin/bootstrap-traverser.py" else: traverser = "./bin/parallel-bootstrap-traverser.py" -- cgit v1.2.3