summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mdbp/build_schema.json9
-rw-r--r--mdbp/common.py11
2 files changed, 18 insertions, 2 deletions
diff --git a/mdbp/build_schema.json b/mdbp/build_schema.json
index 90e4a36..34185ce 100644
--- a/mdbp/build_schema.json
+++ b/mdbp/build_schema.json
@@ -79,6 +79,15 @@
"default": [],
"description": "values of DEB_BUILD_OPTIONS"
},
+ "parallel": {
+ "oneOf": [ {
+ "type": "integer",
+ "minimum": 1
+ }, {
+ "const": "auto"
+ } ],
+ "description": "add parallel=value to DEB_BUILD_OPTIONS. The special value auto is replaced with the CPU count."
+ },
"environment": {
"type": "object",
"propertyNames": { "pattern": "^[^=-][^=]*$" },
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):