From patchwork Thu Jan 3 21:52:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Weber X-Patchwork-Id: 1020523 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rockwellcollins.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43W1qy251Pz9s7h for ; Fri, 4 Jan 2019 08:53:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id ABC832331B; Thu, 3 Jan 2019 21:53:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GguyRy+uV+Co; Thu, 3 Jan 2019 21:52:59 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 87E3921FA8; Thu, 3 Jan 2019 21:52:59 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 349F81C0804 for ; Thu, 3 Jan 2019 21:52:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 3235587169 for ; Thu, 3 Jan 2019 21:52:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y947XeP+nG9X for ; Thu, 3 Jan 2019 21:52:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from da1vs01.rockwellcollins.com (da1vs01.rockwellcollins.com [205.175.227.27]) by hemlock.osuosl.org (Postfix) with ESMTPS id DAE0E86FDE for ; Thu, 3 Jan 2019 21:52:50 +0000 (UTC) Received: from ofwda1n02.rockwellcollins.com (HELO crulimr01.rockwellcollins.com) ([205.175.227.14]) by da1vs01.rockwellcollins.com with ESMTP; 03 Jan 2019 15:52:50 -0600 X-Received: from largo.rockwellcollins.com (unknown [192.168.140.76]) by crulimr01.rockwellcollins.com (Postfix) with ESMTP id 2AE496031E; Thu, 3 Jan 2019 15:52:50 -0600 (CST) From: Matt Weber To: buildroot@buildroot.org Date: Thu, 3 Jan 2019 15:52:44 -0600 Message-Id: <1546552368-50707-3-git-send-email-matthew.weber@rockwellcollins.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546552368-50707-1-git-send-email-matthew.weber@rockwellcollins.com> References: <1546552368-50707-1-git-send-email-matthew.weber@rockwellcollins.com> Subject: [Buildroot] [PATCH v6 3/7] testing/infra/builder: build with target and environment X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ricardo Martincoski MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Ricardo Martincoski 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 support for br2-externals to the test infra. Signed-off-by: Ricardo Martincoski Cc: Arnout Vandecappelle Signed-off-by: Matt Weber --- Changes v2 - New from: http://patchwork.ozlabs.org/patch/912351/ v2 -> v3 [Ricardo - Updated patch commit description context. v4 - None v5 - Rebased post 2018.11 on master --- 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: