From 766edd449d6c9b654ca49aa21390b9514e9e6aa6 Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Sun, 31 Mar 2019 22:29:30 +0200 Subject: [PATCH] cmake: modules: Enclose name and path in quotes Due to the fact that CMake only supports greedy regexes, the ':' in a Windows path ('C:\...') was being matched leading to an invalid split of the line. Quote both the name and the path to avoid this issue. Signed-off-by: Carles Cufi --- CMakeLists.txt | 9 ++++++--- scripts/zephyr_module.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 151949d0049f..29bd9c5a3368 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -580,9 +580,12 @@ if(EXISTS ${CMAKE_BINARY_DIR}/zephyr_modules.txt) file(STRINGS ${CMAKE_BINARY_DIR}/zephyr_modules.txt ZEPHYR_MODULES_TXT) foreach(module ${ZEPHYR_MODULES_TXT}) - string(REGEX REPLACE "(.*):.*" "\\1" module_name ${module}) - string(REGEX REPLACE ".*:(.*)" "\\1" module_path ${module}) - message("Including module: ${module_name}") + # Match "":"" for each line of file, each corresponding to + # one module. The use of quotes is required due to CMake not supporting + # lazy regexes (it supports greedy only). + string(REGEX REPLACE "\"(.*)\":\".*\"" "\\1" module_name ${module}) + string(REGEX REPLACE "\".*\":\"(.*)\"" "\\1" module_path ${module}) + message("Including module: ${module_name} in path: ${module_path}") add_subdirectory(${module_path} ${CMAKE_BINARY_DIR}/${module_name}) endforeach() endif() diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py index 0431227daca0..f119ce8aab25 100755 --- a/scripts/zephyr_module.py +++ b/scripts/zephyr_module.py @@ -90,7 +90,7 @@ def process_module(module, cmake_out=None, kconfig_out=None): cmake_path = os.path.join(module, cmake_setting or 'zephyr') cmake_file = os.path.join(cmake_path, 'CMakeLists.txt') if os.path.isfile(cmake_file) and cmake_out is not None: - cmake_out.write('{}:{}\n'.format(os.path.basename(module), + cmake_out.write('\"{}\":\"{}\"\n'.format(os.path.basename(module), os.path.abspath(cmake_path))) kconfig_file = os.path.join(module, kconfig_setting or 'zephyr/Kconfig')