From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web12.56756.1598890331563612728 for ; Mon, 31 Aug 2020 09:12:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: bob.c.feng@intel.com) IronPort-SDR: Jte9LnyGQillq247HPjhxADflfL+VLKP7bS0kgTP8hyUhnA8VM8U1P09t+k/fx/hGnlYFSOHlJ cHQr9YCxlWtw== X-IronPort-AV: E=McAfee;i="6000,8403,9730"; a="136536521" X-IronPort-AV: E=Sophos;i="5.76,376,1592895600"; d="scan'208";a="136536521" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 09:12:08 -0700 IronPort-SDR: kL9acfziorlILZZ4cCvIWSphmppi5kqPcnJx0xlH/GqiNL3cp8F/FVk/Sy8rqqxRyiUVz0FQQV x2tXObVM1ZIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,376,1592895600"; d="scan'208";a="501899944" Received: from bfeng1-mobl1.ccr.corp.intel.com ([10.254.212.85]) by fmsmga005.fm.intel.com with ESMTP; 31 Aug 2020 09:12:05 -0700 From: "Bob Feng" To: edk2-devel@lists.01.org, devel@edk2.groups.io Cc: "Bob Feng" , Liming Gao , Yuwei Chen , Shenglei Zhang Subject: [Patch 1/1] BaseTools/Ecc: Fix an issue of path separator compatibility Date: Tue, 1 Sep 2020 00:11:59 +0800 Message-Id: <20200831161159.26652-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 From: "Bob Feng" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2904 The path separator is different in Windows and Linux, the original code does not handle this difference. This patch is to fix this issue. Signed-off-by: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Cc: Shenglei Zhang --- BaseTools/Source/Python/Ecc/Check.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index 0fdc7e35c18a..ca24c8acffeb 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -13,10 +13,11 @@ from Ecc.EccToolError import * from Ecc.MetaDataParser import ParseHeaderCommentSection from Ecc import EccGlobalData from Ecc import c from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws +import platform ## Check # # This class is to define checkpoints used by ECC tool # @@ -1099,17 +1100,18 @@ class Check(object): InfPathSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand) InfPathList = [] for Item in InfPathSet: if Item[0] not in InfPathList: InfPathList.append(Item[0]) + pathsep = """'\\'""" if platform.system() == 'Windows' else """'/'""" SqlCommand = """ select ID, Path, FullPath from File where upper(FullPath) not in - (select upper(A.Path) || '\\' || upper(B.Value1) from File as A, INF as B + (select upper(A.Path) || %s || upper(B.Value1) from File as A, INF as B where A.ID in (select BelongsToFile from INF where Model = %s group by BelongsToFile) and B.BelongsToFile = A.ID and B.Model = %s) and (Model = %s or Model = %s) - """ % (MODEL_EFI_SOURCE_FILE, MODEL_EFI_SOURCE_FILE, MODEL_FILE_C, MODEL_FILE_H) + """ % (pathsep, MODEL_EFI_SOURCE_FILE, MODEL_EFI_SOURCE_FILE, MODEL_FILE_C, MODEL_FILE_H) RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand) for Record in RecordSet: Path = Record[1] Path = Path.upper().replace('\X64', '').replace('\IA32', '').replace('\EBC', '').replace('\IPF', '').replace('\ARM', '') if Path in InfPathList: @@ -1122,21 +1124,22 @@ class Check(object): EdkLogger.quiet("Checking for pcd type in c code function usage ...") SqlCommand = """ select ID, Model, Value1, Value2, BelongsToFile from INF where Model > %s and Model < %s """ % (MODEL_PCD, MODEL_META_DATA_HEADER) PcdSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand) + pathsep = """'\\'""" if platform.system() == 'Windows' else """'/'""" for Pcd in PcdSet: Model = Pcd[1] PcdName = Pcd[2] if Pcd[3]: PcdName = Pcd[3] BelongsToFile = Pcd[4] SqlCommand = """ select ID from File where FullPath in - (select B.Path || '\\' || A.Value1 from INF as A, File as B where A.Model = %s and A.BelongsToFile = %s + (select B.Path || %s || A.Value1 from INF as A, File as B where A.Model = %s and A.BelongsToFile = %s and B.ID = %s and (B.Model = %s or B.Model = %s)) - """ % (MODEL_EFI_SOURCE_FILE, BelongsToFile, BelongsToFile, MODEL_FILE_C, MODEL_FILE_H) + """ % (pathsep, MODEL_EFI_SOURCE_FILE, BelongsToFile, BelongsToFile, MODEL_FILE_C, MODEL_FILE_H) TableSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand) for Tbl in TableSet: TblName = 'Identifier' + str(Tbl[0]) SqlCommand = """ select Name, ID from %s where value like '%s' and Model = %s -- 2.18.0.windows.1