app: fix set_zephyr_base()
Commit e8080e9c3f
("manifest: simplify and fix get_projects()") caused a regression in
the west command line interface, which turns out to be due to a bug in
main.py. The fix itself seems fine.
The bug is in main.py's set_zephyr_base() function, where we search
for any project named or with path 'zephyr' like this:
projects = manifest.get_projects(['zephyr'])
This was always incorrect: when searching for a project by path,
we cannot make any assumptions about the current working directory.
This line of code happens to work if you are running west from the
workspace topdir, which is what we do in testing, but it fails if you
are somewhere else in the file system, e.g. in WEST_TOPDIR/zephyr.
We happened to get bizarrely lucky before this fix to get_projects(),
because prior to that fix, we were comparing
Path(THE_MANIFEST_REPOSITORY_PATH).resolve()
with
Path('zephyr').resolve()
in the get_projects() call from set_zephyr_base().
As long as THE_MANIFEST_REPOSITORY_PATH is 'zephyr' (which it is by
default when using the upstream zephyr repository as the manifest
repository), this comparison will always result in get_projects()
returning the ManifestProject no matter where you are on the file
system, since we're comparing the same things to each other.
But *with* that fix in manifest.py, we need to also fix main.py to
pass a fully resolved WEST_TOPDIR/zephyr path to get_projects() when
searching by path, since what we are trying to do is find a project
with either name 'zephyr' or path 'zephyr' inside the current
workspace.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
a95f530751
commit
c17e0b27a7
|
@ -700,11 +700,16 @@ def set_zephyr_base(args, manifest, topdir, config):
|
|||
zb_prefer = config.get('zephyr.base-prefer')
|
||||
rel_zb_config = config.get('zephyr.base')
|
||||
if rel_zb_config is None:
|
||||
# Try to find a project named 'zephyr', or with path
|
||||
# 'zephyr' inside the workspace.
|
||||
projects = None
|
||||
try:
|
||||
projects = manifest.get_projects(['zephyr'])
|
||||
projects = manifest.get_projects(['zephyr'], allow_paths=False)
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
projects = manifest.get_projects([Path(topdir) / 'zephyr'])
|
||||
except ValueError:
|
||||
pass
|
||||
if projects:
|
||||
zephyr = projects[0]
|
||||
config.set('zephyr.base', zephyr.path)
|
||||
|
|
Loading…
Reference in New Issue