Merge branch 'bugfix/override_cmake_python' into 'master'

cmake: Minor Python CMake build fixes

Closes IDFGH-4454

See merge request espressif/esp-idf!12975
pull/6882/head
Angus Gratton 2021-04-13 03:39:16 +00:00
commit a5faf86934
2 zmienionych plików z 17 dodań i 8 usunięć

Wyświetl plik

@ -130,9 +130,11 @@ function(__build_init idf_path)
# Must be global so as to be accessible from any subdirectory in custom projects. # Must be global so as to be accessible from any subdirectory in custom projects.
add_library(__idf_build_target STATIC IMPORTED GLOBAL) add_library(__idf_build_target STATIC IMPORTED GLOBAL)
set_default(python "python") # Set the Python path (which may be passed in via -DPYTHON=) and store in a build property
set_default(PYTHON "python")
file(TO_CMAKE_PATH ${PYTHON} PYTHON)
idf_build_set_property(PYTHON ${PYTHON})
idf_build_set_property(PYTHON ${python})
idf_build_set_property(IDF_PATH ${idf_path}) idf_build_set_property(IDF_PATH ${idf_path})
idf_build_set_property(__PREFIX idf) idf_build_set_property(__PREFIX idf)
@ -273,8 +275,12 @@ function(__build_check_python)
message(STATUS "Checking Python dependencies...") message(STATUS "Checking Python dependencies...")
execute_process(COMMAND "${python}" "${idf_path}/tools/check_python_dependencies.py" execute_process(COMMAND "${python}" "${idf_path}/tools/check_python_dependencies.py"
RESULT_VARIABLE result) RESULT_VARIABLE result)
if(NOT result EQUAL 0) if(result EQUAL 1)
# check_python_dependencies returns error code 1 on failure
message(FATAL_ERROR "Some Python dependencies must be installed. Check above message for details.") message(FATAL_ERROR "Some Python dependencies must be installed. Check above message for details.")
elseif(NOT result EQUAL 0)
# means check_python_dependencies.py failed to run at all, result should be an error message
message(FATAL_ERROR "Failed to run Python dependency check. Python: ${python}, Error: ${result}")
endif() endif()
endif() endif()
endfunction() endfunction()

Wyświetl plik

@ -6,12 +6,15 @@ cmake_minimum_required(VERSION 3.5)
# call. # call.
include(${CMAKE_CURRENT_LIST_DIR}/idf.cmake) include(${CMAKE_CURRENT_LIST_DIR}/idf.cmake)
# setting PYTHON variable here for compatibility only, new code should use
# idf_build_get_property(variable PYTHON)
idf_build_get_property(PYTHON PYTHON)
if(NOT PYTHON)
message(FATAL_ERROR "Internal error, PYTHON build property not set correctly.")
endif()
# legacy variable for compatibility
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py") set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
# Internally, the Python interpreter is already set to 'python'. Re-set here
# to be absolutely sure.
set_default(PYTHON "python")
file(TO_CMAKE_PATH ${PYTHON} PYTHON)
idf_build_set_property(PYTHON ${PYTHON})
# On processing, checking Python required modules can be turned off if it was # On processing, checking Python required modules can be turned off if it was
# already checked externally. # already checked externally.