From: "Tim Orling" <timothy.t.orling@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Cc: kai.kang@windriver.com, randy.macleod@windriver.com,
Tim Orling <timothy.t.orling@linux.intel.com>
Subject: [PATCH v2 4/6] lib/oe/utils.py: add get_host_compiler_version()
Date: Tue, 31 Mar 2020 13:03:04 -0700 [thread overview]
Message-ID: <20200331200306.36942-4-timothy.t.orling@linux.intel.com> (raw)
In-Reply-To: <20200331200306.36942-1-timothy.t.orling@linux.intel.com>
Add helper function to get the host compiler and version.
Do not assume compiler is gcc.
NOTE: cannot set env to d.getVar("PATH") as that does not contain
the session PATH which was set by environment-setup-... which
breaks the install-buildtools use-case
Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com>
---
meta/lib/oe/utils.py | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 9042b370f7..13f4271da0 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -373,6 +373,37 @@ def format_pkg_list(pkg_dict, ret_format=None):
return output_str
+
+# Helper function to get the host compiler version
+# Do not assume the compiler is gcc
+def get_host_compiler_version(d, taskcontextonly=False):
+ import re, subprocess
+
+ if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
+ return
+
+ compiler = d.getVar("BUILD_CC")
+ # Get rid of ccache since it is not present when parsing.
+ if compiler.startswith('ccache '):
+ compiler = compiler[7:]
+ try:
+ env = os.environ.copy()
+ # datastore PATH does not contain session PATH as set by environment-setup-...
+ # this breaks the install-buildtools use-case
+ # env["PATH"] = d.getVar("PATH")
+ output = subprocess.check_output("%s --version" % compiler, \
+ shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
+ except subprocess.CalledProcessError as e:
+ bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8")))
+
+ match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
+ if not match:
+ bb.fatal("Can't get compiler version from %s --version output" % compiler)
+
+ version = match.group(1)
+ return compiler, version
+
+
def host_gcc_version(d, taskcontextonly=False):
import re, subprocess
--
2.24.0
next prev parent reply other threads:[~2020-03-31 20:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 20:03 [PATCH v2 1/6] scripts/install-buildtools: improvements Tim Orling
2020-03-31 20:03 ` [PATCH v2 2/6] oe-buildenv-internal: python 3.5 as min version Tim Orling
2020-03-31 20:03 ` [PATCH v2 3/6] sanity.bbclass: recommend using install-buildtools Tim Orling
2020-03-31 20:03 ` Tim Orling [this message]
2020-03-31 20:03 ` [PATCH v2 5/6] sanity.bbclass: add test for gcc < 5.0 Tim Orling
2020-03-31 20:03 ` [PATCH v2 6/6] install-buildtools: bump default to yocto-3.1_M3, fixes Tim Orling
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=20200331200306.36942-4-timothy.t.orling@linux.intel.com \
--to=timothy.t.orling@linux.intel.com \
--cc=kai.kang@windriver.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=randy.macleod@windriver.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox