project_include.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. if(NOT BOOTLOADER_BUILD)
  2. set(PARTITION_TABLE_OFFSET ${CONFIG_PARTITION_TABLE_OFFSET})
  3. # Set PARTITION_CSV_PATH to the configured partition CSV file
  4. # absolute path
  5. if(CONFIG_PARTITION_TABLE_CUSTOM)
  6. # Custom filename expands any path relative to the project
  7. get_filename_component(PARTITION_CSV_PATH "${CONFIG_PARTITION_TABLE_FILENAME}"
  8. ABSOLUTE BASE_DIR "${IDF_PROJECT_PATH}")
  9. if(NOT EXISTS "${PARTITION_CSV_PATH}")
  10. message(WARNING "Partition table CSV file ${PARTITION_CSV_PATH} not found. "
  11. "Change custom partition CSV path in menuconfig.")
  12. # Note: partition_table CMakeLists.txt contains some logic to create a dummy
  13. # partition_table target in this case, see comments in that file.
  14. endif()
  15. else()
  16. # Other .csv files are always in the component directory
  17. get_filename_component(PARTITION_CSV_PATH "${COMPONENT_PATH}/${CONFIG_PARTITION_TABLE_FILENAME}" ABSOLUTE)
  18. if(NOT EXISTS "${PARTITION_CSV_PATH}")
  19. message(FATAL_ERROR "Internal error, built-in ${PARTITION_CSV_PATH} not found.")
  20. endif()
  21. endif()
  22. # need to re-run CMake if the partition CSV changes, as the offsets/sizes of partitions may change
  23. set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PARTITION_CSV_PATH})
  24. # partition_table_get_partition_info
  25. #
  26. # Get information about a partition from the partition table
  27. function(partition_table_get_partition_info result get_part_info_args part_info)
  28. separate_arguments(get_part_info_args)
  29. execute_process(COMMAND ${PYTHON}
  30. ${IDF_PATH}/components/partition_table/parttool.py -q
  31. --partition-table-offset ${PARTITION_TABLE_OFFSET}
  32. --partition-table-file ${PARTITION_CSV_PATH}
  33. ${get_part_info_args} get_partition_info --info ${part_info}
  34. OUTPUT_VARIABLE info
  35. RESULT_VARIABLE exit_code
  36. OUTPUT_STRIP_TRAILING_WHITESPACE)
  37. if(NOT ${exit_code} EQUAL 0 AND NOT ${exit_code} EQUAL 1)
  38. # can't fail here as it would prevent the user from running 'menuconfig' again
  39. message(WARNING "parttool.py execution failed (${result}), problem with partition CSV file (see above)")
  40. endif()
  41. set(${result} ${info} PARENT_SCOPE)
  42. endfunction()
  43. endif()