mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/missing_build_targets_cmake' into 'master'
esptool_py: add missing phony build targets for CMake Closes IDFGH-370 See merge request espressif/esp-idf!5838
This commit is contained in:
commit
46a65a35d6
18
components/esptool_py/get_port_args.cmake
Normal file
18
components/esptool_py/get_port_args.cmake
Normal file
@ -0,0 +1,18 @@
|
||||
# Note: we can't expand these environment variables in the main IDF CMake build,
|
||||
# because we want to expand them at flashing time not at CMake runtime (so they can change
|
||||
# without needing a CMake re-run)
|
||||
set(ESPPORT $ENV{ESPPORT})
|
||||
if(NOT ESPPORT)
|
||||
message("Note: ${TOOL} will search for a serial port. To specify a port, set the ESPPORT environment variable.")
|
||||
else()
|
||||
set(port_arg "-p ${ESPPORT}")
|
||||
endif()
|
||||
|
||||
set(ESPBAUD $ENV{ESPBAUD})
|
||||
if(NOT ESPBAUD)
|
||||
message("Note: ${TOOL} will attempt to set baud rate automatically. "
|
||||
"To specify a baud rate, set the ESPBAUD environment variable.")
|
||||
else()
|
||||
set(baud_arg "-b ${ESPBAUD}")
|
||||
endif()
|
||||
|
@ -142,13 +142,34 @@ function(esptool_py_custom_target target_name flasher_filename dependencies)
|
||||
-D IDF_PATH="${idf_path}"
|
||||
-D ESPTOOLPY="${ESPTOOLPY}"
|
||||
-D ESPTOOL_ARGS="write_flash;@flash_${flasher_filename}_args"
|
||||
-D ESPTOOL_WORKING_DIR="${build_dir}"
|
||||
-D WORKING_DIRECTORY="${build_dir}"
|
||||
-P run_esptool.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
endfunction()
|
||||
|
||||
add_custom_target(erase_flash
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D IDF_PATH="${idf_path}"
|
||||
-D ESPTOOLPY="${ESPTOOLPY}"
|
||||
-D ESPTOOL_ARGS="erase_flash"
|
||||
-P run_esptool.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
add_custom_target(monitor
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D IDF_PATH="${idf_path}"
|
||||
-D IDF_MONITOR="${idf_path}/tools/idf_monitor.py"
|
||||
-D ELF_FILE="${elf}"
|
||||
-D WORKING_DIRECTORY="${build_dir}"
|
||||
-P run_idf_monitor.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
esptool_py_custom_target(flash project "app;partition_table;bootloader")
|
||||
esptool_py_custom_target(app-flash app "app")
|
||||
|
||||
|
15
components/esptool_py/run_cmd.cmake
Normal file
15
components/esptool_py/run_cmd.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
if(NOT IDF_PATH)
|
||||
message(FATAL_ERROR "IDF_PATH not set.")
|
||||
endif()
|
||||
include("${IDF_PATH}/tools/cmake/utilities.cmake")
|
||||
spaces2list(CMD)
|
||||
|
||||
execute_process(COMMAND ${CMD}
|
||||
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
|
||||
RESULT_VARIABLE result
|
||||
)
|
||||
|
||||
if(${result})
|
||||
# No way to have CMake silently fail, unfortunately
|
||||
message(FATAL_ERROR "${TOOL} failed")
|
||||
endif()
|
@ -8,39 +8,14 @@
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if(NOT IDF_PATH OR NOT ESPTOOLPY OR NOT ESPTOOL_ARGS OR NOT ESPTOOL_WORKING_DIR)
|
||||
message(FATAL_ERROR "IDF_PATH, ESPTOOLPY, ESPTOOL_ARGS, and ESPTOOL_WORKING_DIR must "
|
||||
"be specified on the CMake command line. For direct esptool execution, it is "
|
||||
"strongly recommended to run esptool.py directly.")
|
||||
set(TOOL "esptool.py")
|
||||
|
||||
if(NOT ESPTOOLPY OR NOT ESPTOOL_ARGS)
|
||||
message(FATAL_ERROR "ESPTOOLPY and ESPTOOL_ARGS must "
|
||||
"be specified on the CMake command line. For direct execution, it is "
|
||||
"strongly recommended to run ${TOOL} directly.")
|
||||
endif()
|
||||
|
||||
# Note: we can't expand these environment variables in the main IDF CMake build,
|
||||
# because we want to expand them at flashing time not at CMake runtime (so they can change
|
||||
# without needing a CMake re-run)
|
||||
set(ESPPORT $ENV{ESPPORT})
|
||||
if(NOT ESPPORT)
|
||||
message("Note: esptool.py will search for a serial port. To specify a port, set the ESPPORT environment variable.")
|
||||
else()
|
||||
set(port_arg "-p ${ESPPORT}")
|
||||
endif()
|
||||
|
||||
set(ESPBAUD $ENV{ESPBAUD})
|
||||
if(NOT ESPBAUD)
|
||||
message("Note: Using default baud rate 460800. To modify, set ESPBAUD environment variable.")
|
||||
set(ESPBAUD 460800)
|
||||
endif()
|
||||
|
||||
include("${IDF_PATH}/tools/cmake/utilities.cmake")
|
||||
|
||||
set(cmd "${ESPTOOLPY} ${port_arg} -b ${ESPBAUD} ${ESPTOOL_ARGS}")
|
||||
spaces2list(cmd)
|
||||
|
||||
execute_process(COMMAND ${cmd}
|
||||
WORKING_DIRECTORY "${ESPTOOL_WORKING_DIR}"
|
||||
RESULT_VARIABLE result
|
||||
)
|
||||
|
||||
if(${result})
|
||||
# No way to have CMake silently fail, unfortunately
|
||||
message(FATAL_ERROR "esptool.py failed")
|
||||
endif()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/get_port_args.cmake")
|
||||
set(CMD "${ESPTOOLPY} ${port_arg} ${baud_arg} ${ESPTOOL_ARGS}")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/run_cmd.cmake")
|
21
components/esptool_py/run_idf_monitor.cmake
Normal file
21
components/esptool_py/run_idf_monitor.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
# A CMake script to run idf_monitor from within ninja or make
|
||||
# or another cmake-based build runner
|
||||
#
|
||||
# (Needed to expand environment variables, for backwards compatibility.)
|
||||
#
|
||||
# It is recommended to NOT USE this CMake script if you have the option of
|
||||
# running idf_monitor.py directly. This script exists only for use inside CMake builds.
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
set(TOOL "idf_monitor.py")
|
||||
|
||||
if(NOT IDF_MONITOR OR NOT ELF_FILE)
|
||||
message(FATAL_ERROR "IDF_MONITOR and ELF_FILE must "
|
||||
"be specified on the CMake command line. For direct execution, it is "
|
||||
"strongly recommended to run ${TOOL} directly.")
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/get_port_args.cmake")
|
||||
set(CMD "${IDF_MONITOR} ${port_arg} ${baud_arg} ${ELF_FILE}")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/run_cmd.cmake")
|
Loading…
Reference in New Issue
Block a user