diff options
-rw-r--r-- | meta/classes/populate_sdk_ext.bbclass | 5 | ||||
-rw-r--r-- | meta/files/ext-sdk-prepare.py | 92 | ||||
-rw-r--r-- | meta/files/ext-sdk-prepare.sh | 8 |
3 files changed, 94 insertions, 11 deletions
diff --git a/meta/classes/populate_sdk_ext.bbclass b/meta/classes/populate_sdk_ext.bbclass index 69e13abc73..4d8d2a6257 100644 --- a/meta/classes/populate_sdk_ext.bbclass +++ b/meta/classes/populate_sdk_ext.bbclass | |||
@@ -224,7 +224,7 @@ install_tools() { | |||
224 | 224 | ||
225 | install ${SDK_DEPLOY}/${BUILD_ARCH}-nativesdk-libc.tar.bz2 ${SDK_OUTPUT}/${SDKPATH} | 225 | install ${SDK_DEPLOY}/${BUILD_ARCH}-nativesdk-libc.tar.bz2 ${SDK_OUTPUT}/${SDKPATH} |
226 | 226 | ||
227 | install -m 0755 ${COREBASE}/meta/files/ext-sdk-prepare.sh ${SDK_OUTPUT}/${SDKPATH} | 227 | install -m 0644 ${COREBASE}/meta/files/ext-sdk-prepare.py ${SDK_OUTPUT}/${SDKPATH} |
228 | } | 228 | } |
229 | 229 | ||
230 | # Since bitbake won't run as root it doesn't make sense to try and install | 230 | # Since bitbake won't run as root it doesn't make sense to try and install |
@@ -270,9 +270,8 @@ sdk_ext_postinst() { | |||
270 | # current working directory when first ran, nor will it set $1 when | 270 | # current working directory when first ran, nor will it set $1 when |
271 | # sourcing a script. That is why this has to look so ugly. | 271 | # sourcing a script. That is why this has to look so ugly. |
272 | LOGFILE="$target_sdk_dir/preparing_build_system.log" | 272 | LOGFILE="$target_sdk_dir/preparing_build_system.log" |
273 | sh -c ". buildtools/environment-setup* > $LOGFILE && cd $target_sdk_dir/`dirname ${oe_init_build_env_path}` && set $target_sdk_dir && . $target_sdk_dir/${oe_init_build_env_path} $target_sdk_dir >> $LOGFILE && $target_sdk_dir/ext-sdk-prepare.sh $target_sdk_dir '${SDK_TARGETS}' >> $LOGFILE 2>&1" || { echo "ERROR: SDK preparation failed: see $LOGFILE"; echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; } | 273 | sh -c ". buildtools/environment-setup* > $LOGFILE && cd $target_sdk_dir/`dirname ${oe_init_build_env_path}` && set $target_sdk_dir && . $target_sdk_dir/${oe_init_build_env_path} $target_sdk_dir >> $LOGFILE && python $target_sdk_dir/ext-sdk-prepare.py '${SDK_TARGETS}' >> $LOGFILE 2>&1" || { echo "ERROR: SDK preparation failed: see $LOGFILE"; echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; } |
274 | fi | 274 | fi |
275 | rm -f $target_sdk_dir/ext-sdk-prepare.sh | ||
276 | echo done | 275 | echo done |
277 | } | 276 | } |
278 | 277 | ||
diff --git a/meta/files/ext-sdk-prepare.py b/meta/files/ext-sdk-prepare.py new file mode 100644 index 0000000000..143e0feba0 --- /dev/null +++ b/meta/files/ext-sdk-prepare.py | |||
@@ -0,0 +1,92 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | # Prepare the build system within the extensible SDK | ||
4 | |||
5 | import sys | ||
6 | import os | ||
7 | import subprocess | ||
8 | |||
9 | def exec_watch(cmd, **options): | ||
10 | """Run program with stdout shown on sys.stdout""" | ||
11 | if isinstance(cmd, basestring) and not "shell" in options: | ||
12 | options["shell"] = True | ||
13 | |||
14 | process = subprocess.Popen( | ||
15 | cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **options | ||
16 | ) | ||
17 | |||
18 | buf = '' | ||
19 | while True: | ||
20 | out = process.stdout.read(1) | ||
21 | if out: | ||
22 | sys.stdout.write(out) | ||
23 | sys.stdout.flush() | ||
24 | buf += out | ||
25 | elif out == '' and process.poll() != None: | ||
26 | break | ||
27 | |||
28 | return process.returncode, buf | ||
29 | |||
30 | |||
31 | def main(): | ||
32 | if len(sys.argv) < 2: | ||
33 | print('Please specify target to prepare with') | ||
34 | return 1 | ||
35 | |||
36 | sdk_targets = ' '.join(sys.argv[1:]).split() | ||
37 | print('Preparing SDK for %s...' % ', '.join(sdk_targets)) | ||
38 | |||
39 | ret, out = exec_watch('bitbake %s --setscene-only' % ' '.join(sdk_targets)) | ||
40 | if ret: | ||
41 | return ret | ||
42 | |||
43 | targetlist = [] | ||
44 | for target in sdk_targets: | ||
45 | if ':' in target: | ||
46 | target = target.split(':')[0] | ||
47 | if not target in targetlist: | ||
48 | targetlist.append(target) | ||
49 | |||
50 | recipes = [] | ||
51 | for target in targetlist: | ||
52 | try: | ||
53 | out = subprocess.check_output(('bitbake -e %s' % target).split(), stderr=subprocess.STDOUT) | ||
54 | for line in out.splitlines(): | ||
55 | if line.startswith('FILE='): | ||
56 | splitval = line.rstrip().split('=') | ||
57 | if len(splitval) > 1: | ||
58 | recipes.append(splitval[1].strip('"')) | ||
59 | break | ||
60 | except subprocess.CalledProcessError as e: | ||
61 | print('ERROR: Failed to get recipe for target %s:\n%s' % (target, e.output)) | ||
62 | return 1 | ||
63 | |||
64 | try: | ||
65 | out = subprocess.check_output('bitbake %s -n' % ' '.join(sdk_targets), stderr=subprocess.STDOUT, shell=True) | ||
66 | unexpected = [] | ||
67 | for line in out.splitlines(): | ||
68 | if 'Running task' in line: | ||
69 | for recipe in recipes: | ||
70 | if recipe in line: | ||
71 | break | ||
72 | else: | ||
73 | line = line.split('Running', 1)[-1] | ||
74 | unexpected.append(line.rstrip()) | ||
75 | except subprocess.CalledProcessError as e: | ||
76 | print('ERROR: Failed to execute dry-run:\n%s' % e.output) | ||
77 | return 1 | ||
78 | |||
79 | if unexpected: | ||
80 | print('ERROR: Unexpected tasks left over to be executed:') | ||
81 | for line in unexpected: | ||
82 | print(' ' + line) | ||
83 | return 1 | ||
84 | |||
85 | if __name__ == "__main__": | ||
86 | try: | ||
87 | ret = main() | ||
88 | except Exception: | ||
89 | ret = 1 | ||
90 | import traceback | ||
91 | traceback.print_exc(5) | ||
92 | sys.exit(ret) | ||
diff --git a/meta/files/ext-sdk-prepare.sh b/meta/files/ext-sdk-prepare.sh deleted file mode 100644 index b3f5d93615..0000000000 --- a/meta/files/ext-sdk-prepare.sh +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Prepare the build system within the extensible SDK | ||
4 | |||
5 | target_sdk_dir="$1" | ||
6 | sdk_targets="$2" | ||
7 | |||
8 | bitbake $sdk_targets --setscene-only || exit 1 | ||