Skip to content

Commit

Permalink
cmake: modules: Enclose name and path in quotes
Browse files Browse the repository at this point in the history
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 <carles.cufi@nordicsemi.no>
  • Loading branch information
carlescufi authored and galak committed Mar 31, 2019
1 parent 52f6f6b commit 766edd4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<name>":"<path>" 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()
Expand Down
2 changes: 1 addition & 1 deletion scripts/zephyr_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 766edd4

Please sign in to comment.