]> granicus.if.org Git - esp-idf/commitdiff
components: update with build system changes
authorRenz Christian Bagaporo <renz@espressif.com>
Fri, 10 May 2019 02:53:08 +0000 (10:53 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Mon, 13 May 2019 11:59:17 +0000 (19:59 +0800)
49 files changed:
components/app_trace/CMakeLists.txt
components/app_update/CMakeLists.txt
components/bootloader/CMakeLists.txt
components/bootloader/project_include.cmake
components/bootloader/subproject/CMakeLists.txt
components/bootloader/subproject/components/micro-ecc/CMakeLists.txt
components/bootloader/subproject/main/CMakeLists.txt
components/bootloader_support/CMakeLists.txt
components/bt/CMakeLists.txt
components/coap/CMakeLists.txt
components/console/CMakeLists.txt
components/cxx/CMakeLists.txt
components/efuse/CMakeLists.txt
components/esp32/CMakeLists.txt
components/esp32/project_include.cmake
components/esp32/test/CMakeLists.txt
components/esp_rom/CMakeLists.txt
components/esp_wifi/CMakeLists.txt
components/esp_wifi/test/CMakeLists.txt
components/espcoredump/CMakeLists.txt
components/esptool_py/CMakeLists.txt
components/esptool_py/project_include.cmake
components/expat/CMakeLists.txt
components/freemodbus/CMakeLists.txt
components/freertos/CMakeLists.txt
components/heap/CMakeLists.txt
components/idf_test/CMakeLists.txt
components/jsmn/CMakeLists.txt
components/json/CMakeLists.txt
components/libsodium/CMakeLists.txt
components/log/CMakeLists.txt
components/lwip/CMakeLists.txt
components/mbedtls/CMakeLists.txt
components/newlib/CMakeLists.txt
components/partition_table/CMakeLists.txt
components/partition_table/project_include.cmake
components/pthread/CMakeLists.txt
components/soc/CMakeLists.txt
components/soc/test/CMakeLists.txt
components/spi_flash/CMakeLists.txt
components/spiffs/project_include.cmake
components/ulp/CMakeLists.txt
components/ulp/cmake/CMakeLists.txt
components/ulp/component_ulp_common.cmake
components/ulp/test/CMakeLists.txt
components/unity/CMakeLists.txt
components/vfs/CMakeLists.txt
components/wpa_supplicant/CMakeLists.txt
components/xtensa/CMakeLists.txt

index db1b1c439ab23f0ab5446d326fb02b92f4338e80..b504469b612448fe7a919102e66b0aa47bd68bce 100644 (file)
@@ -30,6 +30,5 @@ register_component()
 
 # disable --coverage for this component, as it is used as transport
 # for gcov
-component_compile_options("-fno-profile-arcs" "-fno-test-coverage")
-
-target_link_libraries(${COMPONENT_TARGET} gcov)
+target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-coverage")
+target_link_libraries(${COMPONENT_LIB} gcov ${LIBC} ${LIBM})
index 6616cc606edc9791d105db28bf5ebc9b6b4e441b..2c705d509131271597441bc92e1f7d9d438a51b7 100644 (file)
@@ -8,35 +8,40 @@ register_component()
 
 # esp_app_desc structure is added as an undefined symbol because otherwise the
 # linker will ignore this structure as it has no other files depending on it.
-target_link_libraries(${COMPONENT_TARGET} "-u esp_app_desc")
+target_link_libraries(${COMPONENT_LIB} "-u esp_app_desc")
 
 # cut PROJECT_VER and PROJECT_NAME to required 32 characters.
-string(SUBSTRING "${PROJECT_VER}" 0 31 PROJECT_VER_CUT)
-string(SUBSTRING "${PROJECT_NAME}" 0 31 PROJECT_NAME_CUT)
+idf_build_get_property(project_ver PROJECT_VER)
+idf_build_get_property(project_name PROJECT_NAME)
+string(SUBSTRING "${project_ver}" 0 31 PROJECT_VER_CUT)
+string(SUBSTRING "${project_name}" 0 31 PROJECT_NAME_CUT)
 
 set_source_files_properties(
     SOURCE "esp_app_desc.c"
     PROPERTIES COMPILE_DEFINITIONS
     "PROJECT_VER=\"${PROJECT_VER_CUT}\"; PROJECT_NAME=\"${PROJECT_NAME_CUT}\"")
 
-if (NOT BOOTLOADER_BUILD AND IDF_BUILD_ARTIFACTS)
+if(NOT BOOTLOADER_BUILD)
     partition_table_get_partition_info(otadata_offset "--partition-type data --partition-subtype ota" "offset")
     partition_table_get_partition_info(otadata_size "--partition-type data --partition-subtype ota" "size")
 
-    set(blank_otadata_file ${IDF_BUILD_ARTIFACTS_DIR}/ota_data_initial.bin)
-
     # Add custom target for generating empty otadata partition for flashing
     if(otadata_size AND otadata_offset)
+        idf_build_get_property(build_dir BUILD_DIR)
+        set(blank_otadata_file ${build_dir}/ota_data_initial.bin)
+
+        idf_build_get_property(idf_path IDF_PATH)
+        idf_build_get_property(python PYTHON)
         add_custom_command(OUTPUT ${blank_otadata_file}
-            COMMAND ${PYTHON} ${IDF_PATH}/components/partition_table/parttool.py
+            COMMAND ${python} ${idf_path}/components/partition_table/parttool.py
             --partition-type data --partition-subtype ota -q
             --partition-table-file ${PARTITION_CSV_PATH} generate_blank_partition_file
             --output ${blank_otadata_file})
 
         add_custom_target(blank_ota_data ALL DEPENDS ${blank_otadata_file})
-        add_dependencies(flash blank_ota_data)
+        add_dependencies(app blank_ota_data)
 
-        set(otatool_py ${PYTHON} ${COMPONENT_PATH}/otatool.py)
+        set(otatool_py ${python} ${COMPONENT_DIR}/otatool.py)
 
         add_custom_target(read_otadata DEPENDS "${PARTITION_CSV_PATH}"
                         COMMAND ${otatool_py} --partition-table-file ${PARTITION_CSV_PATH} read_otadata)
index 2080ed4418847cc5153f26c44dc4b656fca8f4a4..a9dbf01afed29bf6428292a8e8fdb014411e063f 100644 (file)
@@ -1,5 +1,7 @@
+register_component()
+
 # Do not generate flash file when building bootloader or is in early expansion of the build
-if(CMAKE_BUILD_EARLY_EXPANSION OR BOOTLOADER_BUILD)
+if(BOOTLOADER_BUILD)
     return()
 endif()
 
@@ -9,4 +11,4 @@ set(BOOTLOADER_OFFSET 0x1000)
 esptool_py_flash_project_args(bootloader ${BOOTLOADER_OFFSET}
                             ${BOOTLOADER_BUILD_DIR}/bootloader.bin
                             FLASH_IN_PROJECT
-                            FLASH_FILE_TEMPLATE flash_bootloader_args.in)
+                            FLASH_FILE_TEMPLATE flash_bootloader_args.in)
\ No newline at end of file
index e2c51fb05072b24ddf149319091fdd7c7fcab715..a1ae2b8c902c76aa8bd8b2ff07837937c006a872 100644 (file)
@@ -1,8 +1,15 @@
+# Do not generate flash file when building bootloader or is in early expansion of the build
+if(BOOTLOADER_BUILD)
+    return()
+endif()
+
+idf_build_get_property(project_dir PROJECT_DIR)
+
 # This is for tracking the top level project path
 if(BOOTLOADER_BUILD)
     set(main_project_path "${CMAKE_BINARY_DIR}/../..")
 else()
-    set(main_project_path "${IDF_PROJECT_PATH}")
+    set(main_project_path "${project_dir}")
 endif()
 
 get_filename_component(secure_boot_signing_key
@@ -19,15 +26,13 @@ else()
     add_custom_target(gen_secure_boot_signing_key)
 endif()
 
-if(BOOTLOADER_BUILD OR NOT IDF_BUILD_ARTIFACTS)
-    return()  # don't keep recursing, generate on project builds
-endif()
 
 # Glue to build the bootloader subproject binary as an external
 # cmake project under this one
 #
 #
-set(BOOTLOADER_BUILD_DIR "${IDF_BUILD_ARTIFACTS_DIR}/bootloader")
+idf_build_get_property(build_dir BUILD_DIR)
+set(BOOTLOADER_BUILD_DIR "${build_dir}/bootloader")
 set(bootloader_binary_files
     "${BOOTLOADER_BUILD_DIR}/bootloader.elf"
     "${BOOTLOADER_BUILD_DIR}/bootloader.bin"
@@ -47,12 +52,16 @@ endif()
 if((NOT CONFIG_SECURE_BOOT_ENABLED) OR
     CONFIG_SECURE_BOOTLOADER_REFLASHABLE OR
     CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
+    idf_build_get_property(idf_path IDF_PATH)
+    idf_build_get_property(sdkconfig SDKCONFIG)
+    idf_build_get_property(idf_target IDF_TARGET)
     externalproject_add(bootloader
         # TODO: support overriding the bootloader in COMPONENT_PATHS
-        SOURCE_DIR "${IDF_PATH}/components/bootloader/subproject"
+        SOURCE_DIR "${idf_path}/components/bootloader/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}
                     -DSECURE_BOOT_SIGNING_KEY=${secure_boot_signing_key}
+                    -DPYTHON_DEPS_CHECKED=1
         INSTALL_COMMAND ""
         BUILD_ALWAYS 1  # no easy way around this...
         BUILD_BYPRODUCTS ${bootloader_binary_files}
@@ -69,4 +78,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})
+    ${bootloader_binary_files})
\ No newline at end of file
index d7cc60294ce2888c8cabb2ddb20231d827784c0a..1f39199152d117468773bcd787a8d2c72e1dd83c 100644 (file)
@@ -17,33 +17,17 @@ endif()
 
 set(COMPONENTS bootloader esptool_py partition_table soc bootloader_support log spi_flash micro-ecc main efuse)
 set(BOOTLOADER_BUILD 1)
-add_definitions(-DBOOTLOADER_BUILD=1)
-
-set(COMPONENT_REQUIRES_COMMON log esp_rom esp_common xtensa)
-
+include("${IDF_PATH}/tools/cmake/project.cmake")
+set(common_req log esp_rom esp_common xtensa)
 if (CONFIG_LEGACY_INCLUDE_COMMON_HEADERS)
-    list(APPEND COMPONENT_REQUIRES_COMMON "soc")
+    list(APPEND common_req soc)
 endif()
-
-include("${IDF_PATH}/tools/cmake/project.cmake")
+idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${common_req}")
+idf_build_set_property(__OUTPUT_SDKCONFIG 0)
 project(bootloader)
 
-target_linker_script(bootloader.elf
-    "main/${IDF_TARGET}.bootloader.ld"
-    "main/${IDF_TARGET}.bootloader.rom.ld"
-)
-
-# as cmake won't attach linker args to a header-only library, attach
-# linker args directly to the bootloader.elf
-# esp32.rom.newlib-funcs.ld is included to use memset/memcpy.
-set(BOOTLOADER_LINKER_SCRIPTS
-    "${IDF_PATH}/components/esp_rom/${IDF_TARGET}/ld/${IDF_TARGET}.rom.ld"
-    "${IDF_PATH}/components/esp_rom/${IDF_TARGET}/ld/${IDF_TARGET}.rom.newlib-funcs.ld"
-    "${IDF_PATH}/components/${IDF_TARGET}/ld/${IDF_TARGET}.peripherals.ld")
-
-target_linker_script(bootloader.elf ${BOOTLOADER_LINKER_SCRIPTS})
-
-target_link_libraries(bootloader.elf gcc)
+idf_build_set_property(COMPILE_DEFINITIONS "-DBOOTLOADER_BUILD=1" APPEND)
+idf_build_set_property(COMPILE_OPTIONS "-fno-stack-protector" APPEND)
 
 set(secure_boot_signing_key ${SECURE_BOOT_SIGNING_KEY})
 
index a0e1693b116c1ea1274c33c30f404121a52958d8..d609b61e70be09d4f82ba7247f9052ddacbf1bf0 100644 (file)
@@ -1,8 +1,4 @@
 # only compile the "micro-ecc/uECC.c" source file
 set(COMPONENT_SRCS "micro-ecc/uECC.c")
-
 set(COMPONENT_ADD_INCLUDEDIRS micro-ecc)
-
-set(COMPONENT_REQUIRES)
-
 register_component()
index d090e9757a67621558c28ab4dc6fa9295641e84d..54c62e211644c76726d445a6e479f26fa07434e3 100644 (file)
@@ -1,4 +1,10 @@
 set(COMPONENT_SRCS "bootloader_start.c")
 set(COMPONENT_ADD_INCLUDEDIRS "")
-set(COMPONENT_REQUIRES "bootloader bootloader_support")
+set(COMPONENT_REQUIRES bootloader bootloader_support)
 register_component()
+
+idf_build_get_property(target IDF_TARGET)
+set(scripts "${target}.bootloader.ld"
+            "${target}.bootloader.rom.ld")
+
+target_linker_script(${COMPONENT_LIB} "${scripts}")
\ No newline at end of file
index ee9e831be000d2f0d65b88091fef3900bd4ae12a..dc0e0be7fd63d6010e08594bc3445d763f0b0d10 100644 (file)
@@ -7,7 +7,7 @@ set(COMPONENT_SRCS "src/bootloader_clock.c"
                    "src/flash_partitions.c"
                    "src/flash_qio_mode.c")
 
-if(${BOOTLOADER_BUILD})
+if(BOOTLOADER_BUILD)
     set(COMPONENT_ADD_INCLUDEDIRS "include include_bootloader")
     set(COMPONENT_REQUIRES soc) #unfortunately the header directly uses SOC registers
     set(COMPONENT_PRIV_REQUIRES spi_flash micro-ecc efuse)
@@ -59,4 +59,4 @@ else()
     set(COMPONENT_PRIV_REQUIRES spi_flash mbedtls efuse)
 endif()
 
-register_component()
+register_component()
\ No newline at end of file
index b941d4e86e68205bee13216cf7a709d28df45bef..614ab3628c1e896ea65d857bcd012c6f038da20c 100644 (file)
@@ -280,9 +280,9 @@ register_component()
 
 if(CONFIG_BT_ENABLED)
     if(GCC_NOT_5_2_0)
-        component_compile_options(-Wno-implicit-fallthrough -Wno-unused-const-variable)
+        target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
     endif()
 
-    target_link_libraries(${COMPONENT_TARGET} "-L${CMAKE_CURRENT_LIST_DIR}/lib")
-    target_link_libraries(${COMPONENT_TARGET} btdm_app)
+    target_link_libraries(${COMPONENT_LIB} "-L${CMAKE_CURRENT_LIST_DIR}/lib")
+    target_link_libraries(${COMPONENT_LIB} btdm_app)
 endif()
index 1ec70b4990fcdac7179412b95b81d8d35c146d4e..246a0e28e4ed058b17108c44fc4406e22f20ee8c 100644 (file)
@@ -26,3 +26,9 @@ register_component()
 
 # Silence format truncation warning, until it is fixed upstream
 set_source_files_properties(libcoap/src/coap_debug.c PROPERTIES COMPILE_FLAGS -Wno-format-truncation)
+
+# Needed for coap headers in public builds, also.
+#
+# TODO: find a way to move this to a port header
+target_compile_definitions(${COMPONENT_LIB} PUBLIC WITH_POSIX)
+
index 31fb1ed97be9bc78f852817f47e1766083c7e925..33dddc81a918e3546cbfb46fc2aba5ec08e79acf 100644 (file)
@@ -3,8 +3,5 @@ set(COMPONENT_SRCS "commands.c"
                    "split_argv.c"
                    "argtable3/argtable3.c"
                    "linenoise/linenoise.c")
-
-set(COMPONENT_REQUIRES)
-
 register_component()
 
index 236bd5cf716af77da55fdf157861fa83a9e332c8..0d9b14f134b00f97abe4685de5b7187cce5cf32f 100644 (file)
@@ -1,12 +1,10 @@
 set(COMPONENT_SRCS "cxx_exception_stubs.cpp"
                    "cxx_guards.cpp")
-set(COMPONENT_REQUIRES)
 register_component()
 
-target_link_libraries(${COMPONENT_TARGET} stdc++)
-
-target_link_libraries(${COMPONENT_TARGET} "-u __cxa_guard_dummy")
+target_link_libraries(${COMPONENT_LIB} stdc++)
+target_link_libraries(${COMPONENT_LIB} "-u __cxa_guard_dummy")
 
 if(NOT CONFIG_CXX_EXCEPTIONS)
-    target_link_libraries(${COMPONENT_TARGET} "-u __cxx_fatal_exception")
+    target_link_libraries(${COMPONENT_LIB} "-u __cxx_fatal_exception")
 endif()
index 98a41738508600b207802094113fdad5b440907c..f649a242f4cb301815f0053c56813b47f14373c8 100644 (file)
@@ -1,43 +1,44 @@
-set(SOC_NAME ${IDF_TARGET})
+idf_build_get_property(soc_name IDF_TARGET)
 
-if(EXISTS "${COMPONENT_PATH}/${SOC_NAME}")
-    include(${COMPONENT_PATH}/${SOC_NAME}/sources.cmake)
+if(EXISTS "${COMPONENT_DIR}/${soc_name}")
+    include(${COMPONENT_DIR}/${soc_name}/sources.cmake)
     spaces2list(EFUSE_SOC_SRCS)
-    add_prefix(COMPONENT_SRCS "${SOC_NAME}/" ${EFUSE_SOC_SRCS})
-    set(COMPONENT_ADD_INCLUDEDIRS include
-                                  ${SOC_NAME}/include)
+    add_prefix(COMPONENT_SRCS "${soc_name}/" ${EFUSE_SOC_SRCS})
+    set(COMPONENT_ADD_INCLUDEDIRS include ${soc_name}/include)
 endif()
 
 list(APPEND COMPONENT_SRCS "src/esp_efuse_api.c"
                            "src/esp_efuse_fields.c"
                            "src/esp_efuse_utility.c")
 
-set(COMPONENT_REQUIRES)
 set(COMPONENT_PRIV_REQUIRES bootloader_support soc)
 register_component()
 
 set(GEN_EFUSE_TABLE_ARG --max_blk_len ${CONFIG_EFUSE_MAX_BLK_LEN})
 
+idf_build_get_property(python PYTHON)
+
 ###################
 # Make common files esp_efuse_table.c and include/esp_efuse_table.h files.
-set(EFUSE_COMMON_TABLE_CSV_PATH "${COMPONENT_PATH}/${SOC_NAME}/esp_efuse_table.csv")
+set(EFUSE_COMMON_TABLE_CSV_PATH "${COMPONENT_DIR}/${soc_name}/esp_efuse_table.csv")
 
-add_custom_target(efuse_common_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
+add_custom_target(efuse_common_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
 
 ###################
 # Make custom files project/main/esp_efuse_custom_table.c and project/main/include/esp_efuse_custom_table.h files.
 # Path to CSV file is relative to project path for custom CSV files.
 if(${CONFIG_EFUSE_CUSTOM_TABLE})
     # Custom filename expands any path relative to the project
-    get_filename_component(EFUSE_CUSTOM_TABLE_CSV_PATH "${CONFIG_EFUSE_CUSTOM_TABLE_FILENAME}" ABSOLUTE BASE_DIR "${IDF_PROJECT_PATH}")
-       add_custom_target(efuse_custom_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
+    idf_build_get_property(project_dir PROJECT_DIR)
+    get_filename_component(EFUSE_CUSTOM_TABLE_CSV_PATH "${CONFIG_EFUSE_CUSTOM_TABLE_FILENAME}" ABSOLUTE BASE_DIR "${project_dir}")
+       add_custom_target(efuse_custom_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
 else()
        add_custom_target(efuse_custom_table COMMAND)
 endif()#if(${CONFIG_EFUSE_CUSTOM_TABLE})
 
-add_custom_target(show_efuse_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG} "--info")
+add_custom_target(show_efuse_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG} "--info")
 
 ###################
 # Generates files for unit test. This command is run manually.
-set(EFUSE_TEST_TABLE_CSV_PATH "${COMPONENT_PATH}/test/esp_efuse_test_table.csv")
-add_custom_target(efuse_test_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_TEST_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
+set(EFUSE_TEST_TABLE_CSV_PATH "${COMPONENT_DIR}/test/esp_efuse_test_table.csv")
+add_custom_target(efuse_test_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_TEST_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
index 26ae70deabf9d8e7ea40065330eba0e2c5bced61..c9fe3f59a8fc6793a364d31a7e83ebbe4728a4aa 100644 (file)
@@ -3,9 +3,8 @@ require_idf_targets(esp32)
 if(BOOTLOADER_BUILD)
     # For bootloader, all we need from esp32 is headers
     set(COMPONENT_ADD_INCLUDEDIRS include)
-    set(COMPONENT_REQUIRES ${IDF_COMPONENTS} soc) #unfortunately rom/uart uses SOC registers directly
-    set(COMPONENT_SRCS )
     register_component()
+    target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
 else()
     # Regular app build
 
@@ -47,52 +46,42 @@ else()
 
     register_component()
 
-    target_linker_script(${COMPONENT_TARGET} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
+    target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
+
+    # Rely on user code to define app_main
+    target_link_libraries(${COMPONENT_LIB} "-u app_main")
 
     if(CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY)
         # This has to be linked before esp32.project.ld
-        target_linker_script(${COMPONENT_TARGET} "ld/esp32.extram.bss.ld")
-    endif()
-
-    if(IDF_PROJECT_EXECUTABLE)
-        # Process the template file through the linker script generation mechanism, and use the output for linking the
-        # final binary
-        set(esp32_project_script "${CMAKE_CURRENT_BINARY_DIR}/esp32.project.ld")
-        set(esp32_project_template "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in")
-
-        ldgen_process_template(${esp32_project_template} ${esp32_project_script})
-
-        target_link_libraries(${COMPONENT_TARGET} "-T ${esp32_project_script}")
-
-        set_property(TARGET ${IDF_PROJECT_EXECUTABLE} APPEND PROPERTY LINK_DEPENDS ${esp32_project_script})
+        target_linker_script(${COMPONENT_LIB} "ld/esp32.extram.bss.ld")
     endif()
 
-    target_linker_script(${COMPONENT_TARGET} "ld/esp32.peripherals.ld")
+    # Process the template file through the linker script generation mechanism, and use the output for linking the
+    # final binary
+    target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in" PROCESS)
 
-    target_link_libraries(${COMPONENT_TARGET} gcc)
-    target_link_libraries(${COMPONENT_TARGET} "-u call_user_start_cpu0")
+    target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
+    target_link_libraries(${COMPONENT_LIB} gcc)
+    target_link_libraries(${COMPONENT_LIB} "-u call_user_start_cpu0")
 
     #ld_include_panic_highint_hdl is added as an undefined symbol because otherwise the
     #linker will ignore panic_highint_hdl.S as it has no other files depending on any
     #symbols in it.
-    target_link_libraries(${COMPONENT_TARGET} "-u ld_include_panic_highint_hdl")
+    target_link_libraries(${COMPONENT_LIB} "-u ld_include_panic_highint_hdl")
 
+    idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
+    get_filename_component(config_dir ${sdkconfig_header} DIRECTORY)
     # Preprocess esp32.ld linker script to include configuration, becomes esp32_out.ld
     set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld)
     add_custom_command(
         OUTPUT esp32_out.ld
-        COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CONFIG_DIR} ${LD_DIR}/esp32.ld
+        COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${config_dir} ${LD_DIR}/esp32.ld
         MAIN_DEPENDENCY ${LD_DIR}/esp32.ld ${SDKCONFIG_H}
         COMMENT "Generating linker script..."
         VERBATIM)
 
     add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld)
-    add_dependencies(${COMPONENT_TARGET} esp32_linker_script)
-
-    # Enable dynamic esp_timer overflow value if building unit tests
-    if(esp32_test IN_LIST BUILD_TEST_COMPONENTS)
-        add_definitions(-DESP_TIMER_DYNAMIC_OVERFLOW_VAL)
-    endif()
+    add_dependencies(${COMPONENT_LIB} esp32_linker_script)
 
     # disable stack protection in files which are involved in initialization of that feature
     set_source_files_properties(
index d54d6a9beb78e78d8384a45e0de7fdb0a8b5f818..aa0ac286fab4bde50c0b9697493719394732e3f2 100644 (file)
@@ -3,6 +3,19 @@ if(CONFIG_SPIRAM_CACHE_WORKAROUND)
     # are not part of the ESP-IDF build system (for cases where a generic
     # non-IDF CMakeLists.txt file is imported into a component) don't depend
     # on the esp32 component so don't get the extra flag. This handles that case.
-    add_compile_options(-mfix-esp32-psram-cache-issue)
+    idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-issue" APPEND)
 endif()
 
+# Check toolchain is configured properly in cmake
+if(NOT ( ${CMAKE_SYSTEM_NAME} STREQUAL "Generic" AND ${CMAKE_C_COMPILER} MATCHES xtensa))
+    message(FATAL_ERROR "Internal error, toolchain has not been set correctly by project "
+        "(or an invalid CMakeCache.txt file has been generated somehow)")
+endif()
+
+#
+# Warn if the toolchain version doesn't match
+#
+# TODO: make these platform-specific for diff toolchains
+get_expected_ctng_version(expected_toolchain expected_gcc)
+gcc_version_check("${expected_gcc}")
+crosstool_version_check("${expected_toolchain}")
\ No newline at end of file
index 56ef10f5eba60112cc35067e89fa8ff142f7836c..1ced21ed8af51029c76d583789385a6dd58df64d 100644 (file)
@@ -7,9 +7,11 @@ register_component()
 
 add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
                 COMMAND xxd -i "logo.jpg" "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
-                WORKING_DIRECTORY ${COMPONENT_PATH}
+                WORKING_DIRECTORY ${COMPONENT_DIR}
                 DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg")
 
 add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h")
 
-add_dependencies(${COMPONENT_TARGET} esp32_test_logo)
+add_dependencies(${COMPONENT_LIB} esp32_test_logo)
+
+idf_build_set_property(COMPILE_DEFINITIONS "-DESP_TIMER_DYNAMIC_OVERFLOW_VAL" APPEND)
index cbf6f3dcba030803187a5285441bb4f20788020f..468819a22757bb94661655c8f3cfbf8380abbc8f 100644 (file)
@@ -4,6 +4,12 @@ if(BOOTLOADER_BUILD)
     set(COMPONENT_REQUIRES ${IDF_COMPONENTS})
     set(COMPONENT_SRCS)
     register_component()
+    set(scripts
+        "esp32/ld/esp32.rom.ld"
+        "esp32/ld/esp32.rom.newlib-funcs.ld"
+        "esp32/ld/esp32.rom.libgcc.ld"
+        )
+    target_linker_script(${COMPONENT_LIB} "${scripts}")
 else()
     # Regular app build
     set(COMPONENT_SRCS "esp_rom.c")
@@ -11,27 +17,32 @@ else()
 
     register_component()
 
-    target_linker_script(${COMPONENT_TARGET}
-                        "esp32/ld/esp32.rom.ld"
-                        "esp32/ld/esp32.rom.libgcc.ld"
-                        "esp32/ld/esp32.rom.syscalls.ld"
-                        "esp32/ld/esp32.rom.newlib-data.ld")
+    set(scripts
+        "esp32/ld/esp32.rom.ld"
+        "esp32/ld/esp32.rom.libgcc.ld"
+        "esp32/ld/esp32.rom.syscalls.ld"
+        "esp32/ld/esp32.rom.newlib-data.ld"
+        )
+    target_linker_script(${COMPONENT_LIB} "${scripts}")
 
     if(CONFIG_SPIRAM_CACHE_WORKAROUND)
-        target_compile_options(${COMPONENT_TARGET} PUBLIC -mfix-esp32-psram-cache-issue)
+        # Note: Adding as a PUBLIC compile option here causes this option to propagate to all components that depend on esp32.
+        #
+        # To handle some corner cases, the same flag is set in project_include.cmake
+        target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue)
     else()
-        target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-funcs.ld")
+        target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-funcs.ld")
     endif()
 
     if(CONFIG_NEWLIB_NANO_FORMAT)
-        target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-nano.ld")
+        target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-nano.ld")
     endif()
 
     if(NOT GCC_NOT_5_2_0)
-        target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-locale.ld")
+        target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-locale.ld")
     endif()
 
     if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
-        target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.spiflash.ld")
+        target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.spiflash.ld")
     endif()
 endif()
index e16f87d7d3f3c70e51f1d562b50e33ef8d6be064..b87c5188133d29083f1474bc8e4a783745154153 100644 (file)
@@ -16,29 +16,31 @@ if(NOT CONFIG_NO_BLOBS)
 endif()
 
 register_component()
+target_link_libraries(${COMPONENT_LIB} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
 
 if(NOT CONFIG_NO_BLOBS)
-    target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
-    target_link_libraries(${COMPONENT_TARGET} coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
+    target_link_libraries(${COMPONENT_LIB} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
+    target_link_libraries(${COMPONENT_LIB} coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
 endif()
 
-if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION AND IDF_BUILD_ARTIFACTS)
+if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION)
+    idf_build_get_property(build_dir BUILD_DIR)
     partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset")
-    set(phy_init_data_bin "${IDF_BUILD_ARTIFACTS_DIR}/phy_init_data.bin")
+    set(phy_init_data_bin "${build_dir}/phy_init_data.bin")
+
     # To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy
     # the object file to a raw binary
     add_custom_command(
         OUTPUT ${phy_init_data_bin}
-        DEPENDS ${CMAKE_CURRENT_LIST_DIR}/include/phy_init_data.h
+        DEPENDS ${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
         COMMAND ${CMAKE_C_COMPILER} -x c -c
-        -I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${IDF_BUILD_ARTIFACTS_DIR}
+        -I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${build_dir}
         -o phy_init_data.obj
-        ${CMAKE_CURRENT_LIST_DIR}/include/phy_init_data.h
+        ${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
         COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin}
         )
     add_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin})
-    add_dependencies(flash phy_init_data)
+    add_dependencies(app phy_init_data)
 
     esptool_py_flash_project_args(phy ${phy_partition_offset} ${phy_init_data_bin} FLASH_IN_PROJECT)
-
-endif()
+endif()
\ No newline at end of file
index 4c300eadc64cd857c6b02819820510db107893e8..26798f3f43027cb7fbe42610dc9a7724eab62345 100644 (file)
@@ -5,20 +5,21 @@ set(COMPONENT_REQUIRES unity test_utils nvs_flash ulp esp_common)
 
 register_component()
 
+idf_build_get_property(idf_path IDF_PATH)
 # Calculate MD5 value of header file esp_wifi_os_adapter.h
-execute_process(COMMAND md5sum ${IDF_PATH}/components/esp_wifi/include/esp_private/wifi_os_adapter.h
+execute_process(COMMAND md5sum ${idf_path}/components/esp_wifi/include/esp_wifi_os_adapter.h
                 COMMAND cut -c 1-7
                 OUTPUT_VARIABLE WIFI_OS_ADAPTER_MD5
                 OUTPUT_STRIP_TRAILING_WHITESPACE)
 
 # Calculate MD5 value of header file esp_wifi_crypto_types.h
-execute_process(COMMAND md5sum ${IDF_PATH}/components/esp_wifi/include/esp_wifi_crypto_types.h
+execute_process(COMMAND md5sum ${idf_path}/components/esp_wifi/include/esp_wifi_crypto_types.h
                 COMMAND cut -c 1-7
                 OUTPUT_VARIABLE WIFI_CRYPTO_MD5
                 OUTPUT_STRIP_TRAILING_WHITESPACE)
 
 # Calculate MD5 value of header file esp_coexist_adapter.h
-execute_process(COMMAND md5sum ${IDF_PATH}/components/esp_wifi/include/esp_coexist_adapter.h
+execute_process(COMMAND md5sum ${idf_path}/components/esp_wifi/include/esp_coexist_adapter.h
                 COMMAND cut -c 1-7
                 OUTPUT_VARIABLE COEX_ADAPTER_MD5
                 OUTPUT_STRIP_TRAILING_WHITESPACE)
index 52c416a48f2240a032b48d8b30afc31dcce7e7e1..8ef4c1ce70ddbc9479ff72e8cd75308f7a488901 100644 (file)
@@ -1,6 +1,5 @@
 set(COMPONENT_PRIV_INCLUDEDIRS "include_core_dump")
 set(COMPONENT_ADD_INCLUDEDIRS "include")
-set(COMPONENT_REQUIRES)
 set(COMPONENT_PRIV_REQUIRES spi_flash soc)
 set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
 set(COMPONENT_SRCS "src/core_dump_common.c"
index 87b5eb257bca5c729e693a67a10806b1052b47e5..d20de8b245982d5b5abe509996acbf3c8f9ba8da 100644 (file)
@@ -1,6 +1,5 @@
 register_config_only_component()
 
-if(IDF_BUILD_ARTIFACTS)
 string(REPLACE ";" " " ESPTOOLPY_FLASH_PROJECT_OPTIONS "${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS}")
 set(ESPTOOLPY_FLASH_PROJECT_OPTIONS
     "${ESPTOOLPY_FLASH_PROJECT_OPTIONS}"
@@ -13,15 +12,27 @@ endif()
 # Generate the flash project args and the flasher args json file using the accumulated values
 # from esptool_py_flash_project_args calls. The file is first configured using configure_file() for all variable values,
 # and then generated using file(GENERATE... for generator expressions.
-configure_file(${COMPONENT_PATH}/flash_project_args.in
+configure_file(${COMPONENT_DIR}/flash_project_args.in
                ${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in)
 
-file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flash_project_args
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in2
               INPUT ${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in)
+file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flash_project_args
+              INPUT ${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in2)
 
-configure_file(${COMPONENT_PATH}/flasher_args.json.in
+configure_file(${COMPONENT_DIR}/flasher_args.json.in
                ${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in)
 
-file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flasher_args.json
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in2
               INPUT ${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in)
-endif()
\ No newline at end of file
+file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/flasher_args.json
+              INPUT ${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in2)
+
+set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+    "${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in"
+    "${CMAKE_CURRENT_BINARY_DIR}/flash_project_args.in2"
+    "${CMAKE_BINARY_DIR}/flash_project_args"
+    "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in"
+    "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in2"
+    "${CMAKE_BINARY_DIR}/flasher_args.json")
index 243acea50b57a69c112a40b0e4a34dc8e4c24451..12c2b84d75d0cc8135ea1816d9bd179cc87154a3 100644 (file)
@@ -1,13 +1,10 @@
-if(NOT IDF_BUILD_ARTIFACTS)
-    return()
-endif()
-
 # Set some global esptool.py variables
 #
 # Many of these are read when generating flash_app_args & flash_project_args
-set(ESPTOOLPY ${PYTHON} "${CMAKE_CURRENT_LIST_DIR}/esptool/esptool.py" --chip esp32)
-set(ESPSECUREPY ${PYTHON} "${CMAKE_CURRENT_LIST_DIR}/esptool/espsecure.py")
-set(ESPEFUSEPY ${PYTHON} "${CMAKE_CURRENT_LIST_DIR}/esptool/espefuse.py")
+idf_build_get_property(python PYTHON)
+set(ESPTOOLPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/esptool.py" --chip esp32)
+set(ESPSECUREPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espsecure.py")
+set(ESPEFUSEPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espefuse.py")
 
 set(ESPFLASHMODE ${CONFIG_ESPTOOLPY_FLASHMODE})
 set(ESPFLASHFREQ ${CONFIG_ESPTOOLPY_FLASHFREQ})
@@ -62,44 +59,51 @@ if(CONFIG_ESPTOOLPY_FLASHSIZE_DETECT)
     set(ESPFLASHSIZE detect)
 endif()
 
-get_filename_component(IDF_PROJECT_NAME ${IDF_PROJECT_EXECUTABLE} NAME_WE)
+idf_build_get_property(build_dir BUILD_DIR)
+
+idf_build_get_property(elf_name EXECUTABLE_NAME GENERATOR_EXPRESSION)
+idf_build_get_property(elf EXECUTABLE GENERATOR_EXPRESSION)
+
 if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES AND NOT BOOTLOADER_BUILD)
-    set(unsigned_project_binary "${IDF_PROJECT_NAME}-unsigned.bin")
+    set(unsigned_project_binary "${elf_name}-unsigned.bin")
 else()
-    set(unsigned_project_binary "${IDF_PROJECT_NAME}.bin")
+    set(unsigned_project_binary "${elf_name}.bin")
 endif()
 
+set(PROJECT_BIN "${elf_name}.bin")
+
 #
 # Add 'app.bin' target - generates with elf2image
 #
-add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}"
+add_custom_command(OUTPUT "${build_dir}/.app_hash"
     COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} ${ESPTOOLPY_ELF2IMAGE_OPTIONS}
-        -o "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}" "${IDF_PROJECT_EXECUTABLE}"
-    DEPENDS ${IDF_PROJECT_EXECUTABLE}
+        -o "${build_dir}/${unsigned_project_binary}" "${elf}"
+    COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.app_hash"
+    DEPENDS ${elf}
     VERBATIM
-    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    WORKING_DIRECTORY ${build_dir}
     )
-
-get_filename_component(IDF_PROJECT_BIN ${IDF_PROJECT_EXECUTABLE} NAME_WE)
-set(IDF_PROJECT_BIN ${IDF_PROJECT_BIN}.bin)
+add_custom_target(gen_project_binary DEPENDS "${build_dir}/.app_hash")
 
 if(NOT BOOTLOADER_BUILD AND
     CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
 
     # for locally signed secure boot image, add a signing step to get from unsigned app to signed app
-    add_custom_target(gen_unsigned_project_binary ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}")
-    add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}"
+    add_custom_command(OUTPUT "${build_dir}/.signed_app_hash"
         COMMAND ${ESPSECUREPY} sign_data --keyfile ${secure_boot_signing_key}
-            -o "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}" "${IDF_BUILD_ARTIFACTS_DIR}/${unsigned_project_binary}"
-        DEPENDS gen_unsigned_project_binary
+            -o "${build_dir}/${PROJECT_BIN}" "${build_dir}/${unsigned_project_binary}"
+        COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${PROJECT_BIN}" > "${build_dir}/.signed_app_hash"
+        DEPENDS "${build_dir}/.app_hash"
         VERBATIM
         )
+    add_custom_target(gen_signed_project_binary DEPENDS "${build_dir}/.signed_app_hash")
+    add_dependencies(gen_project_binary gen_signed_project_binary)
 endif()
 
 if(NOT BOOTLOADER_BUILD)
-    add_custom_target(app ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}")
+    add_custom_target(app ALL DEPENDS gen_project_binary)
 else()
-    add_custom_target(bootloader ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}")
+    add_custom_target(bootloader ALL DEPENDS gen_project_binary)
 endif()
 
 if(NOT BOOTLOADER_BUILD AND
@@ -109,7 +113,7 @@ if(NOT BOOTLOADER_BUILD AND
         COMMAND ${CMAKE_COMMAND} -E echo
             "App built but not signed. Sign app before flashing"
         COMMAND ${CMAKE_COMMAND} -E echo
-            "\t${ESPSECUREPY} sign_data --keyfile KEYFILE ${IDF_BUILD_ARTIFACTS_DIR}/${IDF_PROJECT_BIN}"
+            "\t${ESPSECUREPY} sign_data --keyfile KEYFILE ${build_dir}/${elf_bin}"
         VERBATIM)
 endif()
 
@@ -117,12 +121,13 @@ endif()
 # Add 'flash' target - not all build systems can run this directly
 #
 function(esptool_py_custom_target target_name flasher_filename dependencies)
+    idf_build_get_property(idf_path IDF_PATH)
     add_custom_target(${target_name} DEPENDS ${dependencies}
         COMMAND ${CMAKE_COMMAND}
-        -D IDF_PATH="${IDF_PATH}"
+        -D IDF_PATH="${idf_path}"
         -D ESPTOOLPY="${ESPTOOLPY}"
         -D ESPTOOL_ARGS="write_flash;@flash_${flasher_filename}_args"
-        -D ESPTOOL_WORKING_DIR="${IDF_BUILD_ARTIFACTS_DIR}"
+        -D ESPTOOL_WORKING_DIR="${build_dir}"
         -P run_esptool.cmake
         WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
         USES_TERMINAL
@@ -142,8 +147,9 @@ function(esptool_py_flash_project_args entry offset image)
     set(options FLASH_IN_PROJECT)  # flash the image when flashing the project
     set(single_value FLASH_FILE_TEMPLATE) # template file to use to be able to
                                         # flash the image individually using esptool
-    cmake_parse_arguments(flash_entry "${options}" "${single_value}" "" "${ARGN}")
+    cmake_parse_arguments(_ "${options}" "${single_value}" "" "${ARGN}")
 
+    idf_build_get_property(build_dir BUILD_DIR)
     get_property(flash_project_entries TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ENTRIES)
 
     if(${entry} IN_LIST flash_project_entries)
@@ -156,14 +162,16 @@ function(esptool_py_flash_project_args entry offset image)
     file(RELATIVE_PATH image ${CMAKE_BINARY_DIR} ${image})
 
     # Generate the standalone flash file to flash the image individually using esptool
-    set(entry_flash_args ${IDF_BUILD_ARTIFACTS_DIR}/flash_${entry}_args)
-    if(NOT flash_entry_FLASH_FILE_TEMPLATE)
+    set(entry_flash_args ${build_dir}/flash_${entry}_args)
+    if(NOT __FLASH_FILE_TEMPLATE)
         file(GENERATE OUTPUT ${entry_flash_args} CONTENT "${offset} ${image}")
     else()
-        configure_file(${flash_entry_FLASH_FILE_TEMPLATE} ${entry_flash_args})
+        get_filename_component(template "${__FLASH_FILE_TEMPLATE}" ABSOLUTE)
+        file(GENERATE OUTPUT ${entry_flash_args} INPUT ${template})
     endif()
 
-    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${entry_flash_args})
+    set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+                APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${entry_flash_args})
 
     # Generate standalone entries in the flasher args json file
     get_property(flash_project_args_entry_json TARGET
@@ -174,7 +182,7 @@ function(esptool_py_flash_project_args entry offset image)
                 PROPERTY FLASH_PROJECT_ARGS_ENTRY_JSON "${flash_project_args_entry_json}")
 
     # Generate entries in the flasher args json file
-    if(flash_entry_FLASH_IN_PROJECT)
+    if(__FLASH_IN_PROJECT)
         get_property(flash_project_args TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS)
         list(APPEND flash_project_args "${offset} ${image}")
         set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS "${flash_project_args}")
index 821705658a5056a1bd4489475dc26b9e4a87a5d7..596aee917c29f48b5ef775508b75e465aea3d0f1 100644 (file)
@@ -5,15 +5,12 @@ set(COMPONENT_SRCS "expat/expat/lib/loadlibrary.c"
                    "expat/expat/lib/xmltok.c"
                    "expat/expat/lib/xmltok_impl.c"
                    "expat/expat/lib/xmltok_ns.c")
-
-set(COMPONENT_REQUIRES)
-
 register_component()
 
-component_compile_definitions(HAVE_EXPAT_CONFIG_H)
-component_compile_definitions(HAVE_GETRANDOM)
+target_compile_definitions(${COMPONENT_LIB} PRIVATE HAVE_EXPAT_CONFIG_H)
+target_compile_definitions(${COMPONENT_LIB} PRIVATE HAVE_GETRANDOM)
 
 # Temporary suppress "fallthrough" warnings until they are fixed in expat repo
 if(GCC_NOT_5_2_0)
-    component_compile_options(-Wno-implicit-fallthrough)
+    target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough)
 endif()
\ No newline at end of file
index 2de3d445ea385ae428f65c4f620f35d3c5ab3795..4b57c166198d75111a0d184625e554d5a91dec4b 100644 (file)
@@ -1,7 +1,5 @@
 # The following five lines of boilerplate have to be in your project's
 # CMakeLists in this exact order for cmake to work correctly
-cmake_minimum_required(VERSION 3.5)
-
 set(COMPONENT_SRCS  "common/esp_modbus_master.c"
                     "common/esp_modbus_slave.c"
                     "modbus/mb.c"
index da20a822fbb0478a713a542576c666a5042fa402..dec33874150053eb93ded7ef89de81d7d14ec8f1 100644 (file)
@@ -25,7 +25,7 @@ set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
 
 register_component()
 
-target_link_libraries(${COMPONENT_TARGET} "-Wl,--undefined=uxTopUsedPriority")
+target_link_libraries(${COMPONENT_LIB} "-Wl,--undefined=uxTopUsedPriority")
 
 set_source_files_properties(
     tasks.c
index e95ed9e11d7b76a01338466cdf052e50ec78e0f7..f27665d5fef949a3355670dfa08d55ef0d46dede 100644 (file)
@@ -16,9 +16,7 @@ endif()
 
 set(COMPONENT_ADD_INCLUDEDIRS "include")
 set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
-set(COMPONENT_REQUIRES "")
 set(COMPONENT_PRIV_REQUIRES soc)
-
 register_component()
 
 if(CONFIG_HEAP_TRACING)
@@ -34,7 +32,7 @@ if(CONFIG_HEAP_TRACING)
         heap_caps_realloc_default)
 
     foreach(wrap ${WRAP_FUNCTIONS})
-        target_link_libraries(${COMPONENT_TARGET} "-Wl,--wrap=${wrap}")
+        target_link_libraries(${COMPONENT_LIB} "-Wl,--wrap=${wrap}")
     endforeach()
 
 endif()
index cf64054dd8bf583c9463f8b6b6ac356e0fa2a436..e307838a8b2d096e8fc025f0144306699eb4b32c 100644 (file)
@@ -1,3 +1,2 @@
 set(COMPONENT_ADD_INCLUDEDIRS "include")
-set(COMPONENT_REQUIRES)
 register_component()
index f6776023f9469a7e3b72e75f8250e37c58c3376b..562a2cadcbfed81c931913f9b51ba0b4ea741baf 100644 (file)
@@ -1,6 +1,3 @@
 set(COMPONENT_SRCS "src/jsmn.c")
 set(COMPONENT_ADD_INCLUDEDIRS "include")
-
-set(COMPONENT_REQUIRES "")
-
 register_component()
index 9535315e5bdebadb47d456203aa91076fd817dcb..4a85a0b3d1985a8644156e5072e930e21c0a8b07 100644 (file)
@@ -2,7 +2,4 @@ set(COMPONENT_SRCS "cJSON/cJSON.c"
                    "cJSON/cJSON_Utils.c"
                    "cJSON/test.c")
 set(COMPONENT_ADD_INCLUDEDIRS cJSON)
-
-set(COMPONENT_REQUIRES "")
-
 register_component()
index 4ee2f20b32afda1bc02dae719f4208656ada9a47..f0d5afc9da4bb2c6ef70a1d2e957d16ac4dda708 100644 (file)
@@ -1,7 +1,4 @@
 set(SRC libsodium/src/libsodium)
-
-set(COMPONENT_REQUIRES "mbedtls")
-
 # Derived from libsodium/src/libsodium/Makefile.am
 # (ignoring the !MINIMAL set)
 set(COMPONENT_SRCS "${SRC}/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c"
@@ -129,9 +126,10 @@ endif()
 set(COMPONENT_ADD_INCLUDEDIRS ${SRC}/include port_include)
 set(COMPONENT_PRIV_INCLUDEDIRS ${SRC}/include/sodium port_include/sodium port)
 
+set(COMPONENT_REQUIRES mbedtls vfs)
 register_component()
 
-component_compile_definitions(
+target_compile_definitions(${COMPONENT_LIB} PRIVATE 
     CONFIGURED
     NATIVE_LITTLE_ENDIAN
     HAVE_WEAK_SYMBOLS
index 75d55ddc473be48ddbe8b819462f73ae27425788..505dc931864bf2cff40692a52f4d647f21e53f30 100644 (file)
@@ -1,5 +1,4 @@
 set(COMPONENT_SRCS "log.c")
 set(COMPONENT_ADD_INCLUDEDIRS "include")
-set(COMPONENT_REQUIRES)
 set(COMPONENT_PRIV_REQUIRES soc)
 register_component()
index 1c2efc977104827b0182119af071e494d8c09a51..0a79a20daf88d119a83ced952a792da0ba16b1bf 100644 (file)
@@ -130,7 +130,7 @@ set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
 register_component()
 
 # lots of LWIP source files evaluate macros that check address of stack variables
-component_compile_options(-Wno-address)
+target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-address)
 
 if(GCC_NOT_5_2_0)
     set_source_files_properties(
index 09abc2fff08bd224e4a9ffa6e0133f622cba68a0..3b1fd504e21e6a663201205060d4475e867320ae 100644 (file)
@@ -18,7 +18,7 @@ function(project)
 endfunction()
 
 # Needed to for include_next includes to work from within mbedtls
-include_directories("${COMPONENT_PATH}/port/include")
+include_directories("${COMPONENT_DIR}/port/include")
 
 # Workaround issue with creating symbolic links due to issues with native
 # path conversion (TO_NATIVE_PATH). The following summarizes what CMake invocations
@@ -46,20 +46,21 @@ if(CMAKE_HOST_WIN32)
                         "mbedtls/scripts")
         foreach(target_link ${target_links})
             file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${target_link} link)
-            file(TO_NATIVE_PATH ${COMPONENT_PATH}/${target_link} target)
+            file(TO_NATIVE_PATH ${COMPONENT_DIR}/${target_link} target)
 
+            idf_build_get_property(python PYTHON)
             if(NOT EXISTS ${link})
-                if (IS_DIRECTORY ${target})
-                    set(command ${PYTHON} ${COMPONENT_PATH}/mklink.py /j ${link} ${target})
+                if(IS_DIRECTORY ${target})
+                    set(command ${python} ${COMPONENT_DIR}/mklink.py /j ${link} ${target})
                 else()
-                    set(command ${PYTHON} ${COMPONENT_PATH}/mklink.py /h ${link} ${target})
+                    set(command ${python} ${COMPONENT_DIR}/mklink.py /h ${link} ${target})
                 endif()
 
                 execute_process(COMMAND ${command}
                     RESULT_VARIABLE result
                     ERROR_VARIABLE output)
 
-                if (NOT ${result} EQUAL 0)
+                if(NOT ${result} EQUAL 0)
                     message(FATAL_ERROR "Could not create symbolic link for: ${target} --> ${output}")
                 endif()
             endif()
@@ -78,37 +79,26 @@ 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_PATH}/port/esp_bignum.c"
-                                "${COMPONENT_PATH}/port/esp_hardware.c"
-                                "${COMPONENT_PATH}/port/esp_mem.c"
+target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/esp_bignum.c"
+                                "${COMPONENT_DIR}/port/esp_hardware.c"
                                 "${COMPONENT_PATH}/port/esp_sha.c"
-                                "${COMPONENT_PATH}/port/esp_sha1.c"
-                                "${COMPONENT_PATH}/port/esp_sha256.c"
-                                "${COMPONENT_PATH}/port/esp_sha512.c"
-                                "${COMPONENT_PATH}/port/mbedtls_debug.c"
-                                "${COMPONENT_PATH}/port/net_sockets.c"
-                                "${COMPONENT_PATH}/port/esp32/aes.c"
-                                "${COMPONENT_PATH}/port/esp32/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})
-    # Propagate compile options to mbedtls library targets
-    target_include_directories(${target} PRIVATE "${IDF_INCLUDE_DIRECTORIES}")
-    target_compile_options(${target} PRIVATE "${IDF_COMPILE_OPTIONS};${IDF_C_COMPILE_OPTIONS}")
-    target_compile_definitions(${target} PRIVATE "${IDF_COMPILE_DEFINITIONS}")
     target_compile_definitions(${target} PUBLIC -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h")
-
-    # The mbedtls targets also depends on core components
-    foreach(common ${MBEDTLS_PRIV_REQUIRES})
-        component_get_target(common_target ${common})
-        set_property(TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${common_target})
-        set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES ${common_target})
-    endforeach()
 endforeach()
 
 # Link mbedtls libraries to component library
-target_link_libraries(${COMPONENT_TARGET} ${mbedtls_targets})
+target_link_libraries(${COMPONENT_LIB} ${mbedtls_targets})
 
 # Catch usage of deprecated mbedTLS functions when building tests
 if(mbedtls_test IN_LIST BUILD_TEST_COMPONENTS)
     add_definitions(-DMBEDTLS_DEPRECATED_WARNING)
-endif()
+endif()
\ No newline at end of file
index 75ab43003ff504ea7428b567599545aa7ea26cad..627f092e8052fc6d18adb955c89f6e6326cd6b9b 100644 (file)
@@ -63,12 +63,21 @@ list(APPEND COMPONENT_ADD_LDFRAGMENTS newlib.lf)
 register_component()
 
 if (LIB_PATH)
-    target_link_libraries(${COMPONENT_TARGET} "-L ${LIB_PATH}")
+    target_link_libraries(${COMPONENT_LIB} "-L ${LIB_PATH}")
+endif()
+
+if(GCC_NOT_5_2_0)
+    # Toolchain libraries require code defined in this component
+    add_library(extra INTERFACE)
+    idf_component_get_property(newlib newlib COMPONENT_LIB)
+    target_link_libraries(extra INTERFACE ${LIBC} ${LIBM} "$<TARGET_FILE:${newlib}>")
+    target_link_libraries(${COMPONENT_LIB} extra)
+else()
+    target_link_libraries(${COMPONENT_LIB} ${LIBC} ${LIBM})
 endif()
-target_link_libraries(${COMPONENT_TARGET} ${LIBC} ${LIBM})
 
 set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
 
 if(EXTRA_LINK_FLAGS)
-    target_link_libraries(${COMPONENT_TARGET} "${EXTRA_LINK_FLAGS}")
+    target_link_libraries(${COMPONENT_LIB} "${EXTRA_LINK_FLAGS}")
 endif()
index d42e5b85c245ebd9a6e09dcb8a4f784e0bb0c4b0..6fe75a660efd82115aedade61a2a92f093f72ba6 100644 (file)
@@ -1,6 +1,8 @@
 register_config_only_component()
 
-if(NOT BOOTLOADER_BUILD AND IDF_BUILD_ARTIFACTS)
+if(BOOTLOADER_BUILD)
+    return()
+endif()
 
 set(partition_csv "${PARTITION_CSV_PATH}")
 
@@ -28,28 +30,31 @@ else()
     set(partition_secure_opt "")
 endif()
 
-add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}"
-    COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
+idf_build_get_property(build_dir BUILD_DIR)
+idf_build_get_property(python PYTHON)
+
+add_custom_command(OUTPUT "${build_dir}/partition_table/${unsigned_partition_bin}"
+    COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
     -q --offset ${PARTITION_TABLE_OFFSET} ${md5_opt} ${flashsize_opt}
-    ${partition_secure_opt} ${partition_csv} ${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}
+    ${partition_secure_opt} ${partition_csv} ${build_dir}/partition_table/${unsigned_partition_bin}
     DEPENDS ${partition_csv} "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py"
     VERBATIM)
 
 # Add signing steps
 if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
     add_custom_target(gen_unsigned_partition_bin ALL DEPENDS
-                    "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}")
+                    "${build_dir}/partition_table/${unsigned_partition_bin}")
 
-    add_custom_command(OUTPUT "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}"
+    add_custom_command(OUTPUT "${build_dir}/partition_table/${final_partition_bin}"
         COMMAND ${ESPSECUREPY} sign_data --keyfile "${secure_boot_signing_key}"
-        -o "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}"
-        "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}"
-        DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}"
+        -o "${build_dir}/partition_table/${final_partition_bin}"
+        "${build_dir}/partition_table/${unsigned_partition_bin}"
+        DEPENDS "${build_dir}/partition_table/${unsigned_partition_bin}"
         VERBATIM)
 endif()
 
 if(EXISTS ${partition_csv})
-    add_custom_target(partition_table ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}")
+    add_custom_target(partition_table ALL DEPENDS "${build_dir}/partition_table/${final_partition_bin}")
 else()
     # If the partition input CSV is not found, create a phony partition_table target that
     # fails the build. fail_at_build_time also touches CMakeCache.txt to cause a cmake run next time
@@ -86,15 +91,12 @@ add_dependencies(app partition_table)
 # the list of esptool write arguments for flashing
 set_property(GLOBAL APPEND_STRING PROPERTY
     ESPTOOL_WRITE_FLASH_ARGS
-    "${PARTITION_TABLE_OFFSET}  ${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin} ")
+    "${PARTITION_TABLE_OFFSET}  ${build_dir}/partition_table/${final_partition_bin} ")
 
 esptool_py_flash_project_args(partition_table ${PARTITION_TABLE_OFFSET}
-                              ${IDF_BUILD_ARTIFACTS_DIR}/partition_table/partition-table.bin FLASH_IN_PROJECT)
+                              ${build_dir}/partition_table/partition-table.bin FLASH_IN_PROJECT)
 
-if (NOT BOOTLOADER_BUILD)
-    partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset")
-    esptool_py_flash_project_args(app ${app_partition_offset} ${CMAKE_BINARY_DIR}/${IDF_PROJECT_BIN} FLASH_IN_PROJECT)
-endif()
+partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset")
+esptool_py_flash_project_args(app ${app_partition_offset} ${build_dir}/${PROJECT_BIN} FLASH_IN_PROJECT)
 
-endif()
 
index 850c8e9df8bbf69077aa0953e5f1c4fa3f82135f..d8e31c7d1defe1f5e7104789d6f7b73e0c1168ed 100644 (file)
@@ -1,38 +1,42 @@
 if(NOT BOOTLOADER_BUILD)
-set(PARTITION_TABLE_OFFSET ${CONFIG_PARTITION_TABLE_OFFSET})
+    set(PARTITION_TABLE_OFFSET ${CONFIG_PARTITION_TABLE_OFFSET})
 
-# Set PARTITION_CSV_PATH to the configured partition CSV file
-# absolute path
-if(CONFIG_PARTITION_TABLE_CUSTOM)
-    # Custom filename expands any path relative to the project
-    get_filename_component(PARTITION_CSV_PATH "${CONFIG_PARTITION_TABLE_FILENAME}"
-                            ABSOLUTE BASE_DIR "${IDF_PROJECT_PATH}")
+    # Set PARTITION_CSV_PATH to the configured partition CSV file
+    # absolute path
+    if(CONFIG_PARTITION_TABLE_CUSTOM)
+        idf_build_get_property(project_dir PROJECT_DIR)
+        # Custom filename expands any path relative to the project
+        get_filename_component(PARTITION_CSV_PATH "${CONFIG_PARTITION_TABLE_FILENAME}"
+                                ABSOLUTE BASE_DIR "${project_dir}")
 
-    if(NOT EXISTS "${PARTITION_CSV_PATH}")
-        message(WARNING "Partition table CSV file ${PARTITION_CSV_PATH} not found. "
-            "Change custom partition CSV path in menuconfig.")
-        # Note: partition_table CMakeLists.txt contains some logic to create a dummy
-        # partition_table target in this case, see comments in that file.
-    endif()
-else()
-    # Other .csv files are always in the component directory
-    get_filename_component(PARTITION_CSV_PATH "${COMPONENT_PATH}/${CONFIG_PARTITION_TABLE_FILENAME}" ABSOLUTE)
+        if(NOT EXISTS "${PARTITION_CSV_PATH}")
+            message(WARNING "Partition table CSV file ${PARTITION_CSV_PATH} not found. "
+                "Change custom partition CSV path in menuconfig.")
+            # Note: partition_table CMakeLists.txt contains some logic to create a dummy
+            # partition_table target in this case, see comments in that file.
+        endif()
+    else()
+        # Other .csv files are always in the component directory
+        get_filename_component(PARTITION_CSV_PATH "${COMPONENT_DIR}/${CONFIG_PARTITION_TABLE_FILENAME}" ABSOLUTE)
 
-    if(NOT EXISTS "${PARTITION_CSV_PATH}")
-        message(FATAL_ERROR "Internal error, built-in ${PARTITION_CSV_PATH} not found.")
+        if(NOT EXISTS "${PARTITION_CSV_PATH}")
+            message(FATAL_ERROR "Internal error, built-in ${PARTITION_CSV_PATH} not found.")
+        endif()
     endif()
-endif()
 
-# need to re-run CMake if the partition CSV changes, as the offsets/sizes of partitions may change
-set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PARTITION_CSV_PATH})
+    # need to re-run CMake if the partition CSV changes, as the offsets/sizes of partitions may change
+    set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PARTITION_CSV_PATH})
+endif()
 
 # partition_table_get_partition_info
 #
 # Get information about a partition from the partition table
 function(partition_table_get_partition_info result get_part_info_args part_info)
+    idf_build_get_property(python PYTHON)
+    idf_build_get_property(idf_path IDF_PATH)
     separate_arguments(get_part_info_args)
-    execute_process(COMMAND ${PYTHON}
-        ${IDF_PATH}/components/partition_table/parttool.py -q
+    execute_process(COMMAND ${python}
+        ${idf_path}/components/partition_table/parttool.py -q
         --partition-table-offset ${PARTITION_TABLE_OFFSET}
         --partition-table-file ${PARTITION_CSV_PATH}
         ${get_part_info_args} get_partition_info --info ${part_info}
@@ -45,5 +49,3 @@ function(partition_table_get_partition_info result get_part_info_args part_info)
     endif()
     set(${result} ${info} PARENT_SCOPE)
 endfunction()
-endif()
-
index d793a12e32e158c3f08cc1a62f9c91ee291b67fe..cf727293f6824202ed5d6af7cc268e87adfe6ddd 100644 (file)
@@ -2,9 +2,8 @@ set(COMPONENT_SRCS "pthread.c"
                    "pthread_cond_var.c"
                    "pthread_local_storage.c")
 set(COMPONENT_ADD_INCLUDEDIRS "include")
-set(COMPONENT_REQUIRES)
 register_component()
 
 if(CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK)
-    target_link_libraries(${COMPONENT_TARGET} "-Wl,--wrap=vPortCleanUpTCB")
+    target_link_libraries(${COMPONENT_LIB} "-Wl,--wrap=vPortCleanUpTCB")
 endif()
index d2c739de1e3bd9975e3612da088103de44bb3d90..2c52f2a27c55ed9c500780bea6c17727a8cd14e5 100644 (file)
@@ -1,11 +1,11 @@
-set(SOC_NAME ${IDF_TARGET})
+idf_build_get_property(soc_name IDF_TARGET)
 
-if(EXISTS "${COMPONENT_PATH}/${SOC_NAME}")
-    include(${COMPONENT_PATH}/${SOC_NAME}/sources.cmake)
+if(EXISTS "${COMPONENT_DIR}/${soc_name}")
+    include(${COMPONENT_DIR}/${soc_name}/sources.cmake)
 
     spaces2list(SOC_SRCS)
-    add_prefix(COMPONENT_SRCS "${SOC_NAME}/" ${SOC_SRCS})
-    set(COMPONENT_ADD_INCLUDEDIRS ${SOC_NAME}/include)
+    add_prefix(COMPONENT_SRCS "${soc_name}/" ${SOC_SRCS})
+    set(COMPONENT_ADD_INCLUDEDIRS ${soc_name}/include)
 endif()
 
 list(APPEND COMPONENT_ADD_INCLUDEDIRS include)
index b70b4b5fd9419df8bb8437bec0ee894537b2f572..276f56651ac52e6954a55623685df84c9b682e2c 100644 (file)
@@ -1,8 +1,8 @@
-set(SOC_NAME ${IDF_TARGET})
-set(SOC_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../${SOC_NAME}/test)
-if(EXISTS "${SOC_TEST_DIR}")
-    set(COMPONENT_SRCDIRS "${SOC_TEST_DIR}")
-    set(COMPONENT_ADD_INCLUDEDIRS "${SOC_TEST_DIR}")
+idf_build_get_property(soc_name IDF_TARGET)
+get_filename_component(soc_test "${CMAKE_CURRENT_SOURCE_DIR}/../${soc_name}/test" ABSOLUTE)
+if(EXISTS "${soc_test}")
+    set(COMPONENT_SRCS "${soc_test}")
+    set(COMPONENT_ADD_INCLUDEDIRS "${soc_test}")
 endif()
 
 set(COMPONENT_REQUIRES unity test_utils)
index 3ecc19eb0ad3d7b3045576ed8e294d4ae536c74d..be290e7c321aef46dba5847a8c4d66b5c9a7bd42 100644 (file)
@@ -13,8 +13,6 @@ else()
 endif()
 
 set(COMPONENT_ADD_INCLUDEDIRS include)
-set(COMPONENT_REQUIRES)
-
 set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
 
 register_component()
index 2ca13c184169a3f6a4b48d08e90413dc89d3cc48..19fc96ed7a0c2e61ca64bebc6ae2b36debe27e5e 100644 (file)
@@ -6,7 +6,8 @@ function(spiffs_create_partition_image partition base_dir)
     set(options FLASH_IN_PROJECT)
     cmake_parse_arguments(arg "${options}" "" "" "${ARGN}")
 
-    set(spiffsgen_py ${PYTHON} ${IDF_PATH}/components/spiffs/spiffsgen.py)
+    idf_build_get_property(idf_path IDF_PATH)
+    set(spiffsgen_py ${PYTHON} ${idf_path}/components/spiffs/spiffsgen.py)
 
     get_filename_component(base_dir_full_path ${base_dir} ABSOLUTE)
 
index 9c71467b3977bd0737df0170e135ee20e23af866..ca8d115c396e4900c7ef83ecaa59733ed1246fc4 100644 (file)
@@ -1,7 +1,4 @@
 set(COMPONENT_SRCS "ulp.c"
                    "ulp_macro.c")
 set(COMPONENT_ADD_INCLUDEDIRS "include")
-
-set(COMPONENT_REQUIRES)
-
 register_component()
index 49654e84f4bbb3f01246fa1305fc0543bea86fd8..50e8c8e42df6e9a493ff7c4fa6b3ce9b72dd564e 100644 (file)
@@ -38,7 +38,7 @@ foreach(include ${COMPONENT_INCLUDES})
 endforeach()
 
 list(APPEND ULP_PREPROCESSOR_ARGS ${component_includes})
-list(APPEND ULP_PREPROCESSOR_ARGS -I${COMPONENT_PATH})
+list(APPEND ULP_PREPROCESSOR_ARGS -I${COMPONENT_DIR})
 list(APPEND ULP_PREPROCESSOR_ARGS -I${sdkconfig_dir})
 
 include_directories(${component_includes})
index c42ada37e25440dee4fc4d2978be4fdca4d03840..0d2ec262abcfa532187f32db314c13f5cc6b1b44 100644 (file)
@@ -25,19 +25,23 @@ if(NOT CMAKE_BUILD_EARLY_EXPANSION)
     # the external ULP project. This is a workaround to the bug https://public.kitware.com/Bug/view.php?id=16137.
     string(REPLACE ";" "|" ulp_s_sources "${ulp_s_sources}")
 
+    idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
+    idf_build_get_property(idf_path IDF_PATH)
+    idf_build_get_property(python PYTHON)
     externalproject_add(${ULP_APP_NAME}
-        SOURCE_DIR ${IDF_PATH}/components/ulp/cmake
+        SOURCE_DIR ${idf_path}/components/ulp/cmake
         BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}
         INSTALL_COMMAND ""
         CMAKE_ARGS  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-                    -DCMAKE_TOOLCHAIN_FILE=${IDF_PATH}/components/ulp/cmake/toolchain-ulp.cmake
+                    -DCMAKE_TOOLCHAIN_FILE=${idf_path}/components/ulp/cmake/toolchain-ulp.cmake
                     -DULP_S_SOURCES=${ulp_s_sources} -DULP_APP_NAME=${ULP_APP_NAME}
-                    -DCOMPONENT_PATH=${COMPONENT_PATH}
+                    -DCOMPONENT_DIR=${COMPONENT_DIR}
                     # Even though this resolves to a ';' separated list, this is fine. This must be special behavior
                     # for generator expressions.
-                    -DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_TARGET},INTERFACE_INCLUDE_DIRECTORIES>
-                    -DIDF_PATH=${IDF_PATH}
-                    -DSDKCONFIG=${SDKCONFIG_HEADER}
+                    -DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_LIB},INTERFACE_INCLUDE_DIRECTORIES>
+                    -DIDF_PATH=${idf_path}
+                    -DSDKCONFIG=${sdkconfig_header}
+                    -DPYTHON=${python}
         BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME} --target build
         BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources}
                         ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}
@@ -52,8 +56,8 @@ if(NOT CMAKE_BUILD_EARLY_EXPANSION)
 
     add_custom_target(${ULP_APP_NAME}_artifacts DEPENDS ${ULP_APP_NAME})
 
-    add_dependencies(${COMPONENT_TARGET} ${ULP_APP_NAME}_artifacts)
+    add_dependencies(${COMPONENT_LIB} ${ULP_APP_NAME}_artifacts)
 
-    target_linker_script(${COMPONENT_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.ld)
-    target_add_binary_data(${COMPONENT_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.bin BINARY)
+    target_linker_script(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.ld)
+    target_add_binary_data(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}/${ULP_APP_NAME}.bin BINARY)
 endif()
\ No newline at end of file
index ad370eb1325f27214a2f1cc174c0a43de0958aa6..20a82c897f0b64a896a067570fdfcc2c15141b93 100644 (file)
@@ -8,4 +8,5 @@ register_component()
 set(ULP_APP_NAME ulp_test_app)
 set(ULP_S_SOURCES "ulp/test_jumps.S")
 set(ULP_EXP_DEP_SRCS "test_ulp_as.c")
-include(${IDF_PATH}/components/ulp/component_ulp_common.cmake)
+idf_build_get_property(idf_path IDF_PATH)
+include(${idf_path}/components/ulp/component_ulp_common.cmake)
\ No newline at end of file
index e76ffe9524de43e7a969d9f74bdd392d60c5d7bd..3f8ecac23068130e2c68d93a70f09d019d1eb407 100644 (file)
@@ -14,10 +14,10 @@ endif()
 
 register_component()
 
-target_compile_definitions(${COMPONENT_TARGET} PUBLIC
+target_compile_definitions(${COMPONENT_LIB} PUBLIC
     -DUNITY_INCLUDE_CONFIG_H
 )
 
 if(GCC_NOT_5_2_0)
-    component_compile_options(-Wno-unused-const-variable)
+    target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-const-variable)
 endif()
index 6089473eeb5b80d713528be5f8c9d67c5be17fbe..816e7a6d83652371325647fef9a0d1b4c1130399 100644 (file)
@@ -2,7 +2,4 @@ set(COMPONENT_SRCS "vfs.c"
                    "vfs_uart.c"
                    "vfs_semihost.c")
 set(COMPONENT_ADD_INCLUDEDIRS "include")
-
-set(COMPONENT_REQUIRES)
-
 register_component()
index c8be031a7b8e24ab5acb17e6d01f38e33732890a..35bf0bbdb337107771ab6d72753fd2ef6802fd2d 100644 (file)
@@ -79,8 +79,8 @@ set(COMPONENT_PRIV_REQUIRES mbedtls)
 
 register_component()
 
-component_compile_options(-Wno-strict-aliasing)
-component_compile_definitions(
+target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing)
+target_compile_definitions(${COMPONENT_LIB} PRIVATE
     __ets__
     EMBEDDED_SUPP
     IEEE8021X_EAPOL
index 74c3935faad243e2f7a4d819f24a8b00dc821346..9044f14ae16cad32b1037c6366095aa5e8a737a8 100644 (file)
@@ -7,4 +7,4 @@ set(COMPONENT_PRIV_REQUIRES soc)
 
 register_component()
 
-target_link_libraries(${COMPONENT_TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/${IDF_TARGET}/libhal.a")
+target_link_libraries(${COMPONENT_LIB} "${CMAKE_CURRENT_SOURCE_DIR}/${IDF_TARGET}/libhal.a")