Merge branch 'bugfix/various_cmake_fixes_v4.0' into 'release/v4.0'

CMake: Various backports

See merge request espressif/esp-idf!5933
This commit is contained in:
Angus Gratton 2019-09-02 12:46:40 +08:00
commit ebb9384681
12 changed files with 54 additions and 29 deletions

View file

@ -1,5 +1,5 @@
idf_component_register(SRCS "esp_tls.c"
INCLUDE_DIRS "."
PRIVATE_INCLUDE_DIRS "private_include"
PRIV_INCLUDE_DIRS "private_include"
REQUIRES mbedtls
PRIV_REQUIRES lwip nghttp)

View file

@ -10,7 +10,7 @@ ifneq ("$(filter esp32,$(TEST_COMPONENTS_LIST))","")
CPPFLAGS += -DESP_TIMER_DYNAMIC_OVERFLOW_VAL
endif
ESP32_LINKER_SCRIPT_TEMPLATE := $(COMPONENT_PATH)/ld/esp32.project.ld.in
ESP32_LINKER_SCRIPT_OUTPUT_DIR := $(abspath $(BUILD_DIR_BASE)/esp32)
ESP32_LINKER_SCRIPT_OUTPUT_DIR := $(realpath $(BUILD_DIR_BASE)/esp32)
# Target to generate linker script generator from fragments presented by each of
# the components

View file

@ -1,3 +1,3 @@
--encrypt ${ESPTOOLPY_FLASH_PROJECT_OPTIONS}
$<JOIN:$<TARGET_PROPERTY:flash_project_args_target,FLASH_PROJECT_ARGS>,
$<JOIN:${FLASH_PROJECT_ARGS},
>

View file

@ -19,17 +19,18 @@ set_property(TARGET mbedtls PROPERTY SOURCES ${src_tls})
set(mbedtls_targets mbedtls mbedcrypto mbedx509)
# Add port files to mbedtls targets
target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/esp_bignum.c"
target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/mbedtls_debug.c"
"${COMPONENT_DIR}/port/net_sockets.c")
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/esp_bignum.c"
"${COMPONENT_DIR}/port/esp_hardware.c"
"${COMPONENT_PATH}/port/esp_sha.c"
"${COMPONENT_DIR}/port/esp_mem.c"
"${COMPONENT_DIR}/port/esp_sha.c"
"${COMPONENT_DIR}/port/esp_sha1.c"
"${COMPONENT_DIR}/port/esp_sha256.c"
"${COMPONENT_DIR}/port/esp_sha512.c"
"${COMPONENT_DIR}/port/mbedtls_debug.c"
"${COMPONENT_DIR}/port/net_sockets.c"
"${COMPONENT_DIR}/port/esp32/aes.c"
"${COMPONENT_DIR}/port/esp32/sha.c")
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/esp_mem.c")
foreach(target ${mbedtls_targets})
target_compile_definitions(${target} PUBLIC -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h")

View file

@ -5,5 +5,5 @@ idf_component_register(SRCS "transport.c"
"transport_utils.c"
"transport_strcasestr.c"
INCLUDE_DIRS "include"
PRIVATE_INCLUDE_DIRS "private_include"
PRIV_INCLUDE_DIRS "private_include"
REQUIRES lwip esp-tls)

View file

@ -973,7 +973,7 @@ The call requires the target chip to be specified with *target* argument. Option
- PROJECT_DIR - directory of the project; defaults to CMAKE_SOURCE_DIR
- PROJECT_NAME - name of the project; defaults to CMAKE_PROJECT_NAME
- PROJECT_VER - version/revision of the project; defaults to "0.0.0"
- PROJECT_VER - version/revision of the project; defaults to "1"
- SDKCONFIG - output path of generated sdkconfig file; defaults to PROJECT_DIR/sdkconfig or CMAKE_SOURCE_DIR/sdkconfig depending if PROJECT_DIR is set
- SDKCONFIG_DEFAULTS - defaults file to use for the build; defaults to empty
- BUILD_DIR - directory to place ESP-IDF build-related artifacts, such as generated binaries, text files, components; defaults to CMAKE_BINARY_DIR

View file

@ -510,6 +510,14 @@ endmenu\n" >> ${IDF_PATH}/Kconfig;
mv CMakeLists.txt.bak CMakeLists.txt
rm -rf CMakeLists.txt.bak
print_status "Component properties are set"
clean_build_dir
cp CMakeLists.txt CMakeLists.txt.bak
printf "\nidf_component_get_property(srcs main SRCS)\nmessage(STATUS SRCS:\${srcs})" >> CMakeLists.txt
(idf.py reconfigure | grep "SRCS:$(realpath main/main.c)") || failure "Component properties should be set"
rm -rf CMakeLists.txt
mv CMakeLists.txt.bak CMakeLists.txt
rm -rf CMakeLists.txt.bak
print_status "All tests completed"
if [ -n "${FAILURES}" ]; then

View file

@ -295,7 +295,7 @@ endmacro()
#
macro(__build_set_default var default)
set(_var __${var})
if(${_var})
if(NOT "${_var}" STREQUAL "")
idf_build_set_property(${var} "${${_var}}")
else()
idf_build_set_property(${var} "${default}")
@ -330,7 +330,7 @@ endfunction()
# @param[in, optional] PROJECT_DIR (single value) directory of the main project the buildsystem
# is processed for; defaults to CMAKE_SOURCE_DIR
# @param[in, optional] PROJECT_VER (single value) version string of the main project; defaults
# to 0.0.0
# to 1
# @param[in, optional] PROJECT_NAME (single value) main project name, defaults to CMAKE_PROJECT_NAME
# @param[in, optional] SDKCONFIG (single value) sdkconfig output path, defaults to PROJECT_DIR/sdkconfig
# if PROJECT_DIR is set and CMAKE_SOURCE_DIR/sdkconfig if not
@ -366,7 +366,7 @@ macro(idf_build_process target)
__build_set_default(PROJECT_DIR ${CMAKE_SOURCE_DIR})
__build_set_default(PROJECT_NAME ${CMAKE_PROJECT_NAME})
__build_set_default(PROJECT_VER "0.0.0")
__build_set_default(PROJECT_VER 1)
__build_set_default(BUILD_DIR ${CMAKE_BINARY_DIR})
idf_build_get_property(project_dir PROJECT_DIR)

View file

@ -213,6 +213,7 @@ function(__component_get_requirements)
__component_write_properties(${component_properties_file})
execute_process(COMMAND "${CMAKE_COMMAND}"
-D "ESP_PLATFORM=1"
-D "BUILD_PROPERTIES_FILE=${build_properties_file}"
-D "COMPONENT_PROPERTIES_FILE=${component_properties_file}"
-D "COMPONENT_REQUIRES_FILE=${component_requires_file}"
@ -232,10 +233,10 @@ function(__component_get_requirements)
file(REMOVE ${component_requires_file})
endfunction()
# __component_add_sources, __component_check_target
# __component_add_sources, __component_check_target, __component_add_include_dirs
#
# Utility macros for component registration. Adds source files and checks target requirements
# respectively.
# Utility macros for component registration. Adds source files and checks target requirements,
# and adds include directories respectively.
macro(__component_add_sources sources)
set(sources "")
if(__SRCS)
@ -279,6 +280,16 @@ macro(__component_add_sources sources)
list(REMOVE_DUPLICATES sources)
endmacro()
macro(__component_add_include_dirs lib dirs type)
foreach(dir ${dirs})
get_filename_component(_dir ${dir} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR})
if(NOT IS_DIRECTORY ${_dir})
message(FATAL_ERROR "Include directory '${_dir}' is not a directory.")
endif()
target_include_directories(${lib} ${type} ${_dir})
endforeach()
endmacro()
macro(__component_check_target)
if(__REQUIRED_IDF_TARGETS)
idf_build_get_property(idf_target IDF_TARGET)
@ -324,6 +335,7 @@ macro(__component_set_all_dependencies)
endif()
endmacro()
# idf_component_get_property
#
# @brief Retrieve the value of the specified component property
@ -436,16 +448,16 @@ function(idf_component_register)
if(sources OR __EMBED_FILES OR __EMBED_TXTFILES)
add_library(${component_lib} STATIC ${sources})
__component_set_property(${component_target} COMPONENT_TYPE LIBRARY)
target_include_directories(${component_lib} PUBLIC ${__INCLUDE_DIRS})
target_include_directories(${component_lib} PRIVATE ${__PRIV_INCLUDE_DIRS})
target_include_directories(${component_lib} PUBLIC ${config_dir})
__component_add_include_dirs(${component_lib} "${__INCLUDE_DIRS}" PUBLIC)
__component_add_include_dirs(${component_lib} "${__PRIV_INCLUDE_DIRS}" PRIVATE)
__component_add_include_dirs(${component_lib} "${config_dir}" PUBLIC)
set_target_properties(${component_lib} PROPERTIES OUTPUT_NAME ${COMPONENT_NAME})
__ldgen_add_component(${component_lib})
else()
add_library(${component_lib} INTERFACE)
__component_set_property(${component_target} COMPONENT_TYPE CONFIG_ONLY)
target_include_directories(${component_lib} INTERFACE ${__INCLUDE_DIRS})
target_include_directories(${component_lib} INTERFACE ${config_dir})
__component_add_include_dirs(${component_lib} "${__INCLUDE_DIRS}" INTERFACE)
__component_add_include_dirs(${component_lib} "${config_dir}" INTERFACE)
endif()
# Alias the static/interface library created for linking to external targets.
@ -479,6 +491,8 @@ function(idf_component_register)
# COMPONENT_TARGET is deprecated but is made available with same function
# as COMPONENT_LIB for compatibility.
set(COMPONENT_TARGET ${component_lib} PARENT_SCOPE)
__component_set_properties()
endfunction()
#

View file

@ -47,7 +47,7 @@ function(__kconfig_init)
externalproject_add(mconf-idf
SOURCE_DIR ${src_path}
CONFIGURE_COMMAND ""
BINARY_DIR "kconfig_bin"
BINARY_DIR "${CMAKE_BINARY_DIR}/kconfig_bin"
BUILD_COMMAND rm -f ${src_path}/zconf.lex.c ${src_path}/zconf.hash.c
COMMAND make -f ${src_path}/Makefile mconf-idf
BUILD_BYPRODUCTS ${MCONF}

View file

@ -38,9 +38,9 @@ function(__project_get_revision var)
if(PROJECT_VER_GIT)
set(PROJECT_VER ${PROJECT_VER_GIT})
else()
message(STATUS "Project is not inside a git repository, \
will not use 'git describe' to determine PROJECT_VER.")
set(PROJECT_VER "1")
message(STATUS "Project is not inside a git repository, or git repository has no commits;"
" will not use 'git describe' to determine PROJECT_VER.")
set(PROJECT_VER 1)
endif()
endif()
endif()

View file

@ -24,12 +24,14 @@ if(HEAD_CONTENTS MATCHES "ref")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
if(EXISTS "@GIT_DIR@/packed-refs")
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)