diff options
author | Yuval Peress <peress@chromium.org> | 2021-06-25 23:54:22 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-01 20:48:52 +0000 |
commit | 9a909e15a7f1e1ddba969af4af6b3a800d042590 (patch) | |
tree | e9eb0838153c8b57a472004286f5ed85f06eba0e | |
parent | 70cd860787c2663fb9fea28e7d0a4392c6fe82e2 (diff) | |
download | chrome-ec-9a909e15a7f1e1ddba969af4af6b3a800d042590.tar.gz |
zmake: Fix use of ZEPHYR_SDK_INSTALL_DIR
Zephyr v2.6 (when building using the zephyr SDK) tries to find the sdk
using $ENV{ZEPHYR_SDK_INSTALL_DIR}. Add the environment variable def
into the toolchain rule of zmake. Note that the cmake -D value for the
same key isn't removed. This is to avoid breaking any other uses that
attempt to resolve ${ZEPHYR_SDK_INSTALL_DIR} (which is used in several
places.
BRANCH=none
BUG=none
TEST=Install zephyr SDK and build volteer
TEST=Added unit tests
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I2cee8942c453dc332061df1a57b32cfc00c6c4d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2991395
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | zephyr/zmake/tests/test_toolchains.py | 33 | ||||
-rw-r--r-- | zephyr/zmake/zmake/toolchains.py | 3 |
2 files changed, 35 insertions, 1 deletions
diff --git a/zephyr/zmake/tests/test_toolchains.py b/zephyr/zmake/tests/test_toolchains.py new file mode 100644 index 0000000000..5ad9a8e159 --- /dev/null +++ b/zephyr/zmake/tests/test_toolchains.py @@ -0,0 +1,33 @@ +# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import pathlib +import mock +import zmake.toolchains as toolchains + + +def test_coreboot_sdk(): + config = toolchains.get_toolchain('coreboot-sdk', {'ec': pathlib.Path('/')}) + assert config.cmake_defs['ZEPHYR_TOOLCHAIN_VARIANT'] == 'coreboot-sdk' + assert config.cmake_defs['TOOLCHAIN_ROOT'] == '/zephyr' + + +def test_llvm(): + config = toolchains.get_toolchain('llvm', {'ec': pathlib.Path('/')}) + assert config.cmake_defs['ZEPHYR_TOOLCHAIN_VARIANT'] == 'llvm' + assert config.cmake_defs['TOOLCHAIN_ROOT'] == '/zephyr' + + +@mock.patch('zmake.toolchains.find_zephyr_sdk', return_value='/opt/zephyr-sdk') +def test_zephyr(find_zephyr_sdk): + config = toolchains.get_toolchain('zephyr', {}) + assert config.cmake_defs['ZEPHYR_TOOLCHAIN_VARIANT'] == 'zephyr' + assert config.cmake_defs['ZEPHYR_SDK_INSTALL_DIR'] == '/opt/zephyr-sdk' + assert config.environ_defs['ZEPHYR_SDK_INSTALL_DIR'] == '/opt/zephyr-sdk' + + +def test_arm_none_eabi(): + config = toolchains.get_toolchain('arm-none-eabi', {}) + assert config.cmake_defs['ZEPHYR_TOOLCHAIN_VARIANT'] == 'cross-compile' + assert config.cmake_defs['CROSS_COMPILE'] == '/usr/bin/arm-none-eabi-' diff --git a/zephyr/zmake/zmake/toolchains.py b/zephyr/zmake/zmake/toolchains.py index 11dc23bf87..0c0510e970 100644 --- a/zephyr/zmake/zmake/toolchains.py +++ b/zephyr/zmake/zmake/toolchains.py @@ -47,7 +47,8 @@ toolchains = { 'ZEPHYR_TOOLCHAIN_VARIANT': 'llvm'}), 'zephyr': lambda _: build_config.BuildConfig( cmake_defs={'ZEPHYR_TOOLCHAIN_VARIANT': 'zephyr', - 'ZEPHYR_SDK_INSTALL_DIR': str(find_zephyr_sdk())}), + 'ZEPHYR_SDK_INSTALL_DIR': str(find_zephyr_sdk())}, + environ_defs={'ZEPHYR_SDK_INSTALL_DIR': str(find_zephyr_sdk())}), 'arm-none-eabi': lambda _: build_config.BuildConfig( cmake_defs={'ZEPHYR_TOOLCHAIN_VARIANT': 'cross-compile', 'CROSS_COMPILE': '/usr/bin/arm-none-eabi-'}), |