浏览代码

BaseTools:The code used to test python module is moved to edksetup

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1582

testing for presence of python modules should be done in edksetup
to reduce impact on subsequent build times.
This code currently exists in BaseTools/Tests/RunTest.py.

This patch is going to fix this issue.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Fan, ZhijuX 5 年之前
父节点
当前提交
df7c81b5b2
共有 2 个文件被更改,包括 13 次插入10 次删除
  1. 0 8
      BaseTools/Tests/RunTests.py
  2. 13 2
      edksetup.sh

+ 0 - 8
BaseTools/Tests/RunTests.py

@@ -12,14 +12,6 @@
 import os
 import sys
 import unittest
-
-try:
-    import distutils.util
-except ModuleNotFoundError:
-    sys.exit('''
-Python reported: "No module named 'distutils.util"
-''')
-
 import TestTools
 
 def GetCTestSuite():

+ 13 - 2
edksetup.sh

@@ -177,11 +177,22 @@ function SetupPython()
   SetupPython3
 }
 
+function TestUtilModule()
+{
+  if ( $PYTHON_COMMAND -c "import distutils.util" >/dev/null 2>&1 );then
+    return 1
+  else
+    echo Error: "No module named 'distutils.util"
+    return 0
+  fi
+}
+
 function SourceEnv()
 {
   SetWorkspace &&
-  SetupEnv
-  SetupPython
+  SetupEnv &&
+  SetupPython &&
+  TestUtilModule
 }
 
 I=$#