[edk2] [RFC v2] Add Platform Include path in modules

Pankaj Bansal posted 1 patch 6 years, 1 month ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/AutoGen/AutoGen.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
[edk2] [RFC v2] Add Platform Include path in modules
Posted by Pankaj Bansal 6 years, 1 month ago
When we are writing the drivers for IP modules, then sometimes we want
that Platform specific customizations or platform dependent values be
supplied to IP module driver. normally we achieve this using Pcd values.

But sometimes we want to use header files for such data.e.g. if the
values are complex structures.

we need a mechanism that platform be able to supply these header files
to a module, without changing module code.

This patch is an attempt to achieve this functionality.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
---

Notes:
    V2:
     -check if .dec file exist before appending include paths to include path list

 BaseTools/Source/Python/AutoGen/AutoGen.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 405bfa1..4b281d8 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -3783,6 +3783,20 @@ class ModuleAutoGen(AutoGen):
                 for Inc in IncludesList:
                     if Inc not in self._IncludePathList:
                         self._IncludePathList.append(str(Inc))
+            PackageFilePath = os.path.join(self.PlatformInfo.MetaFile.SubDir, self.PlatformInfo.MetaFile.BaseName + '.dec')
+            if os.path.isfile(os.path.normpath(mws.join(self.PlatformInfo.MetaFile.Root, PackageFilePath))):
+                PackageFile = PathClass(PackageFilePath, self.PlatformInfo.MetaFile.Root)
+                Package = self.BuildDatabase[PackageFile, self.Arch, self.BuildTarget, self.ToolChain]
+                PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)
+                if PackageDir not in self._IncludePathList:
+                    self._IncludePathList.append(PackageDir)
+                IncludesList = Package.Includes
+                if Package._PrivateIncludes:
+                    if not self.MetaFile.Path.startswith(PackageDir):
+                        IncludesList = list(set(Package.Includes).difference(set(Package._PrivateIncludes)))
+                for Inc in IncludesList:
+                    if Inc not in self._IncludePathList:
+                        self._IncludePathList.append(str(Inc))
         return self._IncludePathList
 
     def _GetIncludePathLength(self):
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel