From patchwork Mon Aug 22 15:19:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 11700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2C1AC32772 for ; Mon, 22 Aug 2022 15:20:05 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.19159.1661181595214508316 for ; Mon, 22 Aug 2022 08:19:55 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FDA213D5; Mon, 22 Aug 2022 08:19:58 -0700 (PDT) Received: from oss-tx204.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6F00A3F70D; Mon, 22 Aug 2022 08:19:54 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Cc: nd@arm.com Subject: [PATCH 2/3] oeqa/commands: add support for running cross tools to runCmd Date: Mon, 22 Aug 2022 16:19:49 +0100 Message-Id: <20220822151950.2611880-2-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822151950.2611880-1-ross.burton@arm.com> References: <20220822151950.2611880-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 22 Aug 2022 15:20:05 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/169677 If native_sysroot is passed, also support the caller passing in the target_sys and add that to the path if so. This allows runCmd() to be used to invoke the cross tools. Signed-off-by: Ross Burton --- meta/lib/oeqa/utils/commands.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 024261410e0..f733fcdf3c8 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -168,15 +168,22 @@ class Result(object): def runCmd(command, ignore_status=False, timeout=None, assert_error=True, sync=True, - native_sysroot=None, limit_exc_output=0, output_log=None, **options): + native_sysroot=None, target_sys=None, limit_exc_output=0, output_log=None, **options): result = Result() if native_sysroot: - extra_paths = "%s/sbin:%s/usr/sbin:%s/usr/bin" % \ - (native_sysroot, native_sysroot, native_sysroot) - nenv = dict(options.get('env', os.environ)) - nenv['PATH'] = extra_paths + ':' + nenv.get('PATH', '') - options['env'] = nenv + new_env = dict(options.get('env', os.environ)) + paths = new_env["PATH"].split(":") + paths = [ + os.path.join(native_sysroot, "bin"), + os.path.join(native_sysroot, "sbin"), + os.path.join(native_sysroot, "usr", "bin"), + os.path.join(native_sysroot, "usr", "sbin"), + ] + paths + if target_sys: + paths = [os.path.join(native_sysroot, "usr", "bin", target_sys)] + paths + new_env["PATH"] = ":".join(paths) + options['env'] = new_env cmd = Command(command, timeout=timeout, output_log=output_log, **options) cmd.run()