diff options
Diffstat (limited to 'scripts/oe-setup-build')
| -rwxr-xr-x | scripts/oe-setup-build | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/scripts/oe-setup-build b/scripts/oe-setup-build index 5364f2b481..edbcd48355 100755 --- a/scripts/oe-setup-build +++ b/scripts/oe-setup-build | |||
| @@ -18,8 +18,7 @@ def makebuildpath(topdir, template): | |||
| 18 | 18 | ||
| 19 | def discover_templates(layers_file): | 19 | def discover_templates(layers_file): |
| 20 | if not os.path.exists(layers_file): | 20 | if not os.path.exists(layers_file): |
| 21 | print("List of layers {} does not exist; were the layers set up using the setup-layers script?".format(layers_file)) | 21 | raise Exception("List of layers {} does not exist; were the layers set up using the setup-layers script or bitbake-setup tool?".format(layers_file)) |
| 22 | return None | ||
| 23 | 22 | ||
| 24 | templates = [] | 23 | templates = [] |
| 25 | layers_list = json.load(open(layers_file))["layers"] | 24 | layers_list = json.load(open(layers_file))["layers"] |
| @@ -77,8 +76,7 @@ def find_template(template_name, templates): | |||
| 77 | for t in templates: | 76 | for t in templates: |
| 78 | if t["templatename"] == template_name: | 77 | if t["templatename"] == template_name: |
| 79 | return t | 78 | return t |
| 80 | print("Configuration {} is not one of {}, please try again.".format(tempalte_name, [t["templatename"] for t in templates])) | 79 | raise Exception("Configuration {} is not one of {}, please try again.".format(template_name, [t["templatename"] for t in templates])) |
| 81 | return None | ||
| 82 | 80 | ||
| 83 | def setup_build_env(args): | 81 | def setup_build_env(args): |
| 84 | templates = discover_templates(args.layerlist) | 82 | templates = discover_templates(args.layerlist) |
| @@ -91,11 +89,20 @@ def setup_build_env(args): | |||
| 91 | builddir = args.b if args.b else template["buildpath"] | 89 | builddir = args.b if args.b else template["buildpath"] |
| 92 | no_shell = args.no_shell | 90 | no_shell = args.no_shell |
| 93 | coredir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) | 91 | coredir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) |
| 94 | cmd = "TEMPLATECONF={} . {} {}".format(template["templatepath"], os.path.join(coredir, 'oe-init-build-env'), builddir) | 92 | cmd_base = "cd {}\nset {}\n. ./oe-init-build-env\n".format(coredir, os.path.abspath(builddir)) |
| 93 | |||
| 94 | initbuild = os.path.join(builddir, 'init-build-env') | ||
| 95 | if not os.path.exists(initbuild): | ||
| 96 | os.makedirs(builddir, exist_ok=True) | ||
| 97 | with open(initbuild, 'w') as f: | ||
| 98 | f.write(cmd_base) | ||
| 99 | print("\nRun '. {}' to initialize the build in a current shell session.\n".format(initbuild)) | ||
| 100 | |||
| 101 | cmd = "TEMPLATECONF={} {}".format(template["templatepath"], cmd_base) | ||
| 95 | if not no_shell: | 102 | if not no_shell: |
| 96 | cmd = cmd + " && {}".format(os.environ['SHELL']) | 103 | cmd = cmd + " && {}".format(os.environ.get('SHELL','bash')) |
| 97 | print("Running:", cmd) | 104 | print("Running:", cmd) |
| 98 | subprocess.run(cmd, shell=True, executable=os.environ['SHELL']) | 105 | subprocess.run(cmd, shell=True, executable=os.environ.get('SHELL','bash')) |
| 99 | 106 | ||
| 100 | parser = argparse.ArgumentParser(description="A script that discovers available build configurations and sets up a build environment based on one of them. Run without arguments to choose one interactively.") | 107 | parser = argparse.ArgumentParser(description="A script that discovers available build configurations and sets up a build environment based on one of them. Run without arguments to choose one interactively.") |
| 101 | parser.add_argument("--layerlist", default=defaultlayers(), help='Where to look for available layers (as written out by setup-layers script) (default is {}).'.format(defaultlayers())) | 108 | parser.add_argument("--layerlist", default=defaultlayers(), help='Where to look for available layers (as written out by setup-layers script) (default is {}).'.format(defaultlayers())) |
