From be4fc071eb01c7420707e887c92a3adf3e07ea72 Mon Sep 17 00:00:00 2001 From: Oliver Smith-Denny Date: Fri, 3 Apr 2026 13:37:01 -0700 Subject: [PATCH] BaseTools: Reject Inline Comments in tools_def There is a bug in BaseTools currently when an inline comment is used in tools_def. The comment is not stripped out and wreaks havoc down the line, causing BaseTools to get confused elsewhere and drop build options it should be applying. This fixes that behavior by following the build spec which states: Comments are only allows on separate lines and may not be appended appear on actual entry lines. Inline comments are now not allowed and the build will fail and specify why and where. Signed-off-by: Oliver Smith-Denny --- BaseTools/Source/Python/Common/ToolDefClassObject.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py index afc20a3c17..e8dd798f02 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -108,6 +108,10 @@ class ToolDefClassObject(object): if Line == "" or Line[0] == '#': continue + if '#' in Line: + EdkLogger.error("tools_def.txt parser", FILE_PARSE_FAILURE, + "tools_def.txt: Inline comments are not allowed. Line: " + str(Index + 1)) + if Line.startswith("!include"): IncFile = Line[8:].strip() Done, IncFile = self.ExpandMacros(IncFile)