summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2020-10-06 21:10:14 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-12 18:38:10 +0000
commit5ec7c4f83a868c788da4ccbc3944c75ef3f7b739 (patch)
tree4a57655575d3e4e19c8d3d2dc07db5bd37675bbb /zephyr
parent94b7b485a2ec24c73c8888014bea2f9f1801f3c3 (diff)
downloadchrome-ec-5ec7c4f83a868c788da4ccbc3944c75ef3f7b739.tar.gz
zephyr: detect the module location in a 2.3/2.4 compatible manner
Most zephyr modules choose to put CMakeLists.txt at the root of the module, but we instead decided to put ours at zephyr/CMakeLists.txt to keep all CMake contained within the zephyr/ directory. So a change in 2.4 came to bite us. ZEPHYR_CURRENT_MODULE_DIR will now be set to the base of the module, not the directory where the CMakeLists.txt is located. Update the code to probe for the 2.3/2.4 difference. BUG=b:170268298 BRANCH=none TEST=compile zephyr for posix-ec on 2.3 and 2.4 (using zmake; build instructions and WIP CL can be found at go/zmake) Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ia6da8451bd7d25aafe7cf42066d202ead208fa7c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2454973 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/CMakeLists.txt10
1 files changed, 9 insertions, 1 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 1959486797..e7c9d322f2 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -14,8 +14,16 @@ if(NOT DEFINED ZEPHYR_CURRENT_MODULE_DIR)
system for non-Zephyr builds.")
endif()
-set(PLATFORM_EC "${ZEPHYR_CURRENT_MODULE_DIR}/.." CACHE PATH
+set(PLATFORM_EC "${ZEPHYR_CURRENT_MODULE_DIR}" CACHE PATH
"Path to the platform/ec repo.")
+# Zephyr 2.3 will set ZEPHYR_CURRENT_MODULE_DIR to the directory of the
+# CMakeLists.txt file, whereas 2.4 will set it to the actual module
+# directory. Try to detect the condition by searching for
+# zephyr/module.yml.
+if(NOT EXISTS "${PLATFORM_EC}/zephyr/module.yml")
+ set(PLATFORM_EC "${PLATFORM_EC}/..")
+ assert_exists("${PLATFORM_EC}/zephyr/module.yml")
+endif()
zephyr_include_directories_ifdef(
CONFIG_PLATFORM_EC