public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Fix private includes for FILE_GUID override
@ 2019-05-16 11:17 Bob Feng
  2019-05-21  2:43 ` Liming Gao
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Feng @ 2019-05-16 11:17 UTC (permalink / raw)
  To: devel; +Cc: Michael D Kinney, Bob Feng, Liming Gao

From: Michael D Kinney <michael.d.kinney@intel.com>

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

When a module in a DSC file uses a FILE_GUID override in the
module scoped <Defines> section, a copy of the modified INF file
is placed in the Conf/.cache directory.  The check for private
includes uses the INF path to determine if the module is allowed
to use the private includes.  Since the INF path in this case is
not in any package, this check always fails, and no private
include paths are possible.

The fix is to keep both the OriginalPath and the new Path in
the PathClass object, and always use the OriginalPath to see if
the module INF is in the package with private includes.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +-
 BaseTools/Source/Python/Common/Misc.py     | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 31721a6f9f..c174b5a0bb 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -3414,11 +3414,11 @@ class ModuleAutoGen(AutoGen):
             PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)
             if PackageDir not in RetVal:
                 RetVal.append(PackageDir)
             IncludesList = Package.Includes
             if Package._PrivateIncludes:
-                if not self.MetaFile.Path.startswith(PackageDir):
+                if not self.MetaFile.OriginalPath.Path.startswith(PackageDir):
                     IncludesList = list(set(Package.Includes).difference(set(Package._PrivateIncludes)))
             for Inc in IncludesList:
                 if Inc not in RetVal:
                     RetVal.append(str(Inc))
         return RetVal
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 0e0cb45ebe..d082c58bef 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -279,10 +279,11 @@ def ProcessDuplicatedInf(Path, BaseName, Workspace):
     # The BaseName is the FILE_GUID which is also the output directory name.
     #
     #
     RtPath.Path = TempFullPath
     RtPath.BaseName = BaseName
+    RtPath.OriginalPath = Path
     #
     # If file exists, compare contents
     #
     if os.path.exists(TempFullPath):
         with open(str(Path), 'rb') as f1, open(TempFullPath, 'rb') as f2:
@@ -1403,10 +1404,11 @@ class PathClass(object):
         self.IsBinary = IsBinary
         self.Target = Target
         self.TagName = TagName
         self.ToolCode = ToolCode
         self.ToolChainFamily = ToolChainFamily
+        self.OriginalPath = self
 
     ## Convert the object of this class to a string
     #
     #  Convert member Path of the class to a string
     #
-- 
2.20.1.windows.1


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

* Re: [Patch] BaseTools: Fix private includes for FILE_GUID override
  2019-05-16 11:17 [Patch] BaseTools: Fix private includes for FILE_GUID override Bob Feng
@ 2019-05-21  2:43 ` Liming Gao
  0 siblings, 0 replies; 2+ messages in thread
From: Liming Gao @ 2019-05-21  2:43 UTC (permalink / raw)
  To: Feng, Bob C, devel@edk2.groups.io; +Cc: Kinney, Michael D

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Feng, Bob C
> Sent: Thursday, May 16, 2019 7:17 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [Patch] BaseTools: Fix private includes for FILE_GUID override
> 
> From: Michael D Kinney <michael.d.kinney@intel.com>
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1648
> 
> When a module in a DSC file uses a FILE_GUID override in the
> module scoped <Defines> section, a copy of the modified INF file
> is placed in the Conf/.cache directory.  The check for private
> includes uses the INF path to determine if the module is allowed
> to use the private includes.  Since the INF path in this case is
> not in any package, this check always fails, and no private
> include paths are possible.
> 
> The fix is to keep both the OriginalPath and the new Path in
> the PathClass object, and always use the OriginalPath to see if
> the module INF is in the package with private includes.
> 
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +-
>  BaseTools/Source/Python/Common/Misc.py     | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
> index 31721a6f9f..c174b5a0bb 100644
> --- a/BaseTools/Source/Python/AutoGen/AutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
> @@ -3414,11 +3414,11 @@ class ModuleAutoGen(AutoGen):
>              PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)
>              if PackageDir not in RetVal:
>                  RetVal.append(PackageDir)
>              IncludesList = Package.Includes
>              if Package._PrivateIncludes:
> -                if not self.MetaFile.Path.startswith(PackageDir):
> +                if not self.MetaFile.OriginalPath.Path.startswith(PackageDir):
>                      IncludesList = list(set(Package.Includes).difference(set(Package._PrivateIncludes)))
>              for Inc in IncludesList:
>                  if Inc not in RetVal:
>                      RetVal.append(str(Inc))
>          return RetVal
> diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
> index 0e0cb45ebe..d082c58bef 100644
> --- a/BaseTools/Source/Python/Common/Misc.py
> +++ b/BaseTools/Source/Python/Common/Misc.py
> @@ -279,10 +279,11 @@ def ProcessDuplicatedInf(Path, BaseName, Workspace):
>      # The BaseName is the FILE_GUID which is also the output directory name.
>      #
>      #
>      RtPath.Path = TempFullPath
>      RtPath.BaseName = BaseName
> +    RtPath.OriginalPath = Path
>      #
>      # If file exists, compare contents
>      #
>      if os.path.exists(TempFullPath):
>          with open(str(Path), 'rb') as f1, open(TempFullPath, 'rb') as f2:
> @@ -1403,10 +1404,11 @@ class PathClass(object):
>          self.IsBinary = IsBinary
>          self.Target = Target
>          self.TagName = TagName
>          self.ToolCode = ToolCode
>          self.ToolChainFamily = ToolChainFamily
> +        self.OriginalPath = self
> 
>      ## Convert the object of this class to a string
>      #
>      #  Convert member Path of the class to a string
>      #
> --
> 2.20.1.windows.1


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

end of thread, other threads:[~2019-05-21  2:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-16 11:17 [Patch] BaseTools: Fix private includes for FILE_GUID override Bob Feng
2019-05-21  2:43 ` Liming Gao

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