summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-10-26 14:54:36 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2022-10-26 18:09:06 +0200
commit4e1887c8f496528081214446ea055a10be8e5b86 (patch)
treef3c4242199177af9b5e563ba3d9c34d9f932c3f3
parenta29128d4e5ba64bf09f67a7cffea6925af01e0e4 (diff)
downloadjustbuild-4e1887c8f496528081214446ea055a10be8e5b86.tar.gz
Bootstrap: allow setting build configuration
When constructing the build configuration for the bootstrap build is just, start with the value of the environment variable JUST_BUILD_CONF, if set, instead of the empty object. While there, also propagate SOURCE_DATE_EPOCH from the environment to the build configuration.
-rw-r--r--INSTALL.md11
-rwxr-xr-xbin/bootstrap.py18
2 files changed, 25 insertions, 4 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 552b1f8d..e43d1f44 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -70,6 +70,17 @@ before to be present as well).
Additionally, if the environment variable `DEBUG` is set, the second
bootstrap phase is carried out sequentially rather than in parallel.
+Moreover, when constructing the build configuration, the scripts
+starts with the value of the environment variable `JUST_BUILD_CONF` instead
+of the empty object, if this variable is set. One configuration parameter
+is the build enviroment `ENV` that can be used to set an unusual
+value of `PATH`, e.g.,
+``` sh
+env JUST_BUILD_CONF='{"ENV": {"PATH": "/opt/toolchain/bin"}}' python3 ./bin/boostrap.py
+```
+Additionally, if `SOURCE_DATE_EPOCH` is set in the build environment, it
+is forwarded to the build configuration as well.
+
In any case, the resulting binary is selfcontained and can be moved
to an appropriate location in `PATH`.
diff --git a/bin/bootstrap.py b/bin/bootstrap.py
index 4b83e033..098662d7 100755
--- a/bin/bootstrap.py
+++ b/bin/bootstrap.py
@@ -37,14 +37,24 @@ LOCAL_LINK_DIRS_MODULE = "src/buildtool/main"
LOCAL_LINK_DIRS_TARGET = "just"
# architecture related configuration (global variables)
+CONF = {}
+if 'JUST_BUILD_CONF' in os.environ:
+ CONF = json.loads(os.environ['JUST_BUILD_CONF'])
+
ARCHS = {
'i686':'x86',
'x86_64':'x86_64',
'arm':'arm',
'aarch64':'arm64'
}
-MACH = platform.machine()
-CONF = ('{"ARCH":"%s"}' % (ARCHS[MACH],)) if MACH in ARCHS else '{}'
+if "ARCH" not in CONF:
+ MACH = platform.machine()
+ if MACH in ARCHS:
+ CONF["ARCH"] = ARCHS[MACH]
+if 'SOURCE_DATE_EPOCH' in os.environ:
+ CONF['SOURCE_DATE_EPOCH'] = int(os.environ['SOURCE_DATE_EPOCH'])
+
+CONF_STRING = json.dumps(CONF)
# relevant directories (global variables)
@@ -250,7 +260,7 @@ def bootstrap():
GRAPH = os.path.join(WRKDIR, "graph.json")
TO_BUILD = os.path.join(WRKDIR, "to_build.json")
run([
- bootstrap_just, "analyse", "-C", CONF_FILE, "-D", CONF, "--dump-graph", GRAPH,
+ bootstrap_just, "analyse", "-C", CONF_FILE, "-D", CONF_STRING, "--dump-graph", GRAPH,
"--dump-artifacts-to-build", TO_BUILD, MAIN_MODULE, MAIN_TARGET
],
cwd=src_wrkdir)
@@ -265,7 +275,7 @@ def bootstrap():
cwd=src_wrkdir)
OUT = os.path.join(WRKDIR, "out")
run([
- "./out-boot/%s" % (MAIN_STAGE, ), "install", "-C", CONF_FILE, "-D", CONF, "-o", OUT,
+ "./out-boot/%s" % (MAIN_STAGE, ), "install", "-C", CONF_FILE, "-D", CONF_STRING, "-o", OUT,
"--local-build-root", LOCAL_ROOT, MAIN_MODULE, MAIN_TARGET
],
cwd=src_wrkdir)