summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2022-08-05 15:58:49 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-05 17:21:41 +0000
commitab36e4ff4322b9c3bcdb59ecaf19e055b1365545 (patch)
treeb44de7845c0e9d0a096359f403fe9c560fad6c79
parent8c95f2bd1e4ec646ca5c39fe625c5e9701b4245a (diff)
downloadchrome-ec-ab36e4ff4322b9c3bcdb59ecaf19e055b1365545.tar.gz
Revert "zephyr: Make ZEPHYR_BASE not an environment variable"
This reverts commit d16be8f98d81d7e589935d1c6c78ec4430a8960d. Reason for revert: suspected at fault for b/241489955 (suspect we're stripping ccache environment variables in ninja call) BUG=b:241489955 TEST=CQ Original change's description: > zephyr: Make ZEPHYR_BASE not an environment variable > > To minimize the amount of environment variable dependency we have, move > ZEPHYR_BASE (used to find the "Zephyr" CMake package) from an > environment variable to a CMake definition. > > This makes our only required environment variable PATH, so we can do a > complete environment scrub for all commands executed. > > BUG=b:239619222 > BRANCH=none > TEST=zmake testall > > Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> > Change-Id: Ie34a9e1f49177649cf0e54c95d73b41bd1b94992 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3811715 > Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Bug: b:239619222 Change-Id: I9cfdb04fc61d013ba670049c5dbbeeca7de4893c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3813042 Auto-Submit: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Tested-by: Bob Moragues <moragues@chromium.org>
-rw-r--r--docs/zephyr/project_config.md2
-rwxr-xr-xutil/twister_launcher.py2
-rw-r--r--zephyr/projects/brya/CMakeLists.txt2
-rw-r--r--zephyr/projects/corsola/CMakeLists.txt2
-rw-r--r--zephyr/projects/herobrine/CMakeLists.txt2
-rw-r--r--zephyr/projects/intelrvp/CMakeLists.txt2
-rw-r--r--zephyr/projects/it8xxx2_evb/CMakeLists.txt2
-rw-r--r--zephyr/projects/minimal/CMakeLists.txt2
-rw-r--r--zephyr/projects/nissa/CMakeLists.txt2
-rw-r--r--zephyr/projects/npcx_evb/npcx7/CMakeLists.txt2
-rw-r--r--zephyr/projects/npcx_evb/npcx9/CMakeLists.txt2
-rw-r--r--zephyr/projects/rex/CMakeLists.txt2
-rw-r--r--zephyr/projects/skyrim/CMakeLists.txt2
-rw-r--r--zephyr/projects/trogdor/lazor/CMakeLists.txt2
-rw-r--r--zephyr/test/accel_cal/CMakeLists.txt2
-rw-r--r--zephyr/test/ap_power/CMakeLists.txt2
-rw-r--r--zephyr/test/base32/CMakeLists.txt2
-rw-r--r--zephyr/test/crc/CMakeLists.txt2
-rw-r--r--zephyr/test/drivers/CMakeLists.txt2
-rw-r--r--zephyr/test/ec_app/CMakeLists.txt2
-rw-r--r--zephyr/test/hooks/CMakeLists.txt2
-rw-r--r--zephyr/test/i2c/CMakeLists.txt2
-rw-r--r--zephyr/test/i2c_dts/CMakeLists.txt2
-rw-r--r--zephyr/test/math/CMakeLists.txt2
-rw-r--r--zephyr/test/system/CMakeLists.txt2
-rw-r--r--zephyr/test/tasks/CMakeLists.txt4
-rw-r--r--zephyr/zmake/tests/test_build_config.py22
-rw-r--r--zephyr/zmake/tests/test_toolchains.py6
-rw-r--r--zephyr/zmake/zmake/build_config.py14
-rw-r--r--zephyr/zmake/zmake/jobserver.py5
-rw-r--r--zephyr/zmake/zmake/toolchains.py5
-rw-r--r--zephyr/zmake/zmake/zmake.py5
32 files changed, 73 insertions, 38 deletions
diff --git a/docs/zephyr/project_config.md b/docs/zephyr/project_config.md
index 6e1346b0fa..f12d47ba36 100644
--- a/docs/zephyr/project_config.md
+++ b/docs/zephyr/project_config.md
@@ -112,7 +112,7 @@ This file, should at minimum contain the following:
``` cmake
cmake_minimum_required(VERSION 3.20.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ec)
```
diff --git a/util/twister_launcher.py b/util/twister_launcher.py
index a78a0dd534..cd21b1e39e 100755
--- a/util/twister_launcher.py
+++ b/util/twister_launcher.py
@@ -72,6 +72,7 @@ def main():
twister_env = dict(os.environ)
twister_env.update(
{
+ "ZEPHYR_BASE": str(zephyr_base),
"TOOLCHAIN_ROOT": str(ec_base / "zephyr"),
"ZEPHYR_TOOLCHAIN_VARIANT": "llvm",
}
@@ -83,7 +84,6 @@ def main():
"--ninja",
f"-x=DTS_ROOT={str( ec_base / 'zephyr')}",
f"-x=SYSCALL_INCLUDE_DIRS={str(ec_base / 'zephyr' / 'include' / 'drivers')}",
- f"-x=ZEPHYR_BASE={zephyr_base}",
f"-x=ZEPHYR_MODULES={';'.join([str(p) for p in zephyr_modules])}",
"--gcov-tool",
ec_base / "util" / "llvm-gcov.sh",
diff --git a/zephyr/projects/brya/CMakeLists.txt b/zephyr/projects/brya/CMakeLists.txt
index a35978fc63..0cb61eb838 100644
--- a/zephyr/projects/brya/CMakeLists.txt
+++ b/zephyr/projects/brya/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(brya)
set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/brya" CACHE PATH
diff --git a/zephyr/projects/corsola/CMakeLists.txt b/zephyr/projects/corsola/CMakeLists.txt
index d32e5a2428..206916cba0 100644
--- a/zephyr/projects/corsola/CMakeLists.txt
+++ b/zephyr/projects/corsola/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
cros_ec_library_include_directories(include)
diff --git a/zephyr/projects/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/CMakeLists.txt
index 7906cbe01b..c472083e4e 100644
--- a/zephyr/projects/herobrine/CMakeLists.txt
+++ b/zephyr/projects/herobrine/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
cros_ec_library_include_directories(include)
diff --git a/zephyr/projects/intelrvp/CMakeLists.txt b/zephyr/projects/intelrvp/CMakeLists.txt
index 1a8a39d9ae..9abde95f34 100644
--- a/zephyr/projects/intelrvp/CMakeLists.txt
+++ b/zephyr/projects/intelrvp/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(intelrvp)
cros_ec_library_include_directories(include)
diff --git a/zephyr/projects/it8xxx2_evb/CMakeLists.txt b/zephyr/projects/it8xxx2_evb/CMakeLists.txt
index ca8344aeec..dc2eb449b0 100644
--- a/zephyr/projects/it8xxx2_evb/CMakeLists.txt
+++ b/zephyr/projects/it8xxx2_evb/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(it8xxx2_evb)
# Include board specific header files
diff --git a/zephyr/projects/minimal/CMakeLists.txt b/zephyr/projects/minimal/CMakeLists.txt
index bb61a7dcd3..8a0349bb24 100644
--- a/zephyr/projects/minimal/CMakeLists.txt
+++ b/zephyr/projects/minimal/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.20.5)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ec)
zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
diff --git a/zephyr/projects/nissa/CMakeLists.txt b/zephyr/projects/nissa/CMakeLists.txt
index 758f059a44..ebaa902ab3 100644
--- a/zephyr/projects/nissa/CMakeLists.txt
+++ b/zephyr/projects/nissa/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
zephyr_include_directories(include)
zephyr_library_sources("src/common.c")
diff --git a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt b/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt
index 7e3264944f..a61ddf6755 100644
--- a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt
+++ b/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(npcx7)
zephyr_include_directories(include)
diff --git a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt b/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt
index 3a7d331885..a81ae87820 100644
--- a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt
+++ b/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(npcx9)
zephyr_include_directories(include)
diff --git a/zephyr/projects/rex/CMakeLists.txt b/zephyr/projects/rex/CMakeLists.txt
index 9f2264a629..469d8c918c 100644
--- a/zephyr/projects/rex/CMakeLists.txt
+++ b/zephyr/projects/rex/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.20.5)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(rex)
zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
diff --git a/zephyr/projects/skyrim/CMakeLists.txt b/zephyr/projects/skyrim/CMakeLists.txt
index 74197d1373..79a1c72c94 100644
--- a/zephyr/projects/skyrim/CMakeLists.txt
+++ b/zephyr/projects/skyrim/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(skyrim)
cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include)
diff --git a/zephyr/projects/trogdor/lazor/CMakeLists.txt b/zephyr/projects/trogdor/lazor/CMakeLists.txt
index a27c4d09ab..47285c66eb 100644
--- a/zephyr/projects/trogdor/lazor/CMakeLists.txt
+++ b/zephyr/projects/trogdor/lazor/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(lazor)
cros_ec_library_include_directories(include)
diff --git a/zephyr/test/accel_cal/CMakeLists.txt b/zephyr/test/accel_cal/CMakeLists.txt
index 31d8dcdfb6..14fd70e01a 100644
--- a/zephyr/test/accel_cal/CMakeLists.txt
+++ b/zephyr/test/accel_cal/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(accel_cal)
# Ensure that we get the definitions from test_config.h
diff --git a/zephyr/test/ap_power/CMakeLists.txt b/zephyr/test/ap_power/CMakeLists.txt
index 80f7556402..523db95ede 100644
--- a/zephyr/test/ap_power/CMakeLists.txt
+++ b/zephyr/test/ap_power/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ap_power)
# Include the local test directory for shimmed_test_tasks.h
diff --git a/zephyr/test/base32/CMakeLists.txt b/zephyr/test/base32/CMakeLists.txt
index d3b05b1e9d..674ad0d244 100644
--- a/zephyr/test/base32/CMakeLists.txt
+++ b/zephyr/test/base32/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(base32)
target_sources(app PRIVATE "${PLATFORM_EC}/test/base32.c")
diff --git a/zephyr/test/crc/CMakeLists.txt b/zephyr/test/crc/CMakeLists.txt
index aaf0a6a0f1..0b46729578 100644
--- a/zephyr/test/crc/CMakeLists.txt
+++ b/zephyr/test/crc/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(crc)
# Include the test source and the file under test
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt
index 37353b59f8..81b43bf6d2 100644
--- a/zephyr/test/drivers/CMakeLists.txt
+++ b/zephyr/test/drivers/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(drivers)
add_subdirectory(common)
diff --git a/zephyr/test/ec_app/CMakeLists.txt b/zephyr/test/ec_app/CMakeLists.txt
index cdcf9d1482..8ee9a554a7 100644
--- a/zephyr/test/ec_app/CMakeLists.txt
+++ b/zephyr/test/ec_app/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ec_app)
FILE(GLOB app_sources src/*.c)
diff --git a/zephyr/test/hooks/CMakeLists.txt b/zephyr/test/hooks/CMakeLists.txt
index f19d93644e..81ff57d69d 100644
--- a/zephyr/test/hooks/CMakeLists.txt
+++ b/zephyr/test/hooks/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hooks)
target_sources(app PRIVATE hooks.c)
diff --git a/zephyr/test/i2c/CMakeLists.txt b/zephyr/test/i2c/CMakeLists.txt
index 4fa96d0bad..214177013f 100644
--- a/zephyr/test/i2c/CMakeLists.txt
+++ b/zephyr/test/i2c/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(i2c)
target_sources(app PRIVATE src/main.c)
diff --git a/zephyr/test/i2c_dts/CMakeLists.txt b/zephyr/test/i2c_dts/CMakeLists.txt
index 6ff71d72fb..eea2834af1 100644
--- a/zephyr/test/i2c_dts/CMakeLists.txt
+++ b/zephyr/test/i2c_dts/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(i2c_test)
FILE(GLOB app_sources src/*.c)
diff --git a/zephyr/test/math/CMakeLists.txt b/zephyr/test/math/CMakeLists.txt
index dd78d41849..c540ece71d 100644
--- a/zephyr/test/math/CMakeLists.txt
+++ b/zephyr/test/math/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(math)
target_sources(app PRIVATE ${PLATFORM_EC}/common/math_util.c)
diff --git a/zephyr/test/system/CMakeLists.txt b/zephyr/test/system/CMakeLists.txt
index 2113b3a9cf..f91786841e 100644
--- a/zephyr/test/system/CMakeLists.txt
+++ b/zephyr/test/system/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(system_test)
target_sources(app PRIVATE test_system.c
diff --git a/zephyr/test/tasks/CMakeLists.txt b/zephyr/test/tasks/CMakeLists.txt
index f522683cab..f5ea76e67e 100644
--- a/zephyr/test/tasks/CMakeLists.txt
+++ b/zephyr/test/tasks/CMakeLists.txt
@@ -3,7 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(tasks)
# Include the local test directory for shimmed_test_tasks.h
@@ -11,4 +11,4 @@ zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
target_sources(app PRIVATE
main.c
- "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/tasks.c")
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/tasks.c") \ No newline at end of file
diff --git a/zephyr/zmake/tests/test_build_config.py b/zephyr/zmake/tests/test_build_config.py
index 043c4e5539..ac73432e88 100644
--- a/zephyr/zmake/tests/test_build_config.py
+++ b/zephyr/zmake/tests/test_build_config.py
@@ -35,13 +35,17 @@ config_dicts_at_least_one_entry = st.dictionaries(
build_configs = st.builds(
BuildConfig,
+ environ_defs=config_dicts,
cmake_defs=config_dicts,
kconfig_defs=config_dicts,
kconfig_files=st.lists(paths),
)
-build_configs_no_kconfig = st.builds(BuildConfig, cmake_defs=config_dicts)
+build_configs_no_kconfig = st.builds(
+ BuildConfig, environ_defs=config_dicts, cmake_defs=config_dicts
+)
build_configs_with_at_least_one_kconfig = st.builds(
BuildConfig,
+ environ_defs=config_dicts,
cmake_defs=config_dicts,
kconfig_defs=config_dicts_at_least_one_entry,
)
@@ -65,16 +69,19 @@ def test_merge(coins, combined):
return left, right
# Split the original config into two
+ env1, env2 = split(combined.environ_defs.items())
cmake1, cmake2 = split(combined.cmake_defs.items())
kconf1, kconf2 = split(combined.kconfig_defs.items())
files1, files2 = split(combined.kconfig_files)
config1 = BuildConfig(
+ environ_defs=dict(env1),
cmake_defs=dict(cmake1),
kconfig_defs=dict(kconf1),
kconfig_files=files1,
)
config2 = BuildConfig(
+ environ_defs=dict(env2),
cmake_defs=dict(cmake2),
kconfig_defs=dict(kconf2),
kconfig_files=files2,
@@ -84,6 +91,7 @@ def test_merge(coins, combined):
merged = config1 | config2
# Assert that the merged split configs is the original config
+ assert merged.environ_defs == combined.environ_defs
assert merged.cmake_defs == combined.cmake_defs
assert merged.kconfig_defs == combined.kconfig_defs
assert set(merged.kconfig_files) == set(combined.kconfig_files)
@@ -149,6 +157,7 @@ def test_popen_cmake_no_kconfig(conf: BuildConfig, project_dir, build_dir):
_, cmake_defs = parse_cmake_args(job_client.captured_argv)
assert cmake_defs == conf.cmake_defs
+ assert job_client.captured_env == conf.environ_defs
@hypothesis.given(build_configs_with_at_least_one_kconfig, paths, paths)
@@ -194,6 +203,7 @@ def test_popen_cmake_kconfig(conf: BuildConfig, project_dir, build_dir):
kconfig_files = set()
assert cmake_defs == conf.cmake_defs
+ assert job_client.captured_env == conf.environ_defs
assert kconfig_files == expected_kconfig_files
kconfig_defs = util.read_kconfig_file(temp_path)
@@ -221,6 +231,10 @@ def test_build_config_json_stability(fake_kconfig_files):
build configs.
"""
config_a = BuildConfig(
+ environ_defs={
+ "A": "B",
+ "B": "C",
+ },
cmake_defs={
"Z": "Y",
"X": "W",
@@ -234,6 +248,10 @@ def test_build_config_json_stability(fake_kconfig_files):
# Dict ordering is intentionally reversed in b.
config_b = BuildConfig(
+ environ_defs={
+ "B": "C",
+ "A": "B",
+ },
cmake_defs={
"X": "W",
"Z": "Y",
@@ -253,7 +271,7 @@ def test_build_config_json_inequality():
representation.
"""
config_a = BuildConfig(cmake_defs={"A": "B"})
- config_b = BuildConfig(kconfig_defs={"CONFIG_A": "y"})
+ config_b = BuildConfig(environ_defs={"A": "B"})
assert config_a.as_json() != config_b.as_json()
diff --git a/zephyr/zmake/tests/test_toolchains.py b/zephyr/zmake/tests/test_toolchains.py
index b9efc52eb2..f778bedf87 100644
--- a/zephyr/zmake/tests/test_toolchains.py
+++ b/zephyr/zmake/tests/test_toolchains.py
@@ -137,6 +137,9 @@ def test_zephyr(fake_project: project.Project, zephyr_exists, no_environ):
"ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
"ZEPHYR_SDK_INSTALL_DIR": str(pathlib.Path("/opt/zephyr-sdk")),
}
+ assert config.environ_defs == {
+ "ZEPHYR_SDK_INSTALL_DIR": str(pathlib.Path("/opt/zephyr-sdk")),
+ }
def test_zephyr_from_env(mockfs, monkeypatch, fake_project):
@@ -155,6 +158,9 @@ def test_zephyr_from_env(mockfs, monkeypatch, fake_project):
"ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
"ZEPHYR_SDK_INSTALL_DIR": str(zephyr_sdk_path),
}
+ assert config.environ_defs == {
+ "ZEPHYR_SDK_INSTALL_DIR": str(zephyr_sdk_path),
+ }
def test_host_toolchain(fake_project, host_toolchain_exists):
diff --git a/zephyr/zmake/zmake/build_config.py b/zephyr/zmake/zmake/build_config.py
index 6725d18c0d..6f1a76904e 100644
--- a/zephyr/zmake/zmake/build_config.py
+++ b/zephyr/zmake/zmake/build_config.py
@@ -14,16 +14,18 @@ import zmake.util as util
class BuildConfig:
"""A container for build configurations.
- A build config is a tuple of cmake variables, kconfig definitions,
- and kconfig files.
+ A build config is a tuple of environment variables, cmake
+ variables, kconfig definitons, and kconfig files.
"""
def __init__(
self,
+ environ_defs=None,
cmake_defs=None,
kconfig_defs=None,
kconfig_files=None,
):
+ self.environ_defs = dict(environ_defs or {})
self.cmake_defs = dict(cmake_defs or {})
self.kconfig_defs = dict(kconfig_defs or {})
@@ -65,7 +67,9 @@ class BuildConfig:
)
if kconfig_files:
- base_config = BuildConfig(cmake_defs=self.cmake_defs)
+ base_config = BuildConfig(
+ environ_defs=self.environ_defs, cmake_defs=self.cmake_defs
+ )
conf_file_config = BuildConfig(
cmake_defs={
"CONF_FILE": ";".join(
@@ -77,6 +81,7 @@ class BuildConfig:
jobclient, project_dir, build_dir, **kwargs
)
+ kwargs["env"] = dict(**kwargs.get("env", {}), **self.environ_defs)
return jobclient.popen(
[
"/usr/bin/cmake",
@@ -100,6 +105,7 @@ class BuildConfig:
)
return BuildConfig(
+ environ_defs=dict(**self.environ_defs, **other.environ_defs),
cmake_defs=dict(**self.cmake_defs, **other.cmake_defs),
kconfig_defs=dict(**self.kconfig_defs, **other.kconfig_defs),
kconfig_files=[*self.kconfig_files, *other.kconfig_files],
@@ -110,6 +116,7 @@ class BuildConfig:
", ".join(
"{}={!r}".format(name, getattr(self, name))
for name in [
+ "environ_defs",
"cmake_defs",
"kconfig_defs",
"kconfig_files",
@@ -151,6 +158,7 @@ class BuildConfig:
"""Provide a stable JSON representation of the build config."""
return json.dumps(
{
+ "environ_defs": self.environ_defs,
"cmake_defs": self.cmake_defs,
"kconfig_defs": self.kconfig_defs,
"kconfig_files": [str(p.resolve()) for p in self.kconfig_files],
diff --git a/zephyr/zmake/zmake/jobserver.py b/zephyr/zmake/zmake/jobserver.py
index 2b543a77f5..16f856e607 100644
--- a/zephyr/zmake/zmake/jobserver.py
+++ b/zephyr/zmake/zmake/jobserver.py
@@ -48,10 +48,7 @@ class JobClient:
Returns:
A Popen object.
"""
- # By default, we scrub the environment for all commands we run, setting
- # the bare minimum (PATH only). This prevents us from building obscure
- # dependencies on the environment variables.
- kwargs.setdefault("env", {"PATH": "/bin:/usr/bin"})
+ kwargs.setdefault("env", os.environ)
kwargs["env"].update(self.env())
logger = logging.getLogger(self.__class__.__name__)
diff --git a/zephyr/zmake/zmake/toolchains.py b/zephyr/zmake/zmake/toolchains.py
index 73033fb745..8ed1112e25 100644
--- a/zephyr/zmake/zmake/toolchains.py
+++ b/zephyr/zmake/zmake/toolchains.py
@@ -122,7 +122,10 @@ class ZephyrToolchain(GenericToolchain):
"ZEPHYR_SDK_INSTALL_DIR": str(self.zephyr_sdk_install_dir),
}
return (
- build_config.BuildConfig(cmake_defs=tc_vars)
+ build_config.BuildConfig(
+ environ_defs=tc_vars,
+ cmake_defs=tc_vars,
+ )
| super().get_build_config()
)
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index a8566c6776..cbc257ddfc 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -485,6 +485,10 @@ class Zmake:
generated_include_dir = (build_dir / "include").resolve()
base_config = zmake.build_config.BuildConfig(
+ environ_defs={
+ "ZEPHYR_BASE": str(self.zephyr_base),
+ "PATH": "/usr/bin",
+ },
cmake_defs={
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"DTS_ROOT": str(self.module_paths["ec"] / "zephyr"),
@@ -500,7 +504,6 @@ class Zmake:
/ "zephyr"
/ "user-cache"
),
- "ZEPHYR_BASE": str(self.zephyr_base),
"ZMAKE_INCLUDE_DIR": str(generated_include_dir),
"ZMAKE_PROJECT_NAME": project.config.project_name,
**(