# @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
# - Junit Logger\r
# - 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
+ workspace_path = Edk2pathObj.WorkspacePath\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
+ env.set_shell_var('WORKSPACE', workspace_path)\r
+ env.set_shell_var('PACKAGES_PATH', os.pathsep.join(Edk2pathObj.PackagePathList))\r
self.ECC_PASS = True\r
- self.ApplyConfig(pkgconfig, edk2_path, packagename)\r
+ self.ApplyConfig(pkgconfig, workspace_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
- ecc_log = os.path.join(edk2_path, "Ecc.log")\r
+ ecc_diff_range = self.GetDiffRange(patch, packagename, workspace_path)\r
+ self.GenerateEccReport(modify_dir_list, ecc_diff_range, workspace_path, basetools_path)\r
+ ecc_log = os.path.join(workspace_path, "Ecc.log")\r
self.RevertCode()\r
if self.ECC_PASS:\r
tc.SetSuccess()\r
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
+ workspace_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
- report = os.path.join(edk2_path, "Ecc.csv")\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(workspace_path, "Ecc.csv")\r
for modify_dir in modify_dir_list:\r
- target = os.path.join(edk2_path, modify_dir)\r
+ target = os.path.join(workspace_path, modify_dir)\r
logging.info('Run ECC tool for the commit in %s' % modify_dir)\r
ecc_need = True\r
ecc_params = "-c {0} -e {1} -t {2} -r {3}".format(config, exception, target, report)\r
- return_code = RunCmd("Ecc", ecc_params, workingdir=edk2_path)\r
+ return_code = RunCmd("Ecc", ecc_params, workingdir=workspace_path)\r
if return_code != 0:\r
ecc_run = False\r
break\r
if not ecc_run:\r
logging.error('Fail to run ECC tool')\r
- self.ParseEccReport(ecc_diff_range, edk2_path)\r
+ self.ParseEccReport(ecc_diff_range, workspace_path)\r
\r
if not ecc_need:\r
logging.info("Doesn't need run ECC check")\r
RunCmd("git", revert_params)\r
return\r
\r
- def ParseEccReport(self, ecc_diff_range: Dict[str, List[Tuple[int, int]]], edk2_path: str) -> None:\r
- ecc_log = os.path.join(edk2_path, "Ecc.log")\r
- ecc_csv = "Ecc.csv"\r
- file = os.listdir(edk2_path)\r
+ def ParseEccReport(self, ecc_diff_range: Dict[str, List[Tuple[int, int]]], workspace_path: str) -> None:\r
+ ecc_log = os.path.join(workspace_path, "Ecc.log")\r
+ ecc_csv = os.path.join(workspace_path, "Ecc.csv")\r
row_lines = []\r
ignore_error_code = self.GetIgnoreErrorCode()\r
- if ecc_csv in file:\r
+ if os.path.exists(ecc_csv):\r
with open(ecc_csv) as csv_file:\r
reader = csv.reader(csv_file)\r
for row in reader:\r
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]], workspace_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
+ a = os.path.join(workspace_path, pkg, a)\r
a = a.replace(os.sep, "/")\r
\r
logging.info("Ignoring Files {0}".format(a))\r
\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