diff options
author | Michael Thies <mail@mhthies.de> | 2023-01-29 17:38:32 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-02-09 10:49:02 +0100 |
commit | 48115e5c803a2c73d35d047a9a0d9b2ea1352e64 (patch) | |
tree | 9821bf574e695ac6b6270b0d44c0b39a7e11c55b /bin | |
parent | 18b5ba83c79232efba513b554dea12263e5e5f9e (diff) | |
download | justbuild-48115e5c803a2c73d35d047a9a0d9b2ea1352e64.tar.gz |
bootstrap.py: Add env variable NON_LOCAL_DEPS
... to indicate, in case of a package build, which dependencies
should not be taken from the local environment. As those need a
different target root (and potentially other roots), we keep a
copy of file roots modified when transitioning to local builds and
rewrite the changed file roots in the NON_LOCAL_DEPS accordingly.
Co-authored-by: Klaus Aehlig <aehlig@linta.de>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bootstrap.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/bootstrap.py b/bin/bootstrap.py index 12a97807..331950e5 100755 --- a/bin/bootstrap.py +++ b/bin/bootstrap.py @@ -83,6 +83,7 @@ SRCDIR = os.getcwd() WRKDIR = None DISTDIR = [] LOCALBASE = "/" +NON_LOCAL_DEPS = [] # other global variables @@ -185,7 +186,11 @@ def config_to_local(*, repos_file, link_targets_file): with open(repos_file) as f: repos = json.load(f) global_link_dirs = set() + changed_file_roots = {} + backup_layers = {} for repo in repos["repositories"]: + if repo in NON_LOCAL_DEPS: + continue desc = repos["repositories"][repo] repo_desc = desc.get("repository") if not isinstance(repo_desc, dict): @@ -211,6 +216,14 @@ def config_to_local(*, repos_file, link_targets_file): del desc["local_bootstrap"] if repo_desc.get("type") == "file": local_bootstrap = desc.get("local_bootstrap", {}) + if local_bootstrap.get("local_path") and NON_LOCAL_DEPS: + # local layer gets changed, keep a copy + backup_name = "ORIGINAL: " + repo + backup_layers[backup_name] = { + "repository": {"type": "file", + "path": repo_desc.get("path") + }} + changed_file_roots[repo] = backup_name desc["repository"] = { "type": "file", "path": local_bootstrap.get("local_path", desc["repository"].get("path")) @@ -219,6 +232,17 @@ def config_to_local(*, repos_file, link_targets_file): if "local_bootstrap" in desc: del desc["local_bootstrap"] + # For repos that we didn't change to local, make file roots point + # to the original version, so that, in particular, the original + # target root will be used. + for repo in NON_LOCAL_DEPS: + for layer in ["target_root", "rule_root", "expression_root"]: + layer_ref = repos["repositories"][repo].get(layer) + if layer_ref in changed_file_roots: + repos["repositories"][repo][layer] = changed_file_roots[layer_ref] + + repos["repositories"] = dict(repos["repositories"], **backup_layers) + print("just-mr config rewritten to local:\n%s\n" % (json.dumps(repos, indent=2))) os.unlink(repos_file) @@ -331,6 +355,7 @@ def main(args): global DISTDIR global LOCAL_DEPS global LOCALBASE + global NON_LOCAL_DEPS if len(args) > 1: SRCDIR = os.path.abspath(args[1]) if len(args) > 2: @@ -345,6 +370,7 @@ def main(args): LOCAL_DEPS = "PACKAGE" in os.environ LOCALBASE = os.environ.get("LOCALBASE", "/") + NON_LOCAL_DEPS = json.loads(os.environ.get("NON_LOCAL_DEPS", "[]")) bootstrap() |