cmake: Call check_python_dependencies.py from idf.py & cmake

This commit is contained in:
Angus Gratton 2018-09-03 18:24:17 +08:00 committed by Angus Gratton
parent 38c0626090
commit 6fa52ca8fe
2 changed files with 24 additions and 1 deletions

View File

@ -29,6 +29,15 @@ include(idf_functions)
set_default(PYTHON "python") set_default(PYTHON "python")
if(NOT PYTHON_DEPS_CHECKED AND NOT BOOTLOADER_BUILD)
message(STATUS "Checking Python dependencies...")
execute_process(COMMAND "${PYTHON}" "${IDF_PATH}/tools/check_python_dependencies.py"
RESULT_VARIABLE result)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Some Python dependencies must be installed. Check above message for details.")
endif()
endif()
# project # project
# #
# This macro wraps the cmake 'project' command to add # This macro wraps the cmake 'project' command to add

View File

@ -21,6 +21,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# Note: we don't check for Python build-time dependencies until
# check_environment() function below. If possible, avoid importing
# any external libraries here - put in external script, or import in
# their specific function instead.
import sys import sys
import argparse import argparse
import os import os
@ -98,6 +103,15 @@ def check_environment():
print("Setting IDF_PATH environment variable: %s" % detected_idf_path) print("Setting IDF_PATH environment variable: %s" % detected_idf_path)
os.environ["IDF_PATH"] = detected_idf_path os.environ["IDF_PATH"] = detected_idf_path
# check Python dependencies
print("Checking Python dependencies...")
try:
subprocess.check_call([ os.environ["PYTHON"],
os.path.join(os.environ["IDF_PATH"], "tools", "check_python_dependencies.py")],
env=os.environ)
except subprocess.CalledProcessError:
raise SystemExit(1)
def executable_exists(args): def executable_exists(args):
try: try:
subprocess.check_output(args) subprocess.check_output(args)
@ -143,7 +157,7 @@ def _ensure_build_directory(args, always_run_cmake=False):
if args.generator is None: if args.generator is None:
args.generator = detect_cmake_generator() args.generator = detect_cmake_generator()
try: try:
cmake_args = ["cmake", "-G", args.generator] cmake_args = ["cmake", "-G", args.generator, "-DPYTHON_DEPS_CHECKED=1"]
if not args.no_warnings: if not args.no_warnings:
cmake_args += [ "--warn-uninitialized" ] cmake_args += [ "--warn-uninitialized" ]
if args.no_ccache: if args.no_ccache: