From a74b9f1dcce170a54a73bb10c9be4d1e7e31dbf2 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 29 Jan 2019 09:14:30 -0700 Subject: [PATCH] bootstrapper: improve heuristic for --zephyr-base We're seeing warnings when people have ZEPHYR_BASE set to the "" they pass to "west init -l ". Avoid them exactly in the situation that is a zephyr repository by using the manifest directory as ZEPHYR_BASE. For upstream, that is correct anyway. Merge a couple of lines while here as a cosmetic improvement. Fixes: #167 Signed-off-by: Marti Bolivar --- src/west/_bootstrap/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/west/_bootstrap/main.py b/src/west/_bootstrap/main.py index 770f394..6b9b75e 100644 --- a/src/west/_bootstrap/main.py +++ b/src/west/_bootstrap/main.py @@ -224,8 +224,7 @@ to handle any resetting yourself. def initialize_west(args): '''Initialize a West installation in existing project.''' - manifest_dir = args.directory or os.getcwd() - manifest_dir = os.path.abspath(manifest_dir) + manifest_dir = os.path.abspath(args.directory or os.getcwd()) directory = os.path.dirname(manifest_dir) manifest_file = os.path.join(manifest_dir, 'west.yml') @@ -240,9 +239,14 @@ def initialize_west(args): # # Note: main west will try to discover zephyr base and fail, as it is # not fully initialized at this time. - # Thus a dummy zephyr_base is provided. + # + # The real fix is to eliminate post-init, merge the two mains, and + # have west init be a special case that doesn't set up + # ZEPHYR_BASE. For now, we assume the original argument (or cwd) + # is a Zephyr repository, since that's how people are using it in + # practice. os.chdir(directory) - cmd = ['--zephyr-base', directory, 'post-init', '--local', + cmd = ['--zephyr-base', manifest_dir, 'post-init', '--local', os.path.abspath(manifest_dir)] wrap(cmd)