diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-05-09 22:30:29 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-05-09 22:30:29 +0200 |
commit | 29859ef384a596e32d7c6c062eb5e9011ba14dde (patch) | |
tree | c109f81f4e162b751cd8cdb61c66aa34cb4f5dae /mdbp/common.py | |
parent | 49f5448f0f48bbfdd823f076312cd234d707f3f2 (diff) | |
download | mdbp-29859ef384a596e32d7c6c062eb5e9011ba14dde.tar.gz |
support a new field "parallel"
It is basically the parallel field from DEB_BUILD_OPTION which a special
value "auto" that is converted to the CPU count.
Diffstat (limited to 'mdbp/common.py')
-rw-r--r-- | mdbp/common.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mdbp/common.py b/mdbp/common.py index 77cbd33..097c7a3 100644 --- a/mdbp/common.py +++ b/mdbp/common.py @@ -7,6 +7,7 @@ import contextlib import hashlib import importlib.resources import json +import multiprocessing import pathlib import tempfile import typing @@ -57,8 +58,14 @@ def compute_env(build: JsonObject) -> typing.Dict[str, str]: """Compute the process environment from the build object.""" env = dict(PATH="/usr/bin:/bin") env.update(build.get("environment", {})) - if build.get("options"): - env["DEB_BUILD_OPTIONS"] = " ".join(build["options"]) + parallel = build.get("parallel") + if parallel == "auto": + parallel = "%d" % multiprocessing.cpu_count() + options = build.get("options", []) + if parallel: + options.append("parallel=" + parallel) + if options: + env["DEB_BUILD_OPTIONS"] = " ".join(options) return env class HashSumMismatch(Exception): |