summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorTim Orling <timothy.t.orling@linux.intel.com>2020-03-31 13:03:04 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-01 11:44:24 +0100
commitd5d634f682d58f50bf8f8f4502ac00dddd2c048d (patch)
treee53c031ee296cb2f7528b87145edebb49a39349a /meta/lib/oe
parent8c1aeb60c8a682be059c8615152cf1e96f8b1cb5 (diff)
downloadpoky-d5d634f682d58f50bf8f8f4502ac00dddd2c048d.tar.gz
lib/oe/utils.py: add get_host_compiler_version()
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 (From OE-Core rev: 88712929354ff9c876bb1e48b6f15c33af5f2bbc) Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/utils.py31
1 files changed, 31 insertions, 0 deletions
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):
373 373
374 return output_str 374 return output_str
375 375
376
377# Helper function to get the host compiler version
378# Do not assume the compiler is gcc
379def get_host_compiler_version(d, taskcontextonly=False):
380 import re, subprocess
381
382 if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
383 return
384
385 compiler = d.getVar("BUILD_CC")
386 # Get rid of ccache since it is not present when parsing.
387 if compiler.startswith('ccache '):
388 compiler = compiler[7:]
389 try:
390 env = os.environ.copy()
391 # datastore PATH does not contain session PATH as set by environment-setup-...
392 # this breaks the install-buildtools use-case
393 # env["PATH"] = d.getVar("PATH")
394 output = subprocess.check_output("%s --version" % compiler, \
395 shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
396 except subprocess.CalledProcessError as e:
397 bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8")))
398
399 match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
400 if not match:
401 bb.fatal("Can't get compiler version from %s --version output" % compiler)
402
403 version = match.group(1)
404 return compiler, version
405
406
376def host_gcc_version(d, taskcontextonly=False): 407def host_gcc_version(d, taskcontextonly=False):
377 import re, subprocess 408 import re, subprocess
378 409