[edk2] [PATCH] BaseTools:Break build if same [LibraryClasses] name is used

Yonghong Zhu yonghong.zhu at intel.com
Thu Dec 13 17:39:33 PST 2018


From: zhijufan <zhijux.fan at intel.com>

For example if both PackageA and PackageB declare the
[LibraryClasses] name of MyLibClass, that is mapped to
an include file in each package:

PackageA.dec

[LibraryClasses]
  MyLibClass|Include/Library/MyLibClass.h

PackageB.dec

[LibraryClasses]
  MyLibClass|Include/Library/MyLibClass.h

Cc: Liming Gao <liming.gao at intel.com>
Cc: Yonghong Zhu <yonghong.zhu at intel.com>
Cc: Bob Feng <bob.c.feng at intel.com>
Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=954
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan at intel.com>
---
 .../Python/Workspace/WorkspaceCommon.py       | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index 55d01fa4b2..b05ed98888 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -20,7 +20,8 @@ from Workspace.BuildClassObject import StructurePcd
 from Common.BuildToolError import RESOURCE_NOT_AVAILABLE
 from Common.BuildToolError import OPTION_MISSING
 from Common.BuildToolError import BUILD_ERROR
-
+from Common.BuildToolError import OPTION_CONFLICT
+from Common import EdkLogger as EdkLogger
 class OrderedListDict(OrderedDict):
     def __init__(self, *args, **kwargs):
         super(OrderedListDict, self).__init__(*args, **kwargs)
@@ -48,6 +49,21 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain):
             PkgSet.update(Lib.Packages)
     return list(PkgSet)
 
+# Check that the LibraryClasses name are the same
+def CheckLibraryClassesName(PkgList):
+    LibraryDict = {}
+    for Pkg in PkgList:
+        LibCls = Pkg.LibraryClasses
+        for Lib in LibCls:
+            if Lib in LibraryDict:
+                if LibraryDict[Lib] != str(Pkg):
+                    EdkLogger.error("build", OPTION_CONFLICT,
+                                    "ClassName is conflicted,Please change the ClassName",
+                                    ExtraData="in [%s] [%s]\n\tClassName is [%s]" % (
+                                    LibraryDict[Lib], str(Pkg), Lib))
+            else:
+                LibraryDict[Lib] = str(Pkg)
+
 ## Get all declared PCD from platform for specified arch, target and toolchain
 #
 #  @param Platform: DscBuildData instance
@@ -60,6 +76,7 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain):
 #
 def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain, additionalPkgs):
     PkgList = GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain)
+    CheckLibraryClassesName(PkgList)
     PkgList = set(PkgList)
     PkgList |= additionalPkgs
     DecPcds = {}
-- 
2.18.0.windows.1



More information about the edk2-devel mailing list