summaryrefslogtreecommitdiff
path: root/BaseTools
AgeCommit message (Collapse)AuthorFilesLines
2 daysBaseTools: PatchCheck.py: Allow MultiPkg Commits For Subject CheckOliver Smith-Denny1-3/+9
Subject Check was added to PatchCheck.py to enforce that if a package was touched in a commit that it be referenced in the subject line. However, this is impractical for multipackage commits with many packages, e.g. when stack cookies were added, every package was touched, but in a rote way, and it is not reasonable to put every package in a subject line. This updates PatchCheck.py to check if ignore_multi_package is set and if so only require that package names be included in the subject if there are fewer than 3 packages touched. Otherwise, PatchCheck will require the message to start with `Global:` to indicate it touches more than 3 packages. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2 daysBaseTools/PatchCheck.py: Check CI Options Before ParsingOliver Smith-Denny1-1/+1
PatchCheck.py currently parses the CI options as the last step it does before reporting results. This means that the other checking logic cannot use any of the CI options that are passed in. This updates the order of operations to process CI options before running other checks so that they can be used in performing checks. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
3 daysBaseTools: Update architectures in target.templateGao Qihang1-2/+2
- Remove IPF since it's no longer supported in edk2. - Rename AArch64 to AARCH64 for greater accuracy. - Add newly supported RISCV64 and LOONGARCH64. Cc: Chao Li <lichao@loongson.cn> Signed-off-by: Gao Qihang <gaoqihang@loongson.cn>
13 daysBaseTools: DSC: fix processing !include in multiarch subsectionsSergii Dmytruk1-1/+5
Commit f0a2015373 ("UefiPayloadPkg: Add AARCH64 support") changed `[Components.X64]` to `[Components.X64, Components.AARCH64]` which resulted in the following code within that section to not work as expected (the code wasn't there, just providing a real world example that uncovered the issue): [Components.X64, Components.AARCH64] FmpDevicePkg/FmpDxe/FmpDxe.inf { ... <PcdsFixedAtBuild> !include .../...PcdFmpDevicePkcs7CertBufferXdr.inc ... } At the same time `[Components.X64]` or even `[Components.AARCH64, Components.X64]` (notice the swapped order) worked fine for X64 target. The cause of the issue turned out to be skipping includes inside `_PostProcess()` method of `DscParser` class. This method processes list of items stored in a database filled on the first pass through a DSC file in `Start()` method. One of the fields stored in each row of a table is link to a parent object (owner). A section like `[Components.X64, Components.AARCH64]` creates two objects and all of its subelements are duplicated for both X64 and AARCH64. This was not happening for !include statement in the example above. Because `_PostProcess()` contracted a sequence of !include objects disregarding their owner, it did not create instance for each of the requested targets. Codewise, `self._ContentIndex` was incremented more than once, while `__ProcessDirective()` method (invoked indirectly as `Processer[self._ItemType]()`) queried owner of the current directive as: if self._InSubsection: Owner = self._Content[self._ContentIndex - 1][8] else: # not taken in this case This is why order of targets made a difference, only the last was fully initialized in this case. An alternative fix is completely dropping merging of !include directives, but hard to say whether it still has some utility (the code is complex, hard to follow and barely documented). Safer to keep it, in the worst case it doesn't do anything now. Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2025-08-22BaseTools/VfrCompile: Add check for setting string default to numberGao Qihang1-2/+3
It's illegal that string default is numeric type in vfr string definition. This patch add a check to the illegal behavior. If numeric string default is encountered, throw a invalid parameter error to break VfrCompile. Cc: Chao Li <lichao@loongson.cn> Signed-off-by: Gao Qihang <gaoqihang@loongson.cn>
2025-07-30BaseTools: Fix FMMT FvHandler Padding operation issuesecurity-advisory/cve-2025-xxxxx/advisoryYuwei Chen1-4/+22
When using the FMMT FvHandler function, new padding size should be calculated correctly comparing with origin ffs and new ffs, else it will cause the binary size changes. This patch is used to fix the bug. Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
2025-07-23BaseTools/tools_def: Enable frame pointer for RISC-VTuan Phan1-1/+1
Add -fno-omit-frame-pointer to RISC-V targets to ensure frame pointers are preserved, supporting stack backtraces for debugging. Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
2025-07-22BaseTools/tools_def: Always link with -Wl,-z,notext for BFD/LLDJames Le Cuirot1-10/+11
Commit a257988f590ba90dd8394dd6bc7014ae9d814a08 added -Wl,-z,notext, but only when linking for IA32/X64 with LLD. BFD can also be configured to either warn or error when text relocations are detected. It does not check at all by default, but Gentoo Linux tells it to warn in its regular configuration and tells it to error in its hardened configuration. Commit 14cb48b0a053b44c5a6bcc89cbbbf86ac78c7820 made linker warnings fatal in all BFD cases. At least the AARCH64 and IA32/X64 code does include text relocations, so this now fails to build on Gentoo Linux. We should therefore always use -Wl,-z,notext. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2025-07-22BaseTools/tools_def: Make linker warnings fatal for RISCV + LOONGARCH64James Le Cuirot1-3/+3
For consistency, and as before, for GCC5 only. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2025-07-22BaseTools/tools_def: Drop unused GCC IA32/X64 flag variablesJames Le Cuirot1-12/+9
These haven't been used since before 2d07607d8b1a0710ba7379f8ee6c11dae1, when UNIXGCC support was dropped. The recent change in 14cb48b0a053b44c5a6bcc89cbbbf86ac78c7820 to make linker warnings fatal was therefore ineffective for these architectures. As requested, also make linker warnings fatal for GCC5 only. The last release made them fatal for AARCH64 on GCC48/GCC49, but it seems likely no one has actually tested that yet. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2025-07-10BaseTools/toolsetup.bat: Set IASL_PREFIX when using Mingw-w64 on WindowsNate DeSimone2-1/+17
If IASL_PREFIX is not already defined, then edksetup.bat should set it. This unifies the behavior between Visual Studio and Mingw-w64. Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
2025-07-10BaseTools/tools_def: Use MSVC ABI for CLANGPDB TargetsNate DeSimone1-3/+3
Update the CLANGPDB toolchain configuration to use MSVC ABI targets and retain frame pointers in generated code. This improves compatibility with the Microsoft Debug Interface Access (DIA) SDK and improves debuggability with any debugger that uses the Microsoft PDB parser, for example the Visual Studio debugger or windbg. Without these changes, code generated by the Clang compiler will have a mix of calling conventions. With the current configuration, any function declared with EFIAPI will use the Microsoft x64 calling convention. However, the default calling convention will be the SysV x64 calling convention. This mixing of calling conventions prevents debuggers from decoding the call stack. With these changes, only the Microsoft x64 calling convention will be used. These modifications enable debuggers to properly parse and display call stacks on binaries built with the CLANGPDB toolchain. The changes include: - Switch from GNU ABI target (*-unknown-windowsl-gnu) to MSVC ABI targets (*-pc-windows-msvc) for both IA32 and X64 architectures. - Remove -fseh-exceptions as not supported. - Add -fno-omit-frame-pointer as required for call stack. - Undefine the _MSC_VER macro, and define the __GNUC__ macro, so that pre-processor conditionals will continue to function as expected. Co-authored-by: Muhammad Mustafa <muhammad.mustafa@intel.com> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
2025-07-08BaseTools: Remove UGA supportGuoMinJ2-211/+0
The Universal Graphics Adapter (UGA) is a graphic abstraction. The UGA I/O and Draw protocols are deprecated since UEFI 2.0 was introduced. Cf. the UEFI spec v2.9: "Appendix L - EFI 1.10 Protocol Changes and Deprecation List" section L.2 "Deprecated Protocols" Remove the UGA support. Signed-off-by: GuoMinJ <newexplorerj@gmail.com> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-08BaseTools: Improve report generation for Nested Fvs.Aaron Pop1-7/+15
Build report would not detect a nested FV if the nested FV was not in a subsection of an FFS statement. Modify the build report to better handle some of the variations of nested FVs. Failing Example: [Fv.FvName1] INF <path to some driver>.inf [Fv.FvName0] FILE FV_IMAGE = B25ACDEF-39CE-4FA5-B50A-33E24DB1BDDF { SECTION FV_IMAGE = FvName1 } Working Example: [Fv.FvName1] INF <path to some driver>.inf [Fv.FvName0] FILE FV_IMAGE = DA04F6BF-A0FD-47EC-928B-5101A6C95026 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { SECTION FV_IMAGE = FvName1 } } Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2025-07-04BaseTools: Fix the spelling or typoAbdul Lateef Attar1-1/+2
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
2025-07-02BaseTools/PatchCheck.py: permit at least 20 characters after ':'Leif Lindholm1-2/+7
Commit b55530ad4460 ("BaseTools/PatchCheck.py: verify commit message lists package(s)") introduced a check for the requirement to enumerate all modified packages in the commit subject line. But it did leave the maximum line length at 75 characters (for non-CVE commits), which can get a bit cramped for changes to several packages. Introduce a new arbitrary "at least 20 characters after the :" limit. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-07-02BaseTools/PatchCheck.py: clean up subject line length handlingLeif Lindholm1-10/+8
Use a temporary variable for max subject line length and log result of test in one location. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-07-02BaseTools/PatchCheck.py: drop redundant line count checkLeif Lindholm1-1/+1
Before doing the subject line length check, the script checks that the number of lines in the commit message (including subject) is not less than or equal to zero - and returns if it is. However, then the test for whether the subject line starts with a CVE tag inexplicably also checks for whether the number of lines are greater than or equal to one. This is just clutter, so drop it. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-07-01BaseTools: WorkSpace: Remove unnecessary codePierre Gondois7-144/+0
Running the vulture tool on the WorkSpace folder gave the following report. Remove the unnecessary code. - Workspace/BuildClassObject.py:148: unused method 'IsSimpleTypeArray' (60% confidence) - Workspace/BuildClassObject.py:337: unused method 'SetPcdMode' (60% confidence) - Workspace/BuildClassObject.py:612: unused attribute 'DscSpecification' (60% confidence) - Workspace/DscBuildData.py:451: unused property 'DscSpecification' (60% confidence) - Workspace/DscBuildData.py:1253: unused method 'GetBuildOptionsByPkg' (60% confidence) - Workspace/DscBuildData.py:2064: unused method 'GetStarNum' (60% confidence) - Workspace/DscBuildData.py:3613: unused method 'AddModule' (60% confidence) - Workspace/DscBuildData.py:3650: unused method 'AddPcd' (60% confidence) - Workspace/InfBuildData.py:117: unused attribute '_TailComments' (60% confidence) - Workspace/InfBuildData.py:126: unused attribute '_BinaryModule' (60% confidence) - Workspace/MetaDataTable.py:114: unused method 'IsIntegral' (60% confidence) - Workspace/MetaDataTable.py:218: unused method 'GetFileTimeStamp' (60% confidence) - Workspace/MetaDataTable.py:230: unused method 'SetFileTimeStamp' (60% confidence) - Workspace/MetaDataTable.py:298: unused method 'GetCrossIndex' (60% confidence) - Workspace/MetaFileParser.py:161: unused attribute '_FileDir' (60% confidence) - Workspace/MetaFileParser.py:1187: unused method '_DecodeCODEData' (60% confidence) - Workspace/MetaFileParser.py:1796: unused attribute '_RestofValue' (60% confidence) - Workspace/MetaFileTable.py:31: unused attribute '_NumpyTab' (60% confidence) - Workspace/WorkspaceDatabase.py:136: unused class 'TransformObjectFactory' (60% confidence) - Workspace/WorkspaceDatabase.py:159: unused attribute 'TransformObject' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: UPT/Library: Remove unnecessary codePierre Gondois7-1155/+0
Running the vulture tool on the UPT/Library folder gave the following report. Remove the unnecessary code. - UPT/Library/CommentGenerating.py:50: unused function 'GenGenericComment' (60% confidence) - UPT/Library/CommentGenerating.py:172: unused function 'GenInfPcdTailComment' (60% confidence) - UPT/Library/CommentGenerating.py:185: unused function 'GenInfProtocolPPITailComment' (60% confidence) - UPT/Library/CommentGenerating.py:203: unused function 'GenInfGuidTailComment' (60% confidence) - UPT/Library/Misc.py:504: unused class 'MergeCommentDict' (60% confidence) - UPT/Library/Misc.py:527: unused function 'GenDummyHelpTextObj' (60% confidence) - UPT/Library/ParserValidate.py:110: unused function 'IsValidInfComponentType' (60% confidence) - UPT/Library/ParserValidate.py:122: unused function 'IsValidToolFamily' (60% confidence) - UPT/Library/ParserValidate.py:134: unused function 'IsValidToolTagName' (60% confidence) - UPT/Library/ParserValidate.py:465: unused function 'IsValidBuildNumber' (60% confidence) - UPT/Library/ParserValidate.py:478: unused function 'IsValidDepex' (60% confidence) - UPT/Library/ParserValidate.py:546: unused function 'IsValidVersionString' (60% confidence) - UPT/Library/ParserValidate.py:721: unused function 'CheckUTF16FileHeader' (60% confidence) - UPT/Library/Parsing.py:52: unused function 'GetBuildOption' (60% confidence) - UPT/Library/Parsing.py:100: unused function 'GetLibraryClassOfInf' (60% confidence) - UPT/Library/Parsing.py:150: unused function 'GetPcd' (60% confidence) - UPT/Library/Parsing.py:177: unused function 'GetFeatureFlagPcd' (60% confidence) - UPT/Library/Parsing.py:201: unused function 'GetDynamicDefaultPcd' (60% confidence) - UPT/Library/Parsing.py:227: unused function 'GetDynamicHiiPcd' (60% confidence) - UPT/Library/Parsing.py:254: unused function 'GetDynamicVpdPcd' (60% confidence) - UPT/Library/Parsing.py:277: unused function 'GetComponent' (60% confidence) - UPT/Library/Parsing.py:392: unused function 'GetExec' (60% confidence) - UPT/Library/Parsing.py:416: unused function 'GetComponents' (60% confidence) - UPT/Library/Parsing.py:532: unused function 'GetSource' (60% confidence) - UPT/Library/Parsing.py:581: unused function 'GetGuidsProtocolsPpisOfInf' (60% confidence) - UPT/Library/Parsing.py:595: unused function 'GetGuidsProtocolsPpisOfDec' (60% confidence) - UPT/Library/Parsing.py:645: unused function 'GetPcdOfInf' (60% confidence) - UPT/Library/Parsing.py:682: unused function 'GetPcdOfDec' (60% confidence) - UPT/Library/Parsing.py:739: unused function 'InsertSectionItems' (60% confidence) - UPT/Library/Parsing.py:776: unused function 'GenMetaDatSectionItem' (60% confidence) - UPT/Library/StringUtils.py:87: unused function 'GetLibraryClassesWithModuleType' (60% confidence) - UPT/Library/StringUtils.py:107: unused function 'GetDynamics' (60% confidence) - UPT/Library/StringUtils.py:350: unused function 'GetMultipleValuesOfKeyFromLines' (60% confidence) - UPT/Library/StringUtils.py:396: unused function 'GetSingleValueOfKeyFromLines' (60% confidence) - UPT/Library/StringUtils.py:463: unused function 'PreCheck' (60% confidence) - UPT/Library/StringUtils.py:675: unused function 'StringArrayLength' (60% confidence) - UPT/Library/StringUtils.py:718: unused function 'IsHexDigit' (60% confidence) - UPT/Library/UniClassObject.py:86: unused function 'UniToStr' (60% confidence) - UPT/Library/UniClassObject.py:227: unused attribute 'StringNameByteList' (60% confidence) - UPT/Library/UniClassObject.py:237: unused attribute 'StringNameByteList' (60% confidence) - UPT/Library/UniClassObject.py:377: unused method 'GetIncludeFile' (60% confidence) - UPT/Library/UniClassObject.py:947: unused method 'FindStringValue' (60% confidence) - UPT/Library/UniClassObject.py:957: unused method 'FindByToken' (60% confidence) - UPT/Library/UniClassObject.py:1022: unused method 'ReadIncludeUNIfile' (60% confidence) - UPT/Library/StringUtils.py:718: unused function 'IsHexDigit' (60% confidence) - UPT/Library/Xml/XmlRoutines.py:176: unused function 'XmlElementList' (60% confidence) - UPT/Library/Xml/XmlRoutines.py:202: unused function 'XmlNodeName' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: UPT/Xml: Remove unnecessary codePierre Gondois1-1/+0
Running the vulture tool on the UPT/Xml folder gave the following report. Remove the unnecessary code. - UPT/Xml/CommonXml.py:585: unused attribute 'LangDefsList' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: UPT/PomAdapter: Remove unnecessary codePierre Gondois1-47/+0
Running the vulture tool on the UPT/PomAdapter folder gave the following report. Remove the unnecessary code. - UPT/PomAdapter/DecPomAlignment.py:898: unused method 'ShowPackage' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: UPT/Parser: Remove unnecessary codePierre Gondois3-72/+0
Running the vulture tool on the UPT/Parser folder gave the following report. Remove the unnecessary code. - UPT/Parser/InfAsBuiltProcess.py:223: unused function 'GetInfsFromWorkSpace' (60% confidence) - UPT/Parser/InfAsBuiltProcess.py:237: unused function 'GetGuidVerFormLibInstance' (60% confidence) - UPT/Parser/InfParserMisc.py:211: unused attribute 'InfPeiDepexSection' (60% confidence) - UPT/Parser/InfParserMisc.py:212: unused attribute 'InfDxeDepexSection' (60% confidence) - UPT/Parser/InfParserMisc.py:213: unused attribute 'InfSmmDepexSection' (60% confidence) - UPT/Parser/InfSectionParser.py:231: unused attribute 'InfPeiDepexSection' (60% confidence) - UPT/Parser/InfSectionParser.py:232: unused attribute 'InfDxeDepexSection' (60% confidence) - UPT/Parser/InfSectionParser.py:233: unused attribute 'InfSmmDepexSection' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: Table: Remove unnecessary codePierre Gondois3-36/+0
Running the vulture tool on the Table folder gave the following report. Remove the unnecessary code. - Table/Table.py:88: unused method 'GenerateID' (60% confidence) - Table/TableDataModel.py:83: unused method 'GetCrossIndex' (60% confidence) - Table/TableEotReport.py:66: unused method 'GetMaxID' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: GenFds: Remove unnecessary codePierre Gondois6-63/+0
Running the vulture tool on the GenFds folder gave the following report. Remove the unnecessary code. - GenFds/Fd.py:146: unused method 'GenFlashMap' (60% confidence) - GenFds/FdfParser.py:1539: unused attribute 'BaseAddressPcd' (60% confidence) - GenFds/FdfParser.py:1556: unused attribute 'SizePcd' (60% confidence) - GenFds/FdfParser.py:2394: unused attribute 'CurrentLineNum' (60% confidence) - GenFds/FdfParser.py:2395: unused attribute 'CurrentLineContent' (60% confidence) - GenFds/FdfParser.py:2653: unused attribute 'CurrentLineNum' (60% confidence) - GenFds/FdfParser.py:2654: unused attribute 'CurrentLineContent' (60% confidence) - GenFds/FdfParser.py:3229: unused attribute 'CreateFile' (60% confidence) - GenFds/FfsFileStatement.py:36: unused attribute 'CurrentLineNum' (60% confidence) - GenFds/FfsFileStatement.py:37: unused attribute 'CurrentLineContent' (60% confidence) - GenFds/FfsInfStatement.py:68: unused attribute 'CurrentLineNum' (60% confidence) - GenFds/FfsInfStatement.py:69: unused attribute 'CurrentLineContent' (60% confidence) - GenFds/GenFds.py:68: unused attribute 'LibDir' (60% confidence) - GenFds/GenFds.py:557: unused method 'GetFvBlockSize' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: FMTT: Remove unnecessary codePierre Gondois4-51/+1
Running the vulture tool on the FMTT folder gave the following report. Remove the unnecessary code. - FMMT/core/BinaryFactoryProduct.py:132: unused attribute 'ROffset' (60% confidence) - FMMT/core/BinaryFactoryProduct.py:176: unused attribute 'ROffset' (60% confidence) - FMMT/core/BinaryFactoryProduct.py:229: unused attribute 'ROffset' (60% confidence) - FMMT/core/BinaryFactoryProduct.py:365: unused class 'ElfSectionProduct' (60% confidence) - FMMT/core/BinaryFactoryProduct.py:369: unused method 'ParserSectionData' (60% confidence) - FMMT/core/BinaryFactoryProduct.py:371: unused method 'ParserProgramData' (60% confidence) - FMMT/core/BiosTree.py:76: unused method 'insertRel' (60% confidence) - FMMT/core/BiosTree.py:84: unused method 'deleteNode' (60% confidence) - FMMT/core/BiosTreeNode.py:63: unused attribute 'ROffset' (60% confidence) - FMMT/core/BiosTreeNode.py:125: unused attribute 'ROffset' (60% confidence) - FMMT/core/BiosTreeNode.py:182: unused attribute 'ROffset' (60% confidence) - FMMT/core/BiosTreeNode.py:185: unused attribute 'SectionMaxAlignment' (60% confidence) - FMMT/core/BiosTreeNode.py:220: unused attribute 'ROffset' (60% confidence) - FMMT/core/BiosTreeNode.py:223: unused attribute 'OriHeader' (60% confidence) - FMMT/core/BiosTreeNode.py:226: unused attribute 'SectionMaxAlignment' (60% confidence) - FMMT/core/BiosTreeNode.py:247: unused attribute 'ROffset' (60% confidence) - FMMT/FMMT.py:52: unused attribute 'firmware_packet' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: Eot: Remove unnecessary codePierre Gondois7-308/+0
Running the vulture tool on the Eot folder gave the following report. Remove the unnecessary code. - Eot/CodeFragment.py:47: unused class 'AssignmentExpression' (60% confidence) - Eot/CodeFragmentCollector.py:75: unused attribute '__Token' (60% confidence) - Eot/CodeFragmentCollector.py:76: unused attribute '__SkippedChars' (60% confidence) - Eot/CodeFragmentCollector.py:104: unused method '__EndOfLine' (60% confidence) - Eot/CodeFragmentCollector.py:129: unused method '__UndoOneChar' (60% confidence) - Eot/CodeFragmentCollector.py:215: unused method '__InsertComma' (60% confidence) - Eot/Database.py:81: unused attribute 'text_factory' (60% confidence) - Eot/EotMain.py:1012: unused method 'SetFreeSpace' (60% confidence) - Eot/Identification.py:36: unused method 'GetFileFullPath' (60% confidence) - Eot/Identification.py:43: unused method 'GetFileRelativePath' (60% confidence) - Eot/Parser.py:119: unused function 'AddToGlobalMacro' (60% confidence) - Eot/Parser.py:238: unused function 'GetAllSourceFiles' (60% confidence) - Eot/Parser.py:257: unused function 'ParseConditionalStatementMacros' (60% confidence) - Eot/Parser.py:267: unused function 'GetAllFiles' (60% confidence) - Eot/Parser.py:291: unused function 'ParseConditionalStatement' (60% confidence) - Eot/Parser.py:367: unused function 'GetConditionalStatementStatus' (60% confidence) - Eot/Parser.py:722: unused function 'ConvertGuid' (60% confidence) - Eot/Parser.py:857: unused function 'ConvertGuid2' (60% confidence) - Eot/Report.py:161: unused method 'GeneratePpi' (60% confidence) - Eot/Report.py:173: unused method 'GenerateProtocol' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: Ecc: Remove unnecessary codePierre Gondois5-200/+0
Running the vulture tool on the Ecc folder gave the following report. Remove the unnecessary code. - Ecc/c.py:52: unused function 'GetConfig' (60% confidence) - Ecc/c.py:484: unused function 'GetFileModificationTimeFromDB' (60% confidence) - Ecc/CodeFragmentCollector.py:77: unused attribute '__Token' (60% confidence) - Ecc/CodeFragmentCollector.py:78: unused attribute '__SkippedChars' (60% confidence) - Ecc/CodeFragmentCollector.py:109: unused method '__EndOfLine' (60% confidence) - Ecc/CodeFragmentCollector.py:134: unused method '__UndoOneChar' (60% confidence) - Ecc/CodeFragmentCollector.py:221: unused method '__InsertComma' (60% confidence) - Ecc/CodeFragmentCollector.py:539: unused method 'PrintFragments' (60% confidence) - Ecc/Database.py:81: unused attribute 'text_factory' (60% confidence) - Ecc/Database.py:214: unused method 'UpdateIdentifierBelongsToFunction_disabled' (60% confidence) - Ecc/MetaFileWorkspace/MetaDataTable.py:142: unused method 'IsIntegral' (60% confidence) - Ecc/MetaFileWorkspace/MetaDataTable.py:205: unused method 'GetCrossIndex' (60% confidence) - Ecc/Xml/XmlRoutines.py:145: unused function 'XmlElementData' (60% confidence) - Ecc/Xml/XmlRoutines.py:162: unused function 'XmlElementList' (60% confidence) - Ecc/Xml/XmlRoutines.py:192: unused function 'XmlNodeName' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: Capsule: Remove unnecessary codePierre Gondois1-5/+0
Running the vulture tool on the Capsule folder gave the following report. Remove the unnecessary code. - Capsule/WindowsCapsuleSupportHelper.py:26: unused method 'RegisterHelpers' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: build: Remove unnecessary codePierre Gondois2-85/+0
Running the vulture tool on the build folder gave the following report. Remove the unnecessary code. - build/build.py:79: unused function 'IsToolInPath' (60% confidence) - build/build.py:396: unused class 'PlatformMakeUnit' (60% confidence) - build/build.py:570: unused method 'GetErrorMessage' (60% confidence) - build/build.py:806: unused attribute 'HashSkipModules' (60% confidence) - build/build.py:807: unused attribute 'Db_Flag' (60% confidence) - build/build.py:1048: unused attribute 'Db_Flag' (60% confidence) - build/build.py:2500: unused method 'GetRealPathOfTool' (60% confidence) - build/BuildReport.py:1497: unused method 'StrtoHex' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: AutoGen: Remove unnecessary codePierre Gondois8-126/+0
Running the vulture tool on the AutoGen folder gave the following report. Remove the unnecessary code. - AutoGen/BuildEngine.py:333: unused attribute 'SupportedToolChainFamilyList' (60% confidence) - AutoGen/BuildEngine.py:346: unused attribute '_RuleObjectList' (60% confidence) - AutoGen/GenMake.py:450: unused attribute 'FileBuildTargetList' (60% confidence) - AutoGen/GenMake.py:452: unused attribute 'PendingBuildTargetList' (60% confidence) - AutoGen/GenMake.py:458: unused attribute 'LibraryBuildCommandList' (60% confidence) - AutoGen/GenMake.py:459: unused attribute 'LibraryFileList' (60% confidence) - AutoGen/GenMake.py:462: unused attribute 'SystemLibraryList' (60% confidence) - AutoGen/GenMake.py:1168: unused method 'GetFileDependency' (60% confidence) - AutoGen/GenMake.py:1466: unused attribute 'ModuleBuildCommandList' (60% confidence) - AutoGen/GenPcdDb.py:442: unused class 'DbSkuHeadTableItemList' (60% confidence) - AutoGen/GenVar.py:31: unused attribute 'VpdRegionOffset' (60% confidence) - AutoGen/GenVar.py:43: unused attribute 'VpdRegionOffset' (60% confidence) - AutoGen/ModuleAutoGen.py:257: unused attribute 'FileDependCache' (60% confidence) - AutoGen/ModuleAutoGen.py:684: unused method 'BuildOptionIncPathList' (60% confidence) - AutoGen/PlatformAutoGen.py:994: unused method 'EdkBuildOption' (60% confidence) - AutoGen/UniClassObject.py:171: unused attribute 'StringNameByteList' (60% confidence) - AutoGen/UniClassObject.py:181: unused attribute 'StringNameByteList' (60% confidence) - AutoGen/UniClassObject.py:366: unused method 'GetIncludeFile' (60% confidence) - AutoGen/UniClassObject.py:606: unused method 'FindStringValue' (60% confidence) - AutoGen/UniClassObject.py:616: unused method 'FindByToken' (60% confidence) - AutoGen/ValidCheckingInfoObject.py:228: unused attribute 'ValidData' (60% confidence) - AutoGen/ValidCheckingInfoObject.py:231: unused attribute 'ValidData' (60% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: Remove unreachable codePierre Gondois4-37/+0
Running the vulture tool gave the following report. Remove the unreachable code. - TargetTool/TargetTool.py:49: unreachable code after 'raise' (100% confidence) - UPT/Library/UniClassObject.py:137: unreachable code after 'return' (100% confidence) - UPT/Object/Parser/InfDefineObject.py:795: unreachable code after 'if' (100% confidence) - Ecc/Check.py:1504: unreachable code after 'return' (100% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-07-01BaseTools: Remove unused importPierre Gondois12-12/+0
Running the vulture tool gave the following report. Remove the unused import. - BPDG/BPDG.py:21: unused import 'encodings' (90% confidence) - build/build.py:61: unused import 'Manager' (90% confidence) - Ecc/CParser4/CLexer.py:4: unused import 'TextIO' (90% confidence) - Ecc/CParser4/CParser.py:5: unused import 'TextIO' (90% confidence) - Eot/CParser4/CLexer.py:4: unused import 'TextIO' (90% confidence) - Eot/CParser4/CParser.py:5: unused import 'TextIO' (90% confidence) - Eot/EotMain.py:28: unused import 'ConvertGuid' (90% confidence) - GenFds/FdfParser.py:16: unused import 'hexdigits' (90% confidence) - Table/TableEotReport.py:16: unused import 'EotToolError' (90% confidence) - UPT/Library/CommentGenerating.py:19: unused import 'USAGE_ITEM_NOTIFY' (90% confidence) - UPT/Library/ParserValidate.py:18: unused import 'COMPONENT_TYPE_LIST' (90% confidence) - UPT/Library/UniClassObject.py:25: unused import 'CheckUTF16FileHeader' (90% confidence) Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2025-06-25BaseTools/PatchCheck.py: verify commit message lists package(s)Leif Lindholm1-0/+9
Verify that the subject line matches the basic {Package}[,Package]: format _or_ the Revert "<subject of commit to revert>" format. Non-package top-level directories are treated as packages. Suggested-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-06-25BaseTools/PatchCheck.py: pass list of packages to CommitMessageCheckLeif Lindholm1-4/+5
In order to enable subject line format compliance checking in following patches, pass through a list of modified packages to CommitMessageCheck. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-06-25BaseTools/PatchCheck.py: make get_parent_packages return directory namesLeif Lindholm1-1/+1
The get_parent_packages function in CheckGitCommits returns the path of non-package directories, but in fact returns the path of the .dec file for actual packages. Align the handling to be more consistent and return only directory names, regarding of how it was found. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-06-25BaseTools: Declare $(DEBUG_DIR)/<module>.efi outputJean-Philippe Brucker1-0/+1
$(DEBUG_DIR)/<M>.efi is generated by the recipe of $(OUTPUT_DIR)/<M>.efi: the .efi file is generated and then copied into $(DEBUG_DIR). At the moment the generate GNUmakefile does not declare the dependency between these two files, which can be a problem because $(FFS_OUTPUT_DIR)/<M>.offset depends on $(DEBUG_DIR)/<M>.efi. Normally $(DEBUG_DIR)/<M>.efi is generated first and there is no problem, but when an external tool builds edk2 from a Makefile, like OP-TEE build does for instance, the parallel '-j' flag passed to Make is inherited by the edk2 GNUmakefile from the environment. As a result Make might try to build the $(FFS_OUTPUT_DIR)/<M>.offset target in parallel and fail to find the .efi file: make[1]: *** No rule to make target 'Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/AARCH64/NetworkPkg/VlanConfigDxe/VlanConfigDxe/DEBUG/VlanConfigDxe.efi', needed by 'Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/FV/Ffs/E4F61863-FE2C-4b56-A8F4-08519BC439DFVlanConfigDxe/VlanConfigDxe.offset'. Stop. If we declare the $(DEBUG_DIR) file as output of this rule, then the generated GNUmakefile will contain the right dependency declaration: $(DEBUG_DIR)/VlanConfigDxe.efi: $(OUTPUT_DIR)/VlanConfigDxe.efi and the parallel build will succeed. Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
2025-06-24BaseTools/GetFw: Skip R_X86_64_NONE relocationsMichael D Kinney1-0/+12
Building .aslc files in a module for host-based unit testing in Linux/GCC X64 environments may introduce relocations for a symbol in a shared library from lcov or asan. Update logic to not generate an error message and exit if the symbol is unknown but the relocation type is R_X86_64_NONE. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-06-24BaseTools/HostBasedUnitTestRunner: lcov ignore mismatch errorsMichael D Kinney1-5/+5
Ignore mismatch errors for lcov 2.x in all locations that lcov is run. When building more complex unit tests, these mismatch errors are showing up in different phases of the code coverage collection. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-06-07BaseTools: Add support for mingw-w64Nate DeSimone17-192/+802
Adds support for building the C language BaseTools for Windows using toolchains based on mingw-w64. Mingw-w64 is a collection of header files, libraries, and tools that when combined with a compiler enable development of Windows software. Mingw-w64 is a fork of the original MinGW (Minimalist GNU for Windows). Most active development on MinGW has ceased and mingw-w64 is now the actively maintained successor. Mingw-w64 provides a libc implementation built on top of Microsoft's UCRT (Universal C Runtime) with all nessesary compiler bindings needed to support the C++11 feature set. Modern mingw-w64 development appears to have coalesced around MSYS2, which produces a distributions of both GCC and LLVM/Clang that use mingw-w64 to target the Windows OS. This MSYS2 Clang distribution has a UNIX-like directory layout and includes Windows binaries of GNU Make. Combined with the open source licensing, MSYS2's Clang distribution is a highly attractive choice as an alternative Windows SDK for open source projects such as TianoCore. If one wishes to use EDK II to build UEFI firmware on the Windows platform, then the C BaseTools need to be compiled as Windows applications. This includes the PcdValueInit.exe program, which needs to be recompiled every time a firmware build is run in order to regenerate the initial values for structured PCDs. Currently, BaseTools only supports the Visual C++ toolchain on the Windows platform. The following new features have been added to enable usage of the toolchains derived from mingw-w64: - Fixes to the BaseTools C source code to support the use of a GCC-style compiler on the Windows OS. - The GNU Make-style Makefiles for the C BaseTools have been modified to support Windows. Both GCC + mingw-w64 and Clang + mingw-w64 have been tested and confirmed to build a working BaseTools. - BaseTools now supports generating GNU Make-style Makefiles on the Windows platform for the purpose of building firmware. - edksetup.bat has been modified to optionally build BaseTools via mingw-w64. There is no impact to the existing support for Visual C++ and Visual C++ remains the default toolchain. Usage Instructions: For the vast majority of users, the only system setup change nessesary to use a mingw-w64 toolchain is to set the BASETOOLS_MINGW_PATH to the directory containing the desired mingw-w64 based toolchain. A new command line argument has been added to edksetup.bat: Mingw-w64 If this command line argument is set, then the script will set the BASETOOLS_MINGW_BUILD environment variable. The user can also opt to set this environment variable manually before running edksetup.bat If BASETOOLS_MINGW_BUILD is defined, then the BASETOOLS_MINGW_PATH environment variable must point to the directory containing the mingw-w64 toolchain. If CLANG_BIN is not defined and %BASETOOLS_MINGW_PATH%\bin\clang.exe exists, then edksetup.bat will set CLANG_BIN=%BASETOOLS_MINGW_PATH%\bin\ This removes the requirement to configure the CLANG_BIN environment variable manually in order to run a CLANGPDB or CLANGDWARF build if one has the MSYS2 Clang distribution installed. If one wishes to use a different copy of Clang (for example official LLVM binaries) to build firmware and only use the MSYS2 Clang to build BaseTools, then one can continue to set the CLANG_BIN environment variable, same as before. I have tested the MSYS2 Clang distribution against the official LLVM distribution and can confirm that if the compiler version is the same the emitted machine code is identical between the two. Interestingly, the MSYS2 Clang distribution emits the path to the PDB file using "/" as the path seperator instead of "\". That appears to be the only difference in output. Therefore, using the MSYS2 Clang distribution to compile firmware seems a reasonable choice. If CLANG_HOST_BIN is not defined and BASETOOLS_MINGW_BUILD is defined and %BASETOOLS_MINGW_PATH%\bin\mingw32-make.exe exists, then edksetup.bat will add %BASETOOLS_MINGW_PATH%\bin\ to the PATH and set CLANG_HOST_BIN=mingw32- This enable usage of the GNU Make included in the mingw-w64 toolchain to build firmware in addition to BaseTools. if BASETOOLS_MINGW_BUILD is not defined, edksetup.bat will continue to set CLANG_HOST_BIN=n, which uses nmake to build firmware. This behavior can be overridden by manually setting the value of CLANG_HOST_BIN before executing edksetup.bat if one wishes to use a specific Make utility for the CLANGPDB/CLANGDWARF toolchains. References: - https://www.mingw-w64.org/ - https://www.msys2.org/ Co-authored-by: Sandesh Jain <sandesh.jain@intel.com> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
2025-06-07BaseTools: Add Unit Test Support for X64 BaseTools on WindowsNate DeSimone1-2/+2
Fixes a BaseTools Bin directory path detection bug in the the BaseTools Unit Tests. The script incorrectly assumes that sys.platform will be win64 on a 64-bit Python interperter. The "win64" platform string has not been used for 64-bit Python interperters since May 10, 2000: https://github.com/python/cpython/commit/da5cc82d Moreover, this patch was merged before the Python 2.0 release, so there never has been a released Python interperter that used the "win64" string. Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
2025-06-06BaseTools: Add line number to PatchCheck error messagesGary Beihl1-2/+2
PatchCheck error messages can be improved by adding the line number. The line itself may consist of only whitespace for some errors. Adding the line number can help better locate the error source. Signed-off-by: Gary Beihl <garybeihl@microsoft.com>
2025-05-28BaseTools: Add GUID section for build reportZhiguang Liu1-2/+7
Add GUID section for build report. Also, change the GUID format to string format to be easier to parse Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
2025-05-27BaseTools: Update CParser4 to import TextIO from typingRebecca Cran4-4/+4
In Python 3.13 typing.io no longer exists. Instead, import TextIO from typing. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2025-05-26BaseTools: Fix type annotations Roman A2-4/+4
Fixed type annotations for functions: - `def _parse_pattern(line: str) -> Tuple[str]:` -> `def _parse_pattern(line: str) -> Tuple[bool, str, str]:` - `def get_scopes(codeql_enabled: bool) -> Tuple[str]:` -> `def get_scopes(codeql_enabled: bool) -> Tuple[str, ...]:` Signed-off-by: Roman A <gameromandev@gmail.com>
2025-05-09BaseTools: Fix Macro Expansion on Machine Architecture for ComponentsNate DeSimone1-3/+4
BaseTools currently does not expand macros for component architecture when nested !include directives are used. This breaks use cases like [Component.$(DXE_ARCH)]. The fix is to add explicit macro expansion when computing the Arch value for component lines in DscParser. Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
2025-05-03BaseTools: Change arm align value from 32 to 64Vivian Nowka-Keane1-2/+2
Alignment needed to be updated to 64 because of a linker warning when building with MSVC. /ALIGN:64 is the minimum alignment for MSVC ARM64, which differs from MSVC x64. This was missed when checking into edk2 because CI isn't run for MSVC ARM64. Signed-off-by: Vivian Nowka-Keane <vnowkakeane@linux.microsoft.com>
2025-05-03BaseTools: Update tools_def for aarch64Vivian Nowka-Keane1-3/+3
/WX was added as a build flag in VS2022 and now aarch64 builds fail because of an undocumented linker warning: 4226 Alignment specified exceeds target machine page size. This linker warning has always occured and can be ignored. Signed-off-by: Vivian Nowka-Keane <vnowkakeane@linux.microsoft.com>
2025-04-29BaseTools: Scripts: efi_debugging.py: search for EFI_SYSTEM_TABLE_POINTERYing-Chun Liu (PaulLiu)1-2/+34
Add code to search for gST via EFI_SYSTEM_TABLE_POINTER. Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-04-29BaseTools/Conf: Enable GCC preprocessor line-markers for VFRNate DeSimone1-2/+2
This change enables the emission of C preprocessor line-markers for VFR intermediate files on the GCC and Clang compilers. Since the VfrCompiler now supports GCC-style preprocessor line markers, they can be enabled by default. Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>