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
6cmake_minimum_required(VERSION 3.5)
7
8set(TOOL "dfu-util")
9set(CMD "${TOOL}")
10
11if(${ESP_DFU_LIST})
12    list(APPEND CMD "--list")
13else()
14    # The following works even when ESP_DFU_PID is not defined.
15    list(APPEND CMD "-d" "303a:${ESP_DFU_PID}")
16
17    if(NOT $ENV{ESP_DFU_PATH} STREQUAL "")
18        list(APPEND CMD "--path" $ENV{ESP_DFU_PATH})
19    endif()
20    list(APPEND CMD "-D" ${ESP_DFU_BIN})
21endif()
22
23message("Command list: ${CMD}")
24execute_process(COMMAND ${CMD} RESULT_VARIABLE result)
25
26if(${result})
27    message(FATAL_ERROR "${TOOL} failed")
28endif()
29