Skip to content

Commit 766edd4

Browse files
carlescufigalak
authored andcommitted
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 <[email protected]>
1 parent 52f6f6b commit 766edd4

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,12 @@ if(EXISTS ${CMAKE_BINARY_DIR}/zephyr_modules.txt)
580580
file(STRINGS ${CMAKE_BINARY_DIR}/zephyr_modules.txt ZEPHYR_MODULES_TXT)
581581

582582
foreach(module ${ZEPHYR_MODULES_TXT})
583-
string(REGEX REPLACE "(.*):.*" "\\1" module_name ${module})
584-
string(REGEX REPLACE ".*:(.*)" "\\1" module_path ${module})
585-
message("Including module: ${module_name}")
583+
# Match "<name>":"<path>" for each line of file, each corresponding to
584+
# one module. The use of quotes is required due to CMake not supporting
585+
# lazy regexes (it supports greedy only).
586+
string(REGEX REPLACE "\"(.*)\":\".*\"" "\\1" module_name ${module})
587+
string(REGEX REPLACE "\".*\":\"(.*)\"" "\\1" module_path ${module})
588+
message("Including module: ${module_name} in path: ${module_path}")
586589
add_subdirectory(${module_path} ${CMAKE_BINARY_DIR}/${module_name})
587590
endforeach()
588591
endif()

scripts/zephyr_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def process_module(module, cmake_out=None, kconfig_out=None):
9090
cmake_path = os.path.join(module, cmake_setting or 'zephyr')
9191
cmake_file = os.path.join(cmake_path, 'CMakeLists.txt')
9292
if os.path.isfile(cmake_file) and cmake_out is not None:
93-
cmake_out.write('{}:{}\n'.format(os.path.basename(module),
93+
cmake_out.write('\"{}\":\"{}\"\n'.format(os.path.basename(module),
9494
os.path.abspath(cmake_path)))
9595

9696
kconfig_file = os.path.join(module, kconfig_setting or 'zephyr/Kconfig')

0 commit comments

Comments
 (0)