public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/1] BaseTools/Ecc: Fix an issue of path separator compatibility
@ 2020-08-31 16:14 Bob Feng
  2020-09-01  8:05 ` [edk2-devel] " Laszlo Ersek
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Feng @ 2020-08-31 16:14 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao, Yuwei Chen, Shenglei Zhang

From: "Bob Feng" <bob.c.feng@intel.com>

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 <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Shenglei Zhang <shenglei.zhang@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [Patch 1/1] BaseTools/Ecc: Fix an issue of path separator compatibility
  2020-08-31 16:14 [Patch 1/1] BaseTools/Ecc: Fix an issue of path separator compatibility Bob Feng
@ 2020-09-01  8:05 ` Laszlo Ersek
  2020-09-01 10:29   ` Bob Feng
  0 siblings, 1 reply; 3+ messages in thread
From: Laszlo Ersek @ 2020-09-01  8:05 UTC (permalink / raw)
  To: devel, bob.c.feng; +Cc: Liming Gao, Yuwei Chen, Shenglei Zhang

On 08/31/20 18:14, Bob Feng wrote:
> From: "Bob Feng" <bob.c.feng@intel.com>
> 
> 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 <bob.c.feng@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.chen@intel.com>
> Cc: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
>  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
> 

(1) any reason for not using os.sep (aka os.path.sep) instead?

(2) do you intend this patch for the stable tag?

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [Patch 1/1] BaseTools/Ecc: Fix an issue of path separator compatibility
  2020-09-01  8:05 ` [edk2-devel] " Laszlo Ersek
@ 2020-09-01 10:29   ` Bob Feng
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Feng @ 2020-09-01 10:29 UTC (permalink / raw)
  To: Laszlo Ersek, devel@edk2.groups.io, gaoliming@byosoft.com.cn
  Cc: Liming Gao, Chen, Christine, Zhang, Shenglei

Laszlo,

1) there is no special reason not using os.sep, I sent out a new patch to use it.

Liming,

2) If this patch can be included in this stable tag, that will great.  From the Bugzilla, I see this issue will block patch merging.

Thanks,
Bob

-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com> 
Sent: Tuesday, September 1, 2020 4:06 PM
To: devel@edk2.groups.io; Feng, Bob C <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>; Zhang, Shenglei <shenglei.zhang@intel.com>
Subject: Re: [edk2-devel] [Patch 1/1] BaseTools/Ecc: Fix an issue of path separator compatibility

On 08/31/20 18:14, Bob Feng wrote:
> From: "Bob Feng" <bob.c.feng@intel.com>
> 
> 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 <bob.c.feng@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.chen@intel.com>
> Cc: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
>  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
> 

(1) any reason for not using os.sep (aka os.path.sep) instead?

(2) do you intend this patch for the stable tag?

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-01 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-31 16:14 [Patch 1/1] BaseTools/Ecc: Fix an issue of path separator compatibility Bob Feng
2020-09-01  8:05 ` [edk2-devel] " Laszlo Ersek
2020-09-01 10:29   ` Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox