]> git.proxmox.com Git - mirror_edk2.git/commitdiff
.pytool/EccCheck: Locate BaseTools dir with EDK_TOOLS_PATH
authorPierre Gondois <Pierre.Gondois@arm.com>
Tue, 6 Jul 2021 20:55:38 +0000 (04:55 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 12 Jul 2021 14:53:55 +0000 (14:53 +0000)
The BaseTools directory is currently being located as a
sub-directory of the WORKSPACE env var. This might not be
true in other environments. Cf EDKII Build Specification,
s4.1.3 "Build Process Restrictions":
  There is no restriction on the location of the EDK_TOOLS_PATH,
  it may be located within a directory identified as the
  WORKSPACE directory, or in any other location that is
  accessible on the development workstation.

Locate the BaseTools directory using EDK_TOOLS_PATH instead.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
.pytool/Plugin/EccCheck/EccCheck.py

index eee1ff7a77b5cf3fa6ec26eb5607edce4482f897..bb93446441de17026bb568cf2754194a4f4c1aea 100644 (file)
@@ -1,5 +1,6 @@
 # @file EccCheck.py\r
 #\r
+# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
 # Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ##\r
@@ -61,16 +62,17 @@ class EccCheck(ICiBuildPlugin):
     #   - output_stream the StringIO output stream from this plugin via logging\r
     def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, PLMHelper, tc, output_stream=None):\r
         edk2_path = Edk2pathObj.WorkspacePath\r
-        python_path = os.path.join(edk2_path, "BaseTools", "Source", "Python")\r
+        basetools_path = environment.GetValue("EDK_TOOLS_PATH")\r
+        python_path = os.path.join(basetools_path, "Source", "Python")\r
         env = shell_environment.GetEnvironment()\r
         env.set_shell_var('PYTHONPATH', python_path)\r
         env.set_shell_var('WORKSPACE', edk2_path)\r
         self.ECC_PASS = True\r
-        self.ApplyConfig(pkgconfig, edk2_path, packagename)\r
+        self.ApplyConfig(pkgconfig, edk2_path, basetools_path, packagename)\r
         modify_dir_list = self.GetModifyDir(packagename)\r
         patch = self.GetDiff(packagename)\r
         ecc_diff_range = self.GetDiffRange(patch, packagename, edk2_path)\r
-        self.GenerateEccReport(modify_dir_list, ecc_diff_range, edk2_path)\r
+        self.GenerateEccReport(modify_dir_list, ecc_diff_range, edk2_path, basetools_path)\r
         ecc_log = os.path.join(edk2_path, "Ecc.log")\r
         self.RevertCode()\r
         if self.ECC_PASS:\r
@@ -176,11 +178,11 @@ class EccCheck(ICiBuildPlugin):
         return comment_range\r
 \r
     def GenerateEccReport(self, modify_dir_list: List[str], ecc_diff_range: Dict[str, List[Tuple[int, int]]],\r
-                          edk2_path: str) -> None:\r
+                           edk2_path: str, basetools_path: str) -> None:\r
         ecc_need = False\r
         ecc_run = True\r
-        config = os.path.join(edk2_path, "BaseTools", "Source", "Python", "Ecc", "config.ini")\r
-        exception = os.path.join(edk2_path, "BaseTools", "Source", "Python", "Ecc", "exception.xml")\r
+        config = os.path.join(basetools_path, "Source", "Python", "Ecc", "config.ini")\r
+        exception = os.path.join(basetools_path, "Source", "Python", "Ecc", "exception.xml")\r
         report = os.path.join(edk2_path, "Ecc.csv")\r
         for modify_dir in modify_dir_list:\r
             target = os.path.join(edk2_path, modify_dir)\r
@@ -234,7 +236,7 @@ class EccCheck(ICiBuildPlugin):
             log.writelines(all_line)\r
         return\r
 \r
-    def ApplyConfig(self, pkgconfig: Dict[str, List[str]], edk2_path: str, pkg: str) -> None:\r
+    def ApplyConfig(self, pkgconfig: Dict[str, List[str]], edk2_path: str, basetools_path: str, pkg: str) -> None:\r
         if "IgnoreFiles" in pkgconfig:\r
             for a in pkgconfig["IgnoreFiles"]:\r
                 a = os.path.join(edk2_path, pkg, a)\r
@@ -251,7 +253,7 @@ class EccCheck(ICiBuildPlugin):
 \r
         if "ExceptionList" in pkgconfig:\r
             exception_list = pkgconfig["ExceptionList"]\r
-            exception_xml = os.path.join(edk2_path, "BaseTools", "Source", "Python", "Ecc", "exception.xml")\r
+            exception_xml = os.path.join(basetools_path, "Source", "Python", "Ecc", "exception.xml")\r
             try:\r
                 logging.info("Appending exceptions")\r
                 self.AppendException(exception_list, exception_xml)\r