]> granicus.if.org Git - esp-idf/commitdiff
cmake: Call check_python_dependencies.py from idf.py & cmake
authorAngus Gratton <angus@espressif.com>
Mon, 3 Sep 2018 10:24:17 +0000 (18:24 +0800)
committerAngus Gratton <gus@projectgus.com>
Mon, 3 Sep 2018 10:37:53 +0000 (18:37 +0800)
tools/cmake/project.cmake
tools/idf.py

index bf1ab269be022e0534d52729fb2c3bac5922af61..8784a9e9ba212067b97a7c48ba9f919b6a96e9cc 100644 (file)
@@ -29,6 +29,15 @@ include(idf_functions)
 
 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
 #
 # This macro wraps the cmake 'project' command to add
index 1f017e7fce6de5a29e65507e6190e5780152914e..2f552fa5d5b4273ae4a6208d068e8001a272a2bf 100755 (executable)
 # See the License for the specific language governing permissions and
 # 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 argparse
 import os
@@ -98,6 +103,15 @@ def check_environment():
         print("Setting IDF_PATH environment variable: %s" % 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):
     try:
         subprocess.check_output(args)
@@ -143,7 +157,7 @@ def _ensure_build_directory(args, always_run_cmake=False):
         if args.generator is None:
             args.generator = detect_cmake_generator()
         try:
-            cmake_args = ["cmake", "-G", args.generator]
+            cmake_args = ["cmake", "-G", args.generator, "-DPYTHON_DEPS_CHECKED=1"]
             if not args.no_warnings:
                 cmake_args += [ "--warn-uninitialized" ]
             if args.no_ccache: