From 571f770dc0363dcd4d0d3503c2cafab465f445b5 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Mon, 12 Jun 2023 14:34:54 -0700 Subject: [PATCH 1/2] BaseTools: Detect invalid library override Ensures LIBRARY_CLASS as specified in the library override INF defines section is the same value as the library class specified in the override line. --- .../Python/Workspace/WorkspaceCommon.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index 9e506fc646..bfd520d534 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -110,6 +110,26 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha if LibraryClass.startswith("NULL"): Module.LibraryClasses[LibraryClass] = Platform.Modules[str(Module)].LibraryClasses[LibraryClass] + # MU_CHANGE begin + + # Compares the Library class being over written (var: LibraryClass) to the actual library class that is + # is doing the overridding. + # + # i.e. ExampleLib|Path/To/ExampleLibBase.inf: + # ensuring ExampleLib == LIBRARY_CLASS in the define section of ExampleLibBase.inf + else: + path = Platform.Modules[str(Module)].LibraryClasses[LibraryClass] + match = False + for LibraryClassObj in BuildDatabase[path, Arch, Target, Toolchain].LibraryClass: + if LibraryClass == LibraryClassObj.LibraryClass: + match = True + + if not match: + EdkLogger.error("build", BUILD_ERROR, + "Library override [%s] library class does not match specified library class: [%s]" % (path, LibraryClass), + File=FileName) + # MU_CHANGE end + # EdkII module LibraryConsumerList = [Module] Constructor = [] From 4322c3db0f60622b98e98a7599f44b49b029f1c6 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Mon, 12 Jun 2023 14:48:29 -0700 Subject: [PATCH 2/2] update --- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index bfd520d534..1ddc8d530f 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -126,7 +126,7 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha if not match: EdkLogger.error("build", BUILD_ERROR, - "Library override [%s] library class does not match specified library class: [%s]" % (path, LibraryClass), + "LIBRARY_CLASS for override: [%s] does not match the library class being overridden: [%s]" % (path, LibraryClass), File=FileName) # MU_CHANGE end