diff options
-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-'}), |