summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/utils.py')
-rw-r--r--meta/lib/oe/utils.py65
1 files changed, 13 insertions, 52 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 14a7d07ef0..779c5e593f 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -9,6 +9,8 @@ import multiprocessing
9import traceback 9import traceback
10import errno 10import errno
11 11
12import bb.parse
13
12def read_file(filename): 14def read_file(filename):
13 try: 15 try:
14 f = open( filename, "r" ) 16 f = open( filename, "r" )
@@ -265,6 +267,7 @@ def execute_pre_post_process(d, cmds):
265 bb.note("Executing %s ..." % cmd) 267 bb.note("Executing %s ..." % cmd)
266 bb.build.exec_func(cmd, d) 268 bb.build.exec_func(cmd, d)
267 269
270@bb.parse.vardepsexclude("BB_NUMBER_THREADS")
268def get_bb_number_threads(d): 271def get_bb_number_threads(d):
269 return int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) 272 return int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1)
270 273
@@ -316,7 +319,9 @@ def multiprocess_launch_mp(target, items, max_process, extraargs=None):
316 items = list(items) 319 items = list(items)
317 while (items and not errors) or launched: 320 while (items and not errors) or launched:
318 if not errors and items and len(launched) < max_process: 321 if not errors and items and len(launched) < max_process:
319 args = (items.pop(),) 322 args = items.pop()
323 if not type(args) is tuple:
324 args = (args,)
320 if extraargs is not None: 325 if extraargs is not None:
321 args = args + extraargs 326 args = args + extraargs
322 p = ProcessLaunch(target=target, args=args) 327 p = ProcessLaunch(target=target, args=args)
@@ -410,62 +415,31 @@ def format_pkg_list(pkg_dict, ret_format=None, pkgdata_dir=None):
410 return output_str 415 return output_str
411 416
412 417
413# Helper function to get the host compiler version 418# Helper function to get the host gcc version
414# Do not assume the compiler is gcc 419def get_host_gcc_version(d, taskcontextonly=False):
415def get_host_compiler_version(d, taskcontextonly=False):
416 import re, subprocess 420 import re, subprocess
417 421
418 if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1': 422 if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
419 return 423 return
420 424
421 compiler = d.getVar("BUILD_CC")
422 # Get rid of ccache since it is not present when parsing.
423 if compiler.startswith('ccache '):
424 compiler = compiler[7:]
425 try: 425 try:
426 env = os.environ.copy() 426 env = os.environ.copy()
427 # datastore PATH does not contain session PATH as set by environment-setup-... 427 # datastore PATH does not contain session PATH as set by environment-setup-...
428 # this breaks the install-buildtools use-case 428 # this breaks the install-buildtools use-case
429 # env["PATH"] = d.getVar("PATH") 429 # env["PATH"] = d.getVar("PATH")
430 output = subprocess.check_output("%s --version" % compiler, \ 430 output = subprocess.check_output("gcc --version", \
431 shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8") 431 shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
432 except subprocess.CalledProcessError as e: 432 except subprocess.CalledProcessError as e:
433 bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8"))) 433 bb.fatal("Error running gcc --version: %s" % (e.output.decode("utf-8")))
434 434
435 match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0]) 435 match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
436 if not match: 436 if not match:
437 bb.fatal("Can't get compiler version from %s --version output" % compiler) 437 bb.fatal("Can't get compiler version from gcc --version output")
438 438
439 version = match.group(1) 439 version = match.group(1)
440 return compiler, version 440 return version
441
442
443def host_gcc_version(d, taskcontextonly=False):
444 import re, subprocess
445
446 if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
447 return
448
449 compiler = d.getVar("BUILD_CC")
450 # Get rid of ccache since it is not present when parsing.
451 if compiler.startswith('ccache '):
452 compiler = compiler[7:]
453 try:
454 env = os.environ.copy()
455 env["PATH"] = d.getVar("PATH")
456 output = subprocess.check_output("%s --version" % compiler, \
457 shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
458 except subprocess.CalledProcessError as e:
459 bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8")))
460
461 match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
462 if not match:
463 bb.fatal("Can't get compiler version from %s --version output" % compiler)
464
465 version = match.group(1)
466 return "-%s" % version if version in ("4.8", "4.9") else ""
467
468 441
442@bb.parse.vardepsexclude("DEFAULTTUNE_MULTILIB_ORIGINAL", "OVERRIDES")
469def get_multilib_datastore(variant, d): 443def get_multilib_datastore(variant, d):
470 localdata = bb.data.createCopy(d) 444 localdata = bb.data.createCopy(d)
471 if variant: 445 if variant:
@@ -482,19 +456,6 @@ def get_multilib_datastore(variant, d):
482 localdata.setVar("MLPREFIX", "") 456 localdata.setVar("MLPREFIX", "")
483 return localdata 457 return localdata
484 458
485class ImageQAFailed(Exception):
486 def __init__(self, description, name=None, logfile=None):
487 self.description = description
488 self.name = name
489 self.logfile=logfile
490
491 def __str__(self):
492 msg = 'Function failed: %s' % self.name
493 if self.description:
494 msg = msg + ' (%s)' % self.description
495
496 return msg
497
498def sh_quote(string): 459def sh_quote(string):
499 import shlex 460 import shlex
500 return shlex.quote(string) 461 return shlex.quote(string)