Merge branch 'bugfix/child_cmake_uninitialized_vars' into 'master'

cmake: Set uninitialized variable warnings in ULP & bootloader subprojects

See merge request espressif/esp-idf!6302
This commit is contained in:
Angus Gratton 2019-10-29 16:00:05 +08:00
commit dc5a7c85ff
5 changed files with 23 additions and 1 deletions

View file

@ -97,6 +97,7 @@ idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(idf_target IDF_TARGET) idf_build_get_property(idf_target IDF_TARGET)
idf_build_get_property(sdkconfig SDKCONFIG) idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(python PYTHON) idf_build_get_property(python PYTHON)
idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS)
externalproject_add(bootloader externalproject_add(bootloader
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject" SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject"
@ -109,6 +110,7 @@ externalproject_add(bootloader
# the bootloader common component requirements depends on this and # the bootloader common component requirements depends on this and
# config variables are not available before project() call. # config variables are not available before project() call.
-DLEGACY_INCLUDE_COMMON_HEADERS=${CONFIG_LEGACY_INCLUDE_COMMON_HEADERS} -DLEGACY_INCLUDE_COMMON_HEADERS=${CONFIG_LEGACY_INCLUDE_COMMON_HEADERS}
${EXTRA_CMAKE_ARGS}
INSTALL_COMMAND "" INSTALL_COMMAND ""
BUILD_ALWAYS 1 # no easy way around this... BUILD_ALWAYS 1 # no easy way around this...
BUILD_BYPRODUCTS ${bootloader_binary_files} BUILD_BYPRODUCTS ${bootloader_binary_files}

View file

@ -8,6 +8,10 @@ set(CMAKE_C_COMPILER "xtensa-esp32-elf-gcc")
set(CMAKE_ASM_COMPILER "esp32ulp-elf-as") set(CMAKE_ASM_COMPILER "esp32ulp-elf-as")
set(CMAKE_LINKER "esp32ulp-elf-ld") set(CMAKE_LINKER "esp32ulp-elf-ld")
if(NOT ASM_DIALECT)
set(ASM_DIALECT "")
endif()
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "${CMAKE_ASM${ASM_DIALECT}_COMPILER} \ set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "${CMAKE_ASM${ASM_DIALECT}_COMPILER} \
<DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>") <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
set(CMAKE_EXE_LINKER_FLAGS "-A elf32-esp32ulp -nostdlib" CACHE STRING "ULP Linker Base Flags") set(CMAKE_EXE_LINKER_FLAGS "-A elf32-esp32ulp -nostdlib" CACHE STRING "ULP Linker Base Flags")

View file

@ -32,6 +32,8 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs)
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER) idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
idf_build_get_property(idf_path IDF_PATH) idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(python PYTHON) idf_build_get_property(python PYTHON)
idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS)
externalproject_add(${app_name} externalproject_add(${app_name}
SOURCE_DIR ${idf_path}/components/ulp/cmake SOURCE_DIR ${idf_path}/components/ulp/cmake
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${app_name} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${app_name}
@ -45,6 +47,8 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs)
-DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_TARGET},INTERFACE_INCLUDE_DIRECTORIES> -DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_TARGET},INTERFACE_INCLUDE_DIRECTORIES>
-DIDF_PATH=${idf_path} -DIDF_PATH=${idf_path}
-DSDKCONFIG=${SDKCONFIG_HEADER} -DSDKCONFIG=${SDKCONFIG_HEADER}
-DPYTHON=${python}
${EXTRA_CMAKE_ARGS}
BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${app_name} --target build BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${app_name} --target build
BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources} BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources}
${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name} ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name}

View file

@ -18,6 +18,17 @@ if(PYTHON_DEPS_CHECKED)
idf_build_set_property(__CHECK_PYTHON 0) idf_build_set_property(__CHECK_PYTHON 0)
endif() endif()
# Store CMake arguments that need to be passed into all CMake sub-projects as well
# (bootloader, ULP, etc)
#
# It's not possible to tell if CMake was called with --warn-uninitialized, so to also
# have these warnings in sub-projects we set a cache variable as well and then check that.
if(WARN_UNINITIALIZED)
idf_build_set_property(EXTRA_CMAKE_ARGS --warn-uninitialized)
else()
idf_build_set_property(EXTRA_CMAKE_ARGS "")
endif()
# Initialize build target for this build using the environment variable or # Initialize build target for this build using the environment variable or
# value passed externally. # value passed externally.
__target_init() __target_init()

View file

@ -253,6 +253,7 @@ def _ensure_build_directory(args, always_run_cmake=False):
] ]
if not args.no_warnings: if not args.no_warnings:
cmake_args += ["--warn-uninitialized"] cmake_args += ["--warn-uninitialized"]
cmake_args += ["-DWARN_UNINITIALIZED=1"]
if args.define_cache_entry: if args.define_cache_entry:
cmake_args += ["-D" + d for d in args.define_cache_entry] cmake_args += ["-D" + d for d in args.define_cache_entry]