From a8fe083017057b6c2dbd76ef5fd060b16ff06790 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 10 Oct 2019 12:46:42 +1100 Subject: [PATCH] cmake: Set uninitialized variable warnings in ULP & bootloader subprojects Fixes issue where PYTHON was not being expanded when running ulp_mapgen.py, causing Windows launch setting to be used - reported here: https://esp32.com/viewtopic.php?f=13&t=12640&p=50283#p50283 Closes https://github.com/espressif/esp-idf/issues/4785 --- components/bootloader/project_include.cmake | 7 +++++-- components/ulp/cmake/toolchain-ulp.cmake | 6 +++++- components/ulp/project_include.cmake | 6 +++++- tools/cmake/project.cmake | 11 +++++++++++ tools/idf.py | 1 + 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/components/bootloader/project_include.cmake b/components/bootloader/project_include.cmake index 019d1df71..1ae27df9c 100644 --- a/components/bootloader/project_include.cmake +++ b/components/bootloader/project_include.cmake @@ -96,11 +96,13 @@ endif() idf_build_get_property(idf_path IDF_PATH) idf_build_get_property(idf_target IDF_TARGET) idf_build_get_property(sdkconfig SDKCONFIG) +idf_build_get_property(python PYTHON) +idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS) externalproject_add(bootloader SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject" BINARY_DIR "${BOOTLOADER_BUILD_DIR}" - CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target} + CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target} -DPYTHON=${python} -DPYTHON_DEPS_CHECKED=1 -DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR} ${sign_key_arg} ${ver_key_arg} @@ -108,6 +110,7 @@ externalproject_add(bootloader # the bootloader common component requirements depends on this and # config variables are not available before project() call. -DLEGACY_INCLUDE_COMMON_HEADERS=${CONFIG_LEGACY_INCLUDE_COMMON_HEADERS} + ${extra_cmake_args} INSTALL_COMMAND "" BUILD_ALWAYS 1 # no easy way around this... BUILD_BYPRODUCTS ${bootloader_binary_files} @@ -124,4 +127,4 @@ endif() # So for now we just have the top-level build remove the final build products... set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - ${bootloader_binary_files}) \ No newline at end of file + ${bootloader_binary_files}) diff --git a/components/ulp/cmake/toolchain-ulp.cmake b/components/ulp/cmake/toolchain-ulp.cmake index 93f463ca9..56d53c07f 100644 --- a/components/ulp/cmake/toolchain-ulp.cmake +++ b/components/ulp/cmake/toolchain-ulp.cmake @@ -8,8 +8,12 @@ set(CMAKE_C_COMPILER "xtensa-esp32-elf-gcc") set(CMAKE_ASM_COMPILER "esp32ulp-elf-as") 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} \ -o -c ") set(CMAKE_EXE_LINKER_FLAGS "-A elf32-esp32ulp -nostdlib" CACHE STRING "ULP Linker Base Flags") set(CMAKE_ASM_LINK_EXECUTABLE "${CMAKE_LINKER} \ - -o ") \ No newline at end of file + -o ") diff --git a/components/ulp/project_include.cmake b/components/ulp/project_include.cmake index 95996b32f..e33ea2d50 100644 --- a/components/ulp/project_include.cmake +++ b/components/ulp/project_include.cmake @@ -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(idf_path IDF_PATH) idf_build_get_property(python PYTHON) + idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS) + externalproject_add(${app_name} SOURCE_DIR ${idf_path}/components/ulp/cmake 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=$ -DIDF_PATH=${idf_path} -DSDKCONFIG=${SDKCONFIG_HEADER} + -DPYTHON=${python} + ${extra_cmake_args} BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${app_name} --target build BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources} ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name} @@ -64,4 +68,4 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) target_linker_script(${COMPONENT_LIB} INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name}.ld) target_add_binary_data(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name}.bin BINARY) endif() -endfunction() \ No newline at end of file +endfunction() diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 81bf37dd5..e35e88399 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -18,6 +18,17 @@ if(PYTHON_DEPS_CHECKED) idf_build_set_property(__CHECK_PYTHON 0) 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 # value passed externally. __target_init() diff --git a/tools/idf.py b/tools/idf.py index 722d577c9..84c83beb3 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -236,6 +236,7 @@ def _ensure_build_directory(args, always_run_cmake=False): ] if not args.no_warnings: cmake_args += ["--warn-uninitialized"] + cmake_args += ["-DWARN_UNINITIALIZED=1"] if args.define_cache_entry: cmake_args += ["-D" + d for d in args.define_cache_entry]