cmake: zephyr module processing improvements.
This commit improves Zephyr modules support in CMake. All Zephyr modules will now have a corresponding `ZEPHYR_${module_name}_MODULE_DIR` set, regardless of whether they define a cmake folder in module.yml. This results in: `ZEPHYR_${module_name}_MODULE_DIR` defined for all modules and refers to the root of the modle. `ZEPHYR_${module_name}_CMAKE_DIR` defined for modules that specifies cmake in module.yml, or is having both a CMakeLists.txt and Kconfig file in the zephyr folder. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
25c3f8e12f
commit
ab7ec17b86
3 changed files with 16 additions and 9 deletions
|
@ -470,11 +470,15 @@ foreach(module_name ${ZEPHYR_MODULE_NAMES})
|
||||||
# the main binary dir instead.
|
# the main binary dir instead.
|
||||||
# https://cmake.org/pipermail/cmake/2019-June/069547.html
|
# https://cmake.org/pipermail/cmake/2019-June/069547.html
|
||||||
string(TOUPPER ${module_name} MODULE_NAME_UPPER)
|
string(TOUPPER ${module_name} MODULE_NAME_UPPER)
|
||||||
set(ZEPHYR_CURRENT_MODULE_DIR ${ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR})
|
if(NOT ${ZEPHYR_${MODULE_NAME_UPPER}_CMAKE_DIR} STREQUAL "")
|
||||||
add_subdirectory(${ZEPHYR_CURRENT_MODULE_DIR} ${CMAKE_BINARY_DIR}/modules/${module_name})
|
set(ZEPHYR_CURRENT_MODULE_DIR ${ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR})
|
||||||
|
set(ZEPHYR_CURRENT_CMAKE_DIR ${ZEPHYR_${MODULE_NAME_UPPER}_CMAKE_DIR})
|
||||||
|
add_subdirectory(${ZEPHYR_CURRENT_CMAKE_DIR} ${CMAKE_BINARY_DIR}/modules/${module_name})
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
# Done processing modules, clear ZEPHYR_CURRENT_MODULE_DIR.
|
# Done processing modules, clear ZEPHYR_CURRENT_MODULE_DIR and ZEPHYR_CURRENT_CMAKE_DIR.
|
||||||
set(ZEPHYR_CURRENT_MODULE_DIR)
|
set(ZEPHYR_CURRENT_MODULE_DIR)
|
||||||
|
set(ZEPHYR_CURRENT_CMAKE_DIR)
|
||||||
|
|
||||||
set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h)
|
set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h)
|
||||||
set(syscalls_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls.json)
|
set(syscalls_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls.json)
|
||||||
|
|
|
@ -69,13 +69,15 @@ if(WEST OR ZEPHYR_MODULES)
|
||||||
# Match "<name>":"<path>" for each line of file, each corresponding to
|
# Match "<name>":"<path>" for each line of file, each corresponding to
|
||||||
# one module. The use of quotes is required due to CMake not supporting
|
# one module. The use of quotes is required due to CMake not supporting
|
||||||
# lazy regexes (it supports greedy only).
|
# lazy regexes (it supports greedy only).
|
||||||
string(REGEX REPLACE "\"(.*)\":\".*\"" "\\1" module_name ${module})
|
string(REGEX REPLACE "\"(.*)\":\".*\":\".*\"" "\\1" module_name ${module})
|
||||||
string(REGEX REPLACE "\".*\":\"(.*)\"" "\\1" module_path ${module})
|
string(REGEX REPLACE "\".*\":\"(.*)\":\".*\"" "\\1" module_path ${module})
|
||||||
|
string(REGEX REPLACE "\".*\":\".*\":\"(.*)\"" "\\1" cmake_path ${module})
|
||||||
|
|
||||||
list(APPEND ZEPHYR_MODULE_NAMES ${module_name})
|
list(APPEND ZEPHYR_MODULE_NAMES ${module_name})
|
||||||
|
|
||||||
string(TOUPPER ${module_name} MODULE_NAME_UPPER)
|
string(TOUPPER ${module_name} MODULE_NAME_UPPER)
|
||||||
set(ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR ${module_path})
|
set(ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR ${module_path})
|
||||||
|
set(ZEPHYR_${MODULE_NAME_UPPER}_CMAKE_DIR ${cmake_path})
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -135,12 +135,14 @@ def process_cmake(module, meta):
|
||||||
cmake_path = os.path.join(module, cmake_setting or 'zephyr')
|
cmake_path = os.path.join(module, cmake_setting or 'zephyr')
|
||||||
cmake_file = os.path.join(cmake_path, 'CMakeLists.txt')
|
cmake_file = os.path.join(cmake_path, 'CMakeLists.txt')
|
||||||
if os.path.isfile(cmake_file):
|
if os.path.isfile(cmake_file):
|
||||||
return('\"{}\":\"{}\"\n'
|
return('\"{}\":\"{}\":\"{}\"\n'
|
||||||
.format(module_path.name,
|
.format(module_path.name,
|
||||||
|
module_path.as_posix(),
|
||||||
Path(cmake_path).resolve().as_posix()))
|
Path(cmake_path).resolve().as_posix()))
|
||||||
else:
|
else:
|
||||||
return ""
|
return('\"{}\":\"{}\":\"\"\n'
|
||||||
|
.format(module_path.name,
|
||||||
|
module_path.as_posix()))
|
||||||
|
|
||||||
def process_settings(module, meta):
|
def process_settings(module, meta):
|
||||||
section = meta.get('build', dict())
|
section = meta.get('build', dict())
|
||||||
|
@ -175,7 +177,6 @@ def process_kconfig(module, meta):
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def process_sanitycheck(module, meta):
|
def process_sanitycheck(module, meta):
|
||||||
|
|
||||||
out = ""
|
out = ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue