project_include.cmake 2.4 KB

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