Files
poky/meta/files/ext-sdk-prepare.py
Paul Eggleton a702c68c5b classes/populate_sdk_ext: eliminate double execution on install
Use the new BB_SETSCENE_ENFORCE functionality to avoid having to run
bitbake twice on installing the extensible SDK - we can now do it all in
one invocation which not only takes less time, but we should also get
more meaningful errors for some types of failure, in particular where
downloading from an sstate mirror fails.

One result of this change is that you get the errors printed on the
console during normal output rather than this going to the
preparing_build_system.log file first. In OE-Core revision
227d2cbf9e0b8c35fa6644e3d72e0699db9607fa, we changed to always print the
contents of preparing_build_system.log on failure, but now at least the
error contents of that log is duplicated. Besides, I intentionally
didn't print out the contents of that log during normal usage because
it's quite verbose - the bug that we were attempting to fix was about
not getting this information when seeing failures in the automated
tests, thus I've moved printing the log to the test handling code
instead.

Part of the implementation of [YOCTO #9367].

(From OE-Core rev: e1390c1ef85862b91b067ab24f3c06ca506155ad)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-07-08 09:57:23 +01:00

54 lines
1.3 KiB
Python

#!/usr/bin/env python
# Prepare the build system within the extensible SDK
import sys
import os
import subprocess
def exec_watch(cmd, **options):
"""Run program with stdout shown on sys.stdout"""
if isinstance(cmd, str) and not "shell" in options:
options["shell"] = True
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **options
)
buf = ''
while True:
out = process.stdout.read(1)
if out:
sys.stdout.write(out)
sys.stdout.flush()
buf += out
elif out == '' and process.poll() != None:
break
return process.returncode, buf
def main():
if len(sys.argv) < 2:
sdk_targets = []
else:
sdk_targets = ' '.join(sys.argv[1:]).split()
if not sdk_targets:
# Just do a parse so the cache is primed
ret, _ = exec_watch('bitbake -p')
return ret
print('Preparing SDK for %s...' % ', '.join(sdk_targets))
ret, out = exec_watch('BB_SETSCENE_ENFORCE=1 bitbake %s' % ' '.join(sdk_targets))
if ret:
return ret
if __name__ == "__main__":
try:
ret = main()
except Exception:
ret = 1
import traceback
traceback.print_exc()
sys.exit(ret)