run_dfu_util.cmake 716 B

12345678910111213141516171819202122232425262728
  1. # A CMake script to run dfu-util from within ninja or make
  2. # or another cmake-based build runner
  3. #
  4. # It is recommended to NOT USE this CMake script directly
  5. cmake_minimum_required(VERSION 3.5)
  6. set(TOOL "dfu-util")
  7. set(CMD "${TOOL}")
  8. if(${ESP_DFU_LIST})
  9. list(APPEND CMD "--list")
  10. else()
  11. # The following works even when ESP_DFU_PID is not defined.
  12. list(APPEND CMD "-d" "303a:${ESP_DFU_PID}")
  13. if(NOT $ENV{ESP_DFU_PATH} STREQUAL "")
  14. list(APPEND CMD "--path" $ENV{ESP_DFU_PATH})
  15. endif()
  16. list(APPEND CMD "-D" ${ESP_DFU_BIN})
  17. endif()
  18. message("Command list: ${CMD}")
  19. execute_process(COMMAND ${CMD} RESULT_VARIABLE result)
  20. if(${result})
  21. message(FATAL_ERROR "${TOOL} failed")
  22. endif()