summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2022-08-04 08:16:47 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-04 18:20:58 +0000
commitd16be8f98d81d7e589935d1c6c78ec4430a8960d (patch)
treed0e09d79a9f70222fd6ebb89f1da22a4cc4864da
parentb26904c670250b90ede395ae9969ffe579719f5a (diff)
downloadchrome-ec-d16be8f98d81d7e589935d1c6c78ec4430a8960d.tar.gz
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>
-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, 38 insertions, 73 deletions
diff --git a/docs/zephyr/project_config.md b/docs/zephyr/project_config.md
index f12d47ba36..6e1346b0fa 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
project(ec)
```
diff --git a/util/twister_launcher.py b/util/twister_launcher.py
index cd21b1e39e..a78a0dd534 100755
--- a/util/twister_launcher.py
+++ b/util/twister_launcher.py
@@ -72,7 +72,6 @@ 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",
}
@@ -84,6 +83,7 @@ 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 0cb61eb838..a35978fc63 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 206916cba0..d32e5a2428 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
cros_ec_library_include_directories(include)
diff --git a/zephyr/projects/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/CMakeLists.txt
index c472083e4e..7906cbe01b 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
cros_ec_library_include_directories(include)
diff --git a/zephyr/projects/intelrvp/CMakeLists.txt b/zephyr/projects/intelrvp/CMakeLists.txt
index 9abde95f34..1a8a39d9ae 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 dc2eb449b0..ca8344aeec 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 8a0349bb24..bb61a7dcd3 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 ebaa902ab3..758f059a44 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 a61ddf6755..7e3264944f 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 a81ae87820..3a7d331885 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
project(npcx9)
zephyr_include_directories(include)
diff --git a/zephyr/projects/rex/CMakeLists.txt b/zephyr/projects/rex/CMakeLists.txt
index 469d8c918c..9f2264a629 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 79a1c72c94..74197d1373 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 47285c66eb..a27c4d09ab 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 14fd70e01a..31d8dcdfb6 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 523db95ede..80f7556402 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 674ad0d244..d3b05b1e9d 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 0b46729578..aaf0a6a0f1 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 81b43bf6d2..37353b59f8 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
project(drivers)
add_subdirectory(common)
diff --git a/zephyr/test/ec_app/CMakeLists.txt b/zephyr/test/ec_app/CMakeLists.txt
index 8ee9a554a7..cdcf9d1482 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 81ff57d69d..f19d93644e 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 214177013f..4fa96d0bad 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 eea2834af1..6ff71d72fb 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 c540ece71d..dd78d41849 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 f91786841e..2113b3a9cf 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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 f5ea76e67e..f522683cab 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 $ENV{ZEPHYR_BASE})
+find_package(Zephyr REQUIRED HINTS "${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") \ No newline at end of file
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/tasks.c")
diff --git a/zephyr/zmake/tests/test_build_config.py b/zephyr/zmake/tests/test_build_config.py
index ac73432e88..043c4e5539 100644
--- a/zephyr/zmake/tests/test_build_config.py
+++ b/zephyr/zmake/tests/test_build_config.py
@@ -35,17 +35,13 @@ 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, environ_defs=config_dicts, cmake_defs=config_dicts
-)
+build_configs_no_kconfig = st.builds(BuildConfig, 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,
)
@@ -69,19 +65,16 @@ 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,
@@ -91,7 +84,6 @@ 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)
@@ -157,7 +149,6 @@ 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)
@@ -203,7 +194,6 @@ 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)
@@ -231,10 +221,6 @@ 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",
@@ -248,10 +234,6 @@ 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",
@@ -271,7 +253,7 @@ def test_build_config_json_inequality():
representation.
"""
config_a = BuildConfig(cmake_defs={"A": "B"})
- config_b = BuildConfig(environ_defs={"A": "B"})
+ config_b = BuildConfig(kconfig_defs={"CONFIG_A": "y"})
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 f778bedf87..b9efc52eb2 100644
--- a/zephyr/zmake/tests/test_toolchains.py
+++ b/zephyr/zmake/tests/test_toolchains.py
@@ -137,9 +137,6 @@ 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):
@@ -158,9 +155,6 @@ 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 6f1a76904e..6725d18c0d 100644
--- a/zephyr/zmake/zmake/build_config.py
+++ b/zephyr/zmake/zmake/build_config.py
@@ -14,18 +14,16 @@ import zmake.util as util
class BuildConfig:
"""A container for build configurations.
- A build config is a tuple of environment variables, cmake
- variables, kconfig definitons, and kconfig files.
+ A build config is a tuple of cmake variables, kconfig definitions,
+ 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 {})
@@ -67,9 +65,7 @@ class BuildConfig:
)
if kconfig_files:
- base_config = BuildConfig(
- environ_defs=self.environ_defs, cmake_defs=self.cmake_defs
- )
+ base_config = BuildConfig(cmake_defs=self.cmake_defs)
conf_file_config = BuildConfig(
cmake_defs={
"CONF_FILE": ";".join(
@@ -81,7 +77,6 @@ class BuildConfig:
jobclient, project_dir, build_dir, **kwargs
)
- kwargs["env"] = dict(**kwargs.get("env", {}), **self.environ_defs)
return jobclient.popen(
[
"/usr/bin/cmake",
@@ -105,7 +100,6 @@ 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],
@@ -116,7 +110,6 @@ class BuildConfig:
", ".join(
"{}={!r}".format(name, getattr(self, name))
for name in [
- "environ_defs",
"cmake_defs",
"kconfig_defs",
"kconfig_files",
@@ -158,7 +151,6 @@ 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 16f856e607..2b543a77f5 100644
--- a/zephyr/zmake/zmake/jobserver.py
+++ b/zephyr/zmake/zmake/jobserver.py
@@ -48,7 +48,10 @@ class JobClient:
Returns:
A Popen object.
"""
- kwargs.setdefault("env", os.environ)
+ # 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["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 8ed1112e25..73033fb745 100644
--- a/zephyr/zmake/zmake/toolchains.py
+++ b/zephyr/zmake/zmake/toolchains.py
@@ -122,10 +122,7 @@ class ZephyrToolchain(GenericToolchain):
"ZEPHYR_SDK_INSTALL_DIR": str(self.zephyr_sdk_install_dir),
}
return (
- build_config.BuildConfig(
- environ_defs=tc_vars,
- cmake_defs=tc_vars,
- )
+ build_config.BuildConfig(cmake_defs=tc_vars)
| super().get_build_config()
)
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index cbc257ddfc..a8566c6776 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -485,10 +485,6 @@ 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"),
@@ -504,6 +500,7 @@ 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,
**(