From 29859ef384a596e32d7c6c062eb5e9011ba14dde Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sun, 9 May 2021 22:30:29 +0200 Subject: 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. --- mdbp/build_schema.json | 9 +++++++++ mdbp/common.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'mdbp') 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): -- cgit v1.2.3