CMakeLists.txt 3.5 KB

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