Skip to content

Commit 33fbef5

Browse files
tejlmandnvlsianpu
authored andcommitted
cmake: scripts: now using ZEPHYR_BASE as local variable
This commit is a followup to the usage of `find_package(Zephyr ...)`. The zephyr/hello-world sample has been updated to use find_package. The assemble.py script now takes ZEPHYR_BASE as an argument, so it may be used from CMakeLists.txt files when ZEPHYR_BASE is not set in environment, and thus the Makefile sample has been adjusted accordingly. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 9b48d08 commit 33fbef5

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ assert_exists(MBEDTLS_ASN1_DIR)
6262
set(NRF_DIR "${MCUBOOT_DIR}/ext/nrf")
6363

6464
if(CONFIG_BOOT_USE_NRF_CC310_BL)
65-
set(NRFXLIB_DIR $ENV{ZEPHYR_BASE}/../nrfxlib)
65+
set(NRFXLIB_DIR ${ZEPHYR_BASE}/../nrfxlib)
6666
assert_exists(NRFXLIB_DIR)
6767
# Don't include this if we are using west
6868
add_subdirectory(${NRFXLIB_DIR} ${PROJECT_BINARY_DIR}/nrfxlib)

samples/zephyr/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ all: boot hello1 hello2
9292

9393
full.bin: boot hello1 hello2
9494
$(ASSEMBLE) -b $(BUILD_DIR_BOOT) \
95+
-z $(ZEPHYR_BASE) \
9596
-p signed-hello1.bin \
9697
-s signed-hello2.bin \
9798
-o full.bin

samples/zephyr/hello-world/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
cmake_minimum_required(VERSION 3.8)
1313

14-
# Standard Zephyr application boilerplate.
15-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
14+
# find_package(Zephyr) in order to load application boilerplate:
15+
# http://docs.zephyrproject.org/application/application.html
16+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1617
project(NONE)
1718

1819
# This string ends up getting printed in the device console

scripts/assemble.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
import os.path
2626
import sys
2727

28-
ZEPHYR_BASE = os.getenv("ZEPHYR_BASE")
29-
if not ZEPHYR_BASE:
30-
sys.exit("$ZEPHYR_BASE environment variable undefined")
31-
32-
sys.path.insert(0, os.path.join(ZEPHYR_BASE, "scripts", "dts"))
33-
import edtlib
34-
3528
def same_keys(a, b):
3629
"""Determine if the dicts a and b have the same keys in them"""
3730
for ak in a.keys():
@@ -109,15 +102,20 @@ def main():
109102
help='Signed image file for secondary image')
110103
parser.add_argument('-o', '--output', required=True,
111104
help='Filename to write full image to')
105+
parser.add_argument('-z', '--zephyr-base', required=True,
106+
help='Zephyr base containg the Zephyr repository')
112107

113108
args = parser.parse_args()
114109

110+
sys.path.insert(0, os.path.join(args.zephyr_base, "scripts", "dts"))
111+
import edtlib
112+
115113
# Extract board name from path
116114
board = os.path.split(os.path.split(args.bootdir)[0])[1]
117115

118116
dts_path = os.path.join(args.bootdir, "zephyr", board + ".dts.pre.tmp")
119117

120-
edt = edtlib.EDT(dts_path, [os.path.join(ZEPHYR_BASE, "dts", "bindings")],
118+
edt = edtlib.EDT(dts_path, [os.path.join(args.zephyr_base, "dts", "bindings")],
121119
warn_reg_unit_address_mismatch=False)
122120

123121
output = Assembly(args.output, args.bootdir, edt)

0 commit comments

Comments
 (0)