To use Xtensa toolchain, various environment variables must be set so the executables can find necessary files and what core to compile for. This becomes an annoyance when you have to test multiple boards with different cores. You have to use one set of environment variables per core. Twister cannot test them all in one setting, and it is especially annoying doing west builds. So enhance the environment variables handling so that TOOLCHAIN_VER and XTENSA_CORE can be replaced by TOOLCHAIN_VAR_<board> and XTENSA_CORE_<board> where <board> is the normalized board target (think <board>.yaml). CMake will then figure out the core ID for the toolchain to use. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
30 lines
937 B
CMake
30 lines
937 B
CMake
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
set_ifndef(CC gcc)
|
|
|
|
find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC} PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_GCOV ${CROSS_COMPILE}gcov PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
|
|
if(CMAKE_C_COMPILER STREQUAL CMAKE_C_COMPILER-NOTFOUND)
|
|
message(FATAL_ERROR "Zephyr was unable to find ${CROSS_COMPILE}${CC}. Is the environment misconfigured?
|
|
User-configuration:
|
|
ZEPHYR_TOOLCHAIN_VARIANT: ${ZEPHYR_TOOLCHAIN_VARIANT}
|
|
Internal variables:
|
|
CROSS_COMPILE: ${CROSS_COMPILE}
|
|
TOOLCHAIN_HOME: ${TOOLCHAIN_HOME}
|
|
TOOLCHAIN_VER: ${TOOLCHAIN_VER}
|
|
")
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND ${CMAKE_C_COMPILER} --version ${XTENSA_CORE_LOCAL_C_FLAG}
|
|
RESULT_VARIABLE ret
|
|
OUTPUT_VARIABLE stdoutput
|
|
)
|
|
if(ret)
|
|
message(FATAL_ERROR "Executing the below command failed. Are permissions set correctly?
|
|
${CMAKE_C_COMPILER} --version ${XTENSA_CORE_LOCAL_C_FLAG}
|
|
${stdoutput}
|
|
"
|
|
)
|
|
endif()
|