cmake: Apply cmakelint fixes

This commit is contained in:
Angus Gratton 2020-11-10 17:51:08 +11:00 committed by bot
parent a7ae0ee1fa
commit e82eac4354
20 changed files with 105 additions and 60 deletions

View File

@ -1,6 +1,6 @@
set(asio_sources "asio/asio/src/asio.cpp")
if (CONFIG_ASIO_SSL_SUPPORT)
if(CONFIG_ASIO_SSL_SUPPORT)
if(CONFIG_ASIO_USE_ESP_OPENSSL)
list(APPEND asio_sources
"asio/asio/src/asio_ssl.cpp"
@ -17,7 +17,7 @@ idf_component_register(SRCS ${asio_sources}
INCLUDE_DIRS "asio/asio/include" "port/include"
REQUIRES lwip)
if (CONFIG_ASIO_SSL_SUPPORT)
if(CONFIG_ASIO_SSL_SUPPORT)
if(CONFIG_ASIO_USE_ESP_WOLFSSL)
idf_component_get_property(wolflib esp-wolfssl COMPONENT_LIB)
idf_component_get_property(wolfdir esp-wolfssl COMPONENT_DIR)

View File

@ -13,9 +13,14 @@ if(NOT CONFIG_SECURE_BOOT)
endif()
esptool_py_custom_target(bootloader-flash bootloader "bootloader")
esptool_py_flash_target_image(bootloader-flash bootloader ${CONFIG_BOOTLOADER_OFFSET_IN_FLASH} "${BOOTLOADER_BUILD_DIR}/bootloader.bin")
esptool_py_flash_target_image(bootloader-flash bootloader
${CONFIG_BOOTLOADER_OFFSET_IN_FLASH}
"${BOOTLOADER_BUILD_DIR}/bootloader.bin")
# Also attach an image to the project flash target
if(NOT CONFIG_SECURE_BOOT)
esptool_py_flash_target_image(flash bootloader ${CONFIG_BOOTLOADER_OFFSET_IN_FLASH} "${BOOTLOADER_BUILD_DIR}/bootloader.bin")
esptool_py_flash_target_image(flash bootloader
${CONFIG_BOOTLOADER_OFFSET_IN_FLASH}
"${BOOTLOADER_BUILD_DIR}/bootloader.bin")
endif()

View File

@ -15,7 +15,19 @@ if(NOT IDF_TARGET)
"in by the parent build process.")
endif()
set(COMPONENTS bootloader esptool_py esp_hw_support hal partition_table soc bootloader_support log spi_flash micro-ecc main efuse)
set(COMPONENTS
bootloader
esptool_py
esp_hw_support
hal
partition_table
soc
bootloader_support
log
spi_flash
micro-ecc
main
efuse)
set(BOOTLOADER_BUILD 1)
include("${IDF_PATH}/tools/cmake/project.cmake")
set(common_req log esp_rom esp_common esp_hw_support hal xtensa)
@ -87,7 +99,7 @@ if(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
DEPENDS gen_secure_bootloader_key gen_project_binary
VERBATIM)
add_custom_target (gen_bootloader_digest_bin ALL DEPENDS "${bootloader_digest_bin}")
add_custom_target(gen_bootloader_digest_bin ALL DEPENDS "${bootloader_digest_bin}")
endif()
if(CONFIG_SECURE_BOOT_V2_ENABLED)
@ -105,12 +117,14 @@ if(CONFIG_SECURE_BOOT_V2_ENABLED)
set(bootloader_unsigned_bin "bootloader-unsigned.bin")
add_custom_command(OUTPUT ".signed_bin_timestamp"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" "${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/${PROJECT_BIN}"
"${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${ESPSECUREPY} sign_data --version 2 --keyfile "${secure_boot_signing_key}"
-o "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" "${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${CMAKE_COMMAND} -E echo "Generated signed binary image ${build_dir}/${PROJECT_BIN}"
"from ${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" > "${CMAKE_BINARY_DIR}/.signed_bin_timestamp"
COMMAND ${CMAKE_COMMAND} -E md5sum "${CMAKE_BINARY_DIR}/${PROJECT_BIN}"
> "${CMAKE_BINARY_DIR}/.signed_bin_timestamp"
DEPENDS "${build_dir}/.bin_timestamp"
VERBATIM
COMMENT "Generated the signed Bootloader")
@ -120,7 +134,7 @@ if(CONFIG_SECURE_BOOT_V2_ENABLED)
COMMENT "Bootloader generated but not signed")
endif()
add_custom_target (gen_signed_bootloader ALL DEPENDS "${build_dir}/.signed_bin_timestamp")
add_custom_target(gen_signed_bootloader ALL DEPENDS "${build_dir}/.signed_bin_timestamp")
endif()
if(CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
@ -175,7 +189,8 @@ elseif(CONFIG_SECURE_BOOT_V2_ENABLED AND CONFIG_IDF_TARGET_ESP32S2)
COMMAND ${CMAKE_COMMAND} -E echo
"To sign the bootloader with additional private keys."
COMMAND ${CMAKE_COMMAND} -E echo
"\t${espsecurepy} sign_data -k secure_boot_signing_key2.pem -v 2 --append_signatures -o signed_bootloader.bin build/bootloader/bootloader.bin"
"\t${espsecurepy} sign_data -k secure_boot_signing_key2.pem -v 2 \
--append_signatures -o signed_bootloader.bin build/bootloader/bootloader.bin"
COMMAND ${CMAKE_COMMAND} -E echo
"Secure boot enabled, so bootloader not flashed automatically."
COMMAND ${CMAKE_COMMAND} -E echo

View File

@ -522,7 +522,7 @@ if(CONFIG_BT_ENABLED)
"host/nimble/esp-hci/src/esp_nimble_hci.c"
"host/nimble/port/src/esp_nimble_mem.c")
if (CONFIG_BLE_MESH)
if(CONFIG_BLE_MESH)
list(APPEND srcs "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c")
endif()

View File

@ -59,7 +59,8 @@ idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS ${includes}
PRIV_INCLUDE_DIRS "include/driver"
PRIV_REQUIRES efuse esp_pm esp_timer esp_ipc
REQUIRES esp_ringbuf freertos soc hal) #cannot totally hide soc headers, since there are a lot arguments in the driver are chip-dependent
REQUIRES esp_ringbuf freertos soc hal)
# (REQUIRES cannot hide soc headers, since many arguments in the driver headers are chip-dependent)
# uses C11 atomic feature
set_source_files_properties(spi_master.c PROPERTIES COMPILE_FLAGS -std=gnu11)

View File

@ -31,7 +31,9 @@ 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_DIR}/${target}/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.
@ -39,15 +41,21 @@ add_custom_target(efuse_common_table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE
if(${CONFIG_EFUSE_CUSTOM_TABLE})
# Custom filename expands any path relative to the project
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})
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_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})
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})

View File

@ -71,7 +71,8 @@ else()
add_dependencies(${COMPONENT_LIB} esp32_linker_script)
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
# Note: Adding as a PUBLIC compile option here causes this option to propagate to all components that depend on esp32.
# 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)

View File

@ -47,7 +47,9 @@ else()
# Process the template file through the linker script generation mechanism, and use the output for linking the
# final binary
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/ld/esp32s2.project.ld.in" PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32s2.project.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/ld/esp32s2.project.ld.in"
PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32s2.project.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32s2.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} PUBLIC gcc)

View File

@ -6,7 +6,7 @@ if(${target} STREQUAL "esp32")
REQUIRES driver efuse)
elseif(${target} STREQUAL "esp32s2")
idf_component_register(SRCS "esp_adc_cal_esp32s2.c"
idf_component_register(SRCS "esp_adc_cal_esp32s2.c"
INCLUDE_DIRS "include"
REQUIRES driver efuse)

View File

@ -1,4 +1,4 @@
if (CONFIG_ESP_HTTPS_SERVER_ENABLE)
if(CONFIG_ESP_HTTPS_SERVER_ENABLE)
set(src "src/https_server.c")
set(inc "include")
endif()

View File

@ -1,4 +1,10 @@
idf_component_register(SRCS "intr_alloc.c" "esp_async_memcpy.c" "panic.c" "system_api.c" "startup.c" "sleep_modes.c" "system_time.c"
idf_component_register(SRCS "intr_alloc.c"
"esp_async_memcpy.c"
"panic.c"
"system_api.c"
"startup.c"
"sleep_modes.c"
"system_time.c"
INCLUDE_DIRS include
PRIV_REQUIRES spi_flash
# [refactor-todo] requirements due to init code,
@ -15,7 +21,7 @@ add_subdirectory(port)
# of link line order.
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app")
if (NOT CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE)
if(NOT CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app_other_cores")
endif()

View File

@ -15,8 +15,9 @@ if(NOT BOOTLOADER_BUILD)
# In this case, should be used the partition table with two ota app without the factory.
partition_table_get_partition_info(factory_offset "--partition-type app --partition-subtype factory" "offset")
if(CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK AND factory_offset)
fail_at_build_time(check_table_contents
"ERROR: Anti-rollback option is enabled. Partition table should consist of two ota app without factory partition.")
fail_at_build_time(check_table_contents "\
ERROR: Anti-rollback option is enabled. Partition table should \
consist of two ota app without factory partition.")
add_dependencies(app check_table_contents)
endif()

View File

@ -33,7 +33,7 @@ if(NOT BOOTLOADER_BUILD)
"twai_hal.c"
"twai_hal_iram.c"
"interrupt_controller_hal.c"
"sha_hal.c"
"sha_hal.c"
"${target}/interrupt_descriptor_table.c")
if(${target} STREQUAL "esp32")

View File

@ -35,7 +35,7 @@ idf_build_get_property(python PYTHON)
set(gen_partition_table "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py" "-q"
"--offset" "${PARTITION_TABLE_OFFSET}" "${md5_opt}" "${flashsize_opt}"
"${partition_secure_opt}" )
"${partition_secure_opt}")
set(partition_table_display
COMMAND ${CMAKE_COMMAND} -E echo "Partition table binary generated. Contents:"

View File

@ -1,5 +1,5 @@
if(BOOTLOADER_BUILD)
if (CONFIG_IDF_TARGET_ESP32)
if(CONFIG_IDF_TARGET_ESP32)
# ESP32 Bootloader needs SPIUnlock from this file, but doesn't
# need other parts of this component
set(srcs "esp32/spi_flash_rom_patch.c")
@ -19,7 +19,7 @@ else()
set(srcs
"partition.c")
if (CONFIG_IDF_TARGET_ESP32)
if(CONFIG_IDF_TARGET_ESP32)
list(APPEND srcs
"esp32/spi_flash_rom_patch.c")
endif()

View File

@ -26,7 +26,10 @@ else()
# Check the supported assembler version
file(STRINGS ${IDF_PATH}/components/ulp/toolchain_ulp_version.mk version_file_contents)
string(REGEX MATCH "SUPPORTED_ULP_ASSEMBLER_VERSION = (${version_pattern})" as_supported_version ${version_file_contents})
string(REGEX MATCH
"SUPPORTED_ULP_ASSEMBLER_VERSION = (${version_pattern})"
as_supported_version
${version_file_contents})
set(as_supported_version ${CMAKE_MATCH_1})
if(NOT as_version STREQUAL as_supported_version)
@ -56,14 +59,14 @@ list(APPEND ULP_PREPROCESSOR_ARGS -D__ASSEMBLER__)
# Preprocess linker script, pre-linking
get_filename_component(ULP_LD_SCRIPT ${ULP_LD_TEMPLATE} NAME)
add_custom_command( OUTPUT ${ULP_LD_SCRIPT}
COMMAND ${CMAKE_C_COMPILER} -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${ULP_LD_TEMPLATE}
VERBATIM)
add_custom_command(OUTPUT ${ULP_LD_SCRIPT}
COMMAND ${CMAKE_C_COMPILER} -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${ULP_LD_TEMPLATE}
VERBATIM)
add_custom_target(${ULP_APP_NAME}_ld_script
DEPENDS ${ULP_LD_SCRIPT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
DEPENDS ${ULP_LD_SCRIPT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(ULP_COCPU_IS_RISCV)
#risc-v ulp uses extra files for building:
@ -88,7 +91,8 @@ if(ULP_COCPU_IS_RISCV)
add_executable(${ULP_APP_NAME} ${ULP_S_SOURCES})
set(DUMP_SYMBOL_ARGS -g)
set(MAP_GEN_EXTRA_ARGS --riscv)
set(EXTRA_LINKER_ARGS "-nostartfiles -Wl,--gc-sections -Xlinker -Map=${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.map")
set(EXTRA_LINKER_ARGS "-nostartfiles -Wl,--gc-sections -Xlinker \
-Map=${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.map")
#Makes the csr utillies for riscv visible:
target_include_directories(${ULP_APP_NAME} PRIVATE "${IDF_PATH}/components/ulp/ulp_riscv/include")
@ -98,11 +102,12 @@ else()
get_filename_component(ulp_ps_source ${ulp_s_source} NAME_WE)
set(ulp_ps_output ${CMAKE_CURRENT_BINARY_DIR}/${ulp_ps_source}.ulp.S)
# Generate preprocessed assembly files.
add_custom_command( OUTPUT ${ulp_ps_output}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_C_COMPILER} -E -P -xc ${ULP_PREPROCESSOR_ARGS} -o ${ulp_ps_output} ${ulp_s_source}
DEPENDS ${ulp_s_source} ${ULP_LD_SCRIPT}
VERBATIM)
add_custom_command(OUTPUT ${ulp_ps_output}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_C_COMPILER} -E -P -xc ${ULP_PREPROCESSOR_ARGS}
-o ${ulp_ps_output} ${ulp_s_source}
DEPENDS ${ulp_s_source} ${ULP_LD_SCRIPT}
VERBATIM)
# During assembly file compilation, output listing files as well.
set_source_files_properties(${ulp_ps_output}
PROPERTIES COMPILE_FLAGS
@ -119,21 +124,21 @@ else()
endif()
# Dump the list of global symbols in a convenient format
add_custom_command( OUTPUT ${ULP_APP_NAME}.sym
COMMAND ${CMAKE_NM} ${DUMP_SYMBOL_ARGS} $<TARGET_FILE:${ULP_APP_NAME}> > ${ULP_APP_NAME}.sym
DEPENDS ${ULP_APP_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(OUTPUT ${ULP_APP_NAME}.sym
COMMAND ${CMAKE_NM} ${DUMP_SYMBOL_ARGS} $<TARGET_FILE:${ULP_APP_NAME}> > ${ULP_APP_NAME}.sym
DEPENDS ${ULP_APP_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# Dump the binary for inclusion into the project
add_custom_command( OUTPUT ${ULP_APP_NAME}.bin
COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_FILE:${ULP_APP_NAME}> ${ULP_APP_NAME}.bin
DEPENDS ${ULP_APP_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(OUTPUT ${ULP_APP_NAME}.bin
COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_FILE:${ULP_APP_NAME}> ${ULP_APP_NAME}.bin
DEPENDS ${ULP_APP_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command( OUTPUT ${ULP_APP_NAME}.ld ${ULP_APP_NAME}.h
COMMAND ${ULP_MAP_GEN} ${MAP_GEN_EXTRA_ARGS} -s ${ULP_APP_NAME}.sym -o ${ULP_APP_NAME}
DEPENDS ${ULP_APP_NAME}.sym
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(OUTPUT ${ULP_APP_NAME}.ld ${ULP_APP_NAME}.h
COMMAND ${ULP_MAP_GEN} ${MAP_GEN_EXTRA_ARGS} -s ${ULP_APP_NAME}.sym -o ${ULP_APP_NAME}
DEPENDS ${ULP_APP_NAME}.sym
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# Building the component separately from the project should result in
# ULP files being built.

View File

@ -1,4 +1,5 @@
# For more information about build system see https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# 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)

View File

@ -10,7 +10,7 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(mqtt_ssl_ds)
# Flash the custom partition named `pre_prov`.
set (partition pre_prov)
set(partition pre_prov)
idf_build_get_property(project_dir PROJECT_DIR)
set(image_file ${project_dir}/esp_ds_data/${partition}.bin)
partition_table_get_partition_info(offset "--partition-name ${partition}" "offset")

View File

@ -1,4 +1,4 @@
set(COMPONENT_SRCS )
set(COMPONENT_SRCS)
set(COMPONENT_ADD_INCLUDEDIRS ".")
idf_component_register(SRCS "semihost_vfs_example_main.c"

View File

@ -1,2 +1,2 @@
idf_component_register(SRCS "main.c" "connect_test.c"
INCLUDE_DIRS "." )
INCLUDE_DIRS ".")