[Buildroot] [PATCH v5 01/10] testing/infra/builder: build with target and environment
Ricardo Martincoski
ricardo.martincoski at gmail.com
Sat May 12 02:58:24 UTC 2018
From: Ricardo Martincoski <ricardo.martincoski at datacom.ind.br>
Make the builder able to call 'VAR1=1 make VAR2=2 target'.
Allow to send extra parameters to be added to the end of make command
line. It can be used for these purposes:
- to configure a br2-external, by passing 'BR2_EXTERNAL="dir"';
- to specify a make target, such as 'foo-source'.
Allow to add variables to the environment in which make runs. It can be
used to override values from environment, such as 'BR2_DL_DIR="dl"'.
This change will be needed when adding a common class to test the git
download infra.
Signed-off-by: Ricardo Martincoski <ricardo.martincoski at datacom.ind.br>
Cc: Arnout Vandecappelle <arnout at mind.be>
---
Changes v4 -> v5:
- no changes
Changes v3 -> v4:
- no changes
Changes v2 -> v3:
- rebase after adding patch 1 to the series, which runs make using an
empty env;
- use docstring (Arnout Vandecappelle);
- use more descriptive parameter names (make_extra_opts,
make_extra_env) (Arnout Vandecappelle);
- default make_extra_env to {} and use update() (Arnout
Vandecappelle);
- for consistence I did the equivalent to make_extra_opts;
- for symmetry, use make_extra_env also in the configure() (Arnout
Vandecappelle);
- remove old example from commit message since using a static repo to
test git refs do not need to override _VERSION.
Changes v1 -> v2:
- new patch to adapt the test infra to test git download;
---
support/testing/infra/builder.py | 38 ++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/support/testing/infra/builder.py b/support/testing/infra/builder.py
index faf1eb1494..d478c0d212 100644
--- a/support/testing/infra/builder.py
+++ b/support/testing/infra/builder.py
@@ -12,7 +12,18 @@ class Builder(object):
self.builddir = builddir
self.logfile = infra.open_log_file(builddir, "build", logtofile)
- def configure(self):
+ def configure(self, make_extra_opts=[], make_extra_env={}):
+ """
+ Configure the build.
+
+ make_extra_opts: a list of arguments to be passed to the make
+ command.
+ e.g. make_extra_opts=["BR2_EXTERNAL=/path"]
+
+ make_extra_env: a dict of variables to be appended (or replaced)
+ in the environment that calls make.
+ e.g. make_extra_env={"BR2_DL_DIR": "/path"}
+ """
if not os.path.isdir(self.builddir):
os.makedirs(self.builddir)
@@ -25,17 +36,36 @@ class Builder(object):
self.logfile.flush()
env = {"PATH": os.environ["PATH"]}
+ env.update(make_extra_env)
+
cmd = ["make",
- "O={}".format(self.builddir),
- "olddefconfig"]
+ "O={}".format(self.builddir)]
+ cmd += make_extra_opts
+ cmd += ["olddefconfig"]
+
ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile,
env=env)
if ret != 0:
raise SystemError("Cannot olddefconfig")
- def build(self):
+ def build(self, make_extra_opts=[], make_extra_env={}):
+ """
+ Perform the build.
+
+ make_extra_opts: a list of arguments to be passed to the make
+ command. It can include a make target.
+ e.g. make_extra_opts=["foo-source"]
+
+ make_extra_env: a dict of variables to be appended (or replaced)
+ in the environment that calls make.
+ e.g. make_extra_env={"BR2_DL_DIR": "/path"}
+ """
env = {"PATH": os.environ["PATH"]}
+ env.update(make_extra_env)
+
cmd = ["make", "-C", self.builddir]
+ cmd += make_extra_opts
+
ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile,
env=env)
if ret != 0:
--
2.17.0
More information about the buildroot
mailing list