scripts: west-commands: Updates needed when removing ZEPHYR_BASE env
This commit includes the following fixes in order to remove environment
setting of ZEPHYR_BASE is west extension commands.
- Build command
west build --pristine will now use the ZEPHYR_BASE variable found
in CMakeCache.txt in the build folder.
This ensures that the pristine command is executed from the same
Zephyr that was used for compilation.
- Board command
The west boards command no longer sets Zephyr base before invoking
cmake -P cmake/boards.cmake
Instead boards.cmake uses find_package(Zephyr) to ensure consistent
behavior with Zephyr samples, so that the detection of Zephyr base is
uniform across CMake commands.
It also changes BOARD_ROOT_SPACE_SEPARATED to BOARD_ROOT in order to
be consistent with existing user documentation.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
diff --git a/scripts/west_commands/zephyr_ext_common.py b/scripts/west_commands/zephyr_ext_common.py
index fe81f0e..233044c 100644
--- a/scripts/west_commands/zephyr_ext_common.py
+++ b/scripts/west_commands/zephyr_ext_common.py
@@ -16,6 +16,14 @@
from runners.core import RunnerConfig
+# This relies on this file being zephyr/scripts/foo/bar.py.
+# If you move this file, you'll break it, so be careful.
+THIS_ZEPHYR = Path(__file__).parent.parent.parent
+ZEPHYR_BASE = Path(os.environ.get('ZEPHYR_BASE', THIS_ZEPHYR))
+
+# FIXME we need a nicer way to handle imports from scripts and cmake than this.
+ZEPHYR_SCRIPTS = ZEPHYR_BASE / 'scripts'
+ZEPHYR_CMAKE = ZEPHYR_BASE / 'cmake'
class Forceable(WestCommand):
'''WestCommand subclass for commands with a --force option.'''
@@ -55,12 +63,3 @@
elf_file, hex_file, bin_file,
gdb=gdb, openocd=openocd,
openocd_search=openocd_search)
-
-# FIXME we should think of a nicer way to manage sys.path
-# for shared Zephyr code.
-def zephyr_scripts_path():
- # This relies on this file being zephyr/scripts/foo/bar.py.
- zephyr_base = Path(os.environ.get('ZEPHYR_BASE',
- Path(__file__).parent.parent.parent))
-
- return str(zephyr_base / 'scripts')