mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
cmake: Detect missing or out of date submodules during cmake pass
This commit is contained in:
parent
35f521afb6
commit
68e75dd0df
@ -2,7 +2,6 @@ if(CONFIG_AWS_IOT_SDK)
|
|||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS "include aws-iot-device-sdk-embedded-C/include")
|
set(COMPONENT_ADD_INCLUDEDIRS "include aws-iot-device-sdk-embedded-C/include")
|
||||||
set(COMPONENT_SRCDIRS "aws-iot-device-sdk-embedded-C/src port")
|
set(COMPONENT_SRCDIRS "aws-iot-device-sdk-embedded-C/src port")
|
||||||
set(COMPONENT_SUBMODULES aws-iot-device-sdk-embedded-C)
|
|
||||||
|
|
||||||
register_component()
|
register_component()
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@ set(COMPONENT_SRCS
|
|||||||
port/coap_io_socket.c
|
port/coap_io_socket.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(COMPONENT_SUBMODULES libcoap)
|
|
||||||
|
|
||||||
register_component()
|
register_component()
|
||||||
|
|
||||||
# Needed for coap headers in public builds, also.
|
# Needed for coap headers in public builds, also.
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
set(SRC libsodium/src/libsodium)
|
set(SRC libsodium/src/libsodium)
|
||||||
|
|
||||||
set(COMPONENT_SUBMODULES libsodium)
|
|
||||||
|
|
||||||
set(COMPONENT_SRCDIRS
|
set(COMPONENT_SRCDIRS
|
||||||
port
|
port
|
||||||
|
|
||||||
|
@ -3,6 +3,4 @@ set(COMPONENT_SRCS micro-ecc/uECC.c)
|
|||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS micro-ecc)
|
set(COMPONENT_ADD_INCLUDEDIRS micro-ecc)
|
||||||
|
|
||||||
set(COMPONENT_SUBMODULES micro-ecc)
|
|
||||||
|
|
||||||
register_component()
|
register_component()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_ADD_INCLUDEDIRS port/include nghttp2/lib/includes)
|
set(COMPONENT_ADD_INCLUDEDIRS port/include nghttp2/lib/includes)
|
||||||
set(COMPONENT_SRCDIRS nghttp2/lib port)
|
set(COMPONENT_SRCDIRS nghttp2/lib port)
|
||||||
set(COMPONENT_SUBMODULES nghttp2)
|
|
||||||
|
|
||||||
register_component()
|
register_component()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||||
set(COMPONENT_PRIV_INCLUDEDIRS "spiffs/src")
|
set(COMPONENT_PRIV_INCLUDEDIRS "spiffs/src")
|
||||||
set(COMPONENT_SRCDIRS ". spiffs/src")
|
set(COMPONENT_SRCDIRS ". spiffs/src")
|
||||||
set(COMPONENT_SUBMODULES "spiffs")
|
|
||||||
register_component()
|
register_component()
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ include(utilities)
|
|||||||
include(components)
|
include(components)
|
||||||
include(kconfig)
|
include(kconfig)
|
||||||
include(crosstool_version_check)
|
include(crosstool_version_check)
|
||||||
|
include(git_submodules)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Warn if the toolchain version doesn't match
|
# Warn if the toolchain version doesn't match
|
||||||
@ -50,8 +51,8 @@ set_default(EXTRA_COMPONENT_DIRS "")
|
|||||||
set_default(COMPONENT_DIRS "${PROJECT_PATH}/components ${EXTRA_COMPONENT_DIRS} ${IDF_PATH}/components")
|
set_default(COMPONENT_DIRS "${PROJECT_PATH}/components ${EXTRA_COMPONENT_DIRS} ${IDF_PATH}/components")
|
||||||
spaces2list(COMPONENT_DIRS)
|
spaces2list(COMPONENT_DIRS)
|
||||||
|
|
||||||
# expand COMPONENT_DIRS variable into full paths to all components and their names
|
|
||||||
spaces2list(COMPONENTS)
|
spaces2list(COMPONENTS)
|
||||||
|
# Search COMPONENT_DIRS for COMPONENTS, make a list of full paths to each component in COMPONENT_PATHS
|
||||||
find_all_components("${COMPONENT_DIRS}" "${COMPONENTS}" COMPONENT_PATHS COMPONENTS)
|
find_all_components("${COMPONENT_DIRS}" "${COMPONENTS}" COMPONENT_PATHS COMPONENTS)
|
||||||
build_component_config()
|
build_component_config()
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ add_definitions(-DHAVE_CONFIG_H)
|
|||||||
|
|
||||||
git_describe(GIT_REVISION)
|
git_describe(GIT_REVISION)
|
||||||
add_definitions(-DIDF_VER=\"${GIT_REVISION}\")
|
add_definitions(-DIDF_VER=\"${GIT_REVISION}\")
|
||||||
|
git_submodule_check("${IDF_PATH}")
|
||||||
|
|
||||||
add_compile_options("-I${CMAKE_BINARY_DIR}") # for sdkconfig.h
|
add_compile_options("-I${CMAKE_BINARY_DIR}") # for sdkconfig.h
|
||||||
|
|
||||||
|
51
tools/cmake/git_submodules.cmake
Normal file
51
tools/cmake/git_submodules.cmake
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
find_package(Git)
|
||||||
|
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
message(WARNING "Git executable was not found. Git submodule checks will not be executed. If you have any build issues at all, start by adding git executable to the PATH and rerun cmake to not see this warning again.")
|
||||||
|
|
||||||
|
function(git_submodule_check root_path)
|
||||||
|
# no-op
|
||||||
|
endfunction()
|
||||||
|
else(NOT GIT_FOUND)
|
||||||
|
|
||||||
|
function(git_submodule_check root_path)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} submodule status
|
||||||
|
WORKING_DIRECTORY ${root_path}
|
||||||
|
OUTPUT_VARIABLE submodule_status
|
||||||
|
)
|
||||||
|
|
||||||
|
# git submodule status output not guaranteed to be stable,
|
||||||
|
# may need to check GIT_VERSION_STRING and do some fiddling in the
|
||||||
|
# future...
|
||||||
|
|
||||||
|
lines2list(submodule_status)
|
||||||
|
|
||||||
|
foreach(line ${submodule_status})
|
||||||
|
string(REGEX MATCH "(.)[0-9a-f]+ ([^\( ]+) ?" _ignored "${line}")
|
||||||
|
set(status "${CMAKE_MATCH_1}")
|
||||||
|
set(submodule_path "${CMAKE_MATCH_2}")
|
||||||
|
|
||||||
|
if("${status}" STREQUAL "-") # missing submodule
|
||||||
|
message(STATUS "Initialising new submodule ${submodule_path}...")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive ${submodule_path}
|
||||||
|
WORKING_DIRECTORY ${root_path}
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
)
|
||||||
|
if(git_result)
|
||||||
|
message(FATAL_ERROR "Git submodule init failed for ${submodule_path}")
|
||||||
|
endif(git_result)
|
||||||
|
|
||||||
|
elseif(NOT "${status}" STREQUAL " ")
|
||||||
|
message(WARNING "Git submodule ${submodule_path} is out of date. Run 'git submodule update --init --recursive' to fix.")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endfunction(git_submodule_check)
|
||||||
|
|
||||||
|
endif(NOT GIT_FOUND)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,11 +24,25 @@ endfunction()
|
|||||||
#
|
#
|
||||||
# Note: if using this for directories, keeps the issue in place that
|
# Note: if using this for directories, keeps the issue in place that
|
||||||
# directories can't contain spaces...
|
# directories can't contain spaces...
|
||||||
|
#
|
||||||
|
# TODO: look at cmake separate_arguments, which is quote-aware
|
||||||
function(spaces2list variable_name)
|
function(spaces2list variable_name)
|
||||||
string(REPLACE " " ";" tmp "${${variable_name}}")
|
string(REPLACE " " ";" tmp "${${variable_name}}")
|
||||||
set("${variable_name}" "${tmp}" PARENT_SCOPE)
|
set("${variable_name}" "${tmp}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# lines2list
|
||||||
|
#
|
||||||
|
# Take a variable with multiple lines of output in it, convert it
|
||||||
|
# to a cmake list (semicolon-delimited), one line per item
|
||||||
|
#
|
||||||
|
function(lines2list variable_name)
|
||||||
|
string(REGEX REPLACE "\r?\n" ";" tmp "${${variable_name}}")
|
||||||
|
set("${variable_name}" "${tmp}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
# move_if_different
|
# move_if_different
|
||||||
#
|
#
|
||||||
# If 'source' has different md5sum to 'destination' (or destination
|
# If 'source' has different md5sum to 'destination' (or destination
|
||||||
|
Loading…
Reference in New Issue
Block a user