Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseTools: Detect invalid library override #452

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions BaseTools/Source/Python/Workspace/WorkspaceCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_CLASS for override: [%s] does not match the library class being overridden: [%s]" % (path, LibraryClass),
File=FileName)
# MU_CHANGE end

# EdkII module
LibraryConsumerList = [Module]
Constructor = []
Expand Down