CMakeLists.txt 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. idf_build_get_property(target IDF_TARGET)
  2. if(CONFIG_EFUSE_VIRTUAL)
  3. message(STATUS "Efuse virtual mode is enabled. If Secure boot or Flash encryption is on"
  4. " it does not provide any security. FOR TESTING ONLY!")
  5. endif()
  6. if(EXISTS "${COMPONENT_DIR}/${target}")
  7. include(${COMPONENT_DIR}/${target}/sources.cmake)
  8. spaces2list(EFUSE_SOC_SRCS)
  9. set(include_dirs include ${target}/include)
  10. set(private_include private_include ${target}/private_include)
  11. add_prefix(srcs "${target}/" ${EFUSE_SOC_SRCS})
  12. endif()
  13. list(APPEND srcs "src/esp_efuse_api.c"
  14. "src/esp_efuse_fields.c"
  15. "src/esp_efuse_utility.c")
  16. if("esp32" STREQUAL "${target}")
  17. list(APPEND srcs "src/esp_efuse_api_key_esp32.c")
  18. else()
  19. list(APPEND srcs "src/esp_efuse_api_key_esp32xx.c")
  20. endif()
  21. idf_component_register(SRCS "${srcs}"
  22. PRIV_REQUIRES bootloader_support soc spi_flash
  23. INCLUDE_DIRS "${include_dirs}"
  24. PRIV_INCLUDE_DIRS "${private_include}")
  25. if(target)
  26. set(TOOL_TARGET -t ${target})
  27. endif()
  28. set(GEN_EFUSE_TABLE_ARG ${TOOL_TARGET} --max_blk_len ${CONFIG_EFUSE_MAX_BLK_LEN})
  29. idf_build_get_property(python PYTHON)
  30. ###################
  31. # Make common files esp_efuse_table.c and include/esp_efuse_table.h files.
  32. set(EFUSE_COMMON_TABLE_CSV_PATH "${COMPONENT_DIR}/${target}/esp_efuse_table.csv")
  33. add_custom_target(efuse-common-table COMMAND "${python}"
  34. "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py"
  35. ${EFUSE_COMMON_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
  36. add_deprecated_target_alias(efuse_common_table efuse-common-table)
  37. ###################
  38. # Make custom files project/main/esp_efuse_custom_table.c and project/main/include/esp_efuse_custom_table.h files.
  39. # Path to CSV file is relative to project path for custom CSV files.
  40. if(${CONFIG_EFUSE_CUSTOM_TABLE})
  41. # Custom filename expands any path relative to the project
  42. idf_build_get_property(project_dir PROJECT_DIR)
  43. get_filename_component(EFUSE_CUSTOM_TABLE_CSV_PATH "${CONFIG_EFUSE_CUSTOM_TABLE_FILENAME}"
  44. ABSOLUTE BASE_DIR "${project_dir}")
  45. add_custom_target(efuse-custom-table COMMAND "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py"
  46. ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})
  47. add_deprecated_target_alias(efuse_custom_table efuse-custom-table)
  48. else()
  49. add_custom_target(efuse-custom-table COMMAND)
  50. add_deprecated_target_alias(efuse_custom_table efuse-custom-table)
  51. endif()#if(${CONFIG_EFUSE_CUSTOM_TABLE})
  52. add_custom_target(show-efuse-table COMMAND "${python}"
  53. "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py"
  54. ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG} "--info")
  55. add_deprecated_target_alias(show_efuse_table show-efuse-table)
  56. ###################
  57. # Generates files for unit test. This command is run manually.
  58. set(EFUSE_TEST_TABLE_CSV_PATH "${COMPONENT_DIR}/test/esp_efuse_test_table.csv")
  59. add_custom_target(efuse_test_table COMMAND "${python}"
  60. "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py"
  61. ${EFUSE_TEST_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})