diff options
| -rw-r--r-- | meta/lib/oe/utils.py | 31 |
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 | ||
| 379 | def 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 | |||
| 376 | def host_gcc_version(d, taskcontextonly=False): | 407 | def host_gcc_version(d, taskcontextonly=False): |
| 377 | import re, subprocess | 408 | import re, subprocess |
| 378 | 409 | ||
