All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Weber <matthew.weber@rockwellcollins.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 3/6] testing/infra/builder: build with target and environment
Date: Fri, 16 Nov 2018 21:56:19 -0600	[thread overview]
Message-ID: <1542426982-54683-3-git-send-email-matthew.weber@rockwellcollins.com> (raw)
In-Reply-To: <1542426982-54683-1-git-send-email-matthew.weber@rockwellcollins.com>

From: Ricardo Martincoski <ricardo.martincoski@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@datacom.ind.br>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
---
Changes
v2
 - New from: http://patchwork.ozlabs.org/patch/912351/
---
 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 fc318fe..4d9c512 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,22 +36,41 @@ 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"]}
         if "http_proxy" in os.environ:
             self.logfile.write("Using system proxy: " +
                                os.environ["http_proxy"] + "\n")
             env['http_proxy'] = os.environ["http_proxy"]
             env['https_proxy'] = os.environ["http_proxy"]
+        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:
-- 
1.9.1

  parent reply	other threads:[~2018-11-17  3:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-17  3:56 [Buildroot] [PATCH v2 1/6] package/compiler-rt: new package Matt Weber
2018-11-17  3:56 ` [Buildroot] [PATCH v2 2/6] package/llvm: install target binary/debug tools Matt Weber
2018-11-18 19:14   ` Romain Naour
2018-11-19  1:48     ` Matthew Weber
2018-11-19  8:09       ` Romain Naour
2018-11-19 13:04         ` Matthew Weber
2018-11-20 22:36           ` Romain Naour
2018-11-20 22:44             ` Matthew Weber
2018-11-21  3:12             ` Matthew Weber
2018-11-21 21:18               ` Romain Naour
2018-11-22  3:14                 ` Matthew Weber
2018-11-22  4:05                   ` Matthew Weber
2018-11-17  3:56 ` Matt Weber [this message]
2018-11-18 21:35   ` [Buildroot] [PATCH v2 3/6] testing/infra/builder: build with target and environment Ricardo Martincoski
2018-11-17  3:56 ` [Buildroot] [PATCH v2 4/6] testing/infra/basetest: support br2-external Matt Weber
2018-11-18 21:41   ` Ricardo Martincoski
2018-11-17  3:56 ` [Buildroot] [PATCH v2 5/6] testing/tests: CLANG compiler-rt runtime test Matt Weber
2018-11-18 21:50   ` Ricardo Martincoski
2018-11-17  3:56 ` [Buildroot] [PATCH v2 6/6] llvm/clang: add note about version bumping together Matt Weber
2018-11-18 21:53   ` Ricardo Martincoski
2018-11-18 21:32 ` [Buildroot] [PATCH v2 1/6] package/compiler-rt: new package Ricardo Martincoski
2018-11-18 22:28 ` Romain Naour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1542426982-54683-3-git-send-email-matthew.weber@rockwellcollins.com \
    --to=matthew.weber@rockwellcollins.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.