summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
AgeCommit message (Collapse)AuthorFilesLines
28 hoursBaseTools: 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>
5 daysBaseTools: Fix the spelling or typoAbdul Lateef Attar1-1/+2
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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>
8 daysBaseTools: 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-07BaseTools: Add support for mingw-w64Nate DeSimone1-11/+39
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-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-26BaseTools: 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-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-04-14BaseTools:Expression.py Adding a check for missing '}' in the parserpg/proximity_domain_reworkDoug Flick1-1/+1
This check is to catch cases where a missing '}' exists in a dec or dsc file. Signed-off-by: Doug Flick <dougflick@microsoft.com>
2025-04-14BaseTools:Expression.py Add Assertion for PCD with value {}Doug Flick1-0/+2
This adds an assertion to the PCD class in the Expression.py file to check for zero-byte PCDs. Signed-off-by: Doug Flick <dougflick@microsoft.com>
2025-04-14BaseTools:Expression.py Size used before InitDoug Flick1-1/+1
The following example fails to be parsed correctly due to Size being used in the outer scope but initialized in the inner scope ``` gPlatformPkgTokenSpaceGuid.PcdSecureBootDbxBinaryFile|{} ``` Problematic code: ```python for Item in NewPcdValueList: Size = 0 # .... if Size > 0: PcdValue = '{' + ', '.join(AllPcdValueList) + '}' ```` Signed-off-by: Doug Flick <dougflick@microsoft.com>
2025-04-11BaseTools: Fix FMMT Compress wrong behaviorYuwei Chen1-1/+1
When using the replace function, if the replaced file located in a compress section, then the tool will re-build the section. As the compress status set in the wrong place, in some situation, the compress will do twice times which is a wrong behavior. This patch is used to fix this issue. Cc: Rebecca Cran <rebecca@bsdio.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Bob Feng <bob.c.feng@intel.com> Cc: Ashraf Ali S <ashraf.ali.s@intel.com> Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
2025-04-08BaseTools: Dump library dependency chain on build failureRay Ni1-2/+14
When a module M depends on L1, which depends on L2, which depends on L3, the build fails when the library instance of L3 cannot be found according to the library class-instance mapping configuration specified in the DSC file. When such failure happens, the build tool only prints that the instance of L3 required by module M cannot be found. But it does not tell how L3 is required by M. The change enhances build tool to print the entire dependency chain when such failure happens. With the change, the new error message will be as follows: <dsc-path>(...): error 4000: Instance of library class [L3] is not found for module [M], [L3] is: consumed by <instance of L2> consumed by <instance of L1> Signed-off-by: Ray Ni <ray.ni@intel.com>
2025-03-31BaseTools/build: Reduce special FV full to warningMichael D Kinney1-3/+12
If an FV_SPARE_SPACE_THRESHOLD is enabled and an FV is 100% full with 0 bytes free, then this is likely a special FV that may have alignment requirements for the FFS file for both the start address and the length and the FFS file consumes all the available FV space. Reduce FV_SPARE_SPACE_THRESHOLD from an error to a warning if this FV 0 bytes free condition is detected. PR #10828 introduced the generation of these error conditions for an FV with large alignment requirements. The pad region before the aligned FFS file used to be counted as free space even though it could never be used due to the alignment requirements. There was actually no free space available. PR #10828 fixed the free space calculation to properly show it as 0 bytes free, and this change then caused build error when FV_SPARE_SPACE_THRESHOLD feature was enabled. The reduction to a warning for this condition allows the build to complete with errors and also provides a build log warning message for review. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-03-26BaseTools/FMMT: Fix GUID Tool Not Found the Shell Script IssueJason1 Lin1-3/+3
- FMMT tool would use the "PATH" environment variable for locating the required GUID tool. - On Windows-like system, batch file not found in the "PATH" environment variable when "shell=False". - This issue required commands to include program extensions or absolute paths. - This patch sets "shell=True" to extend the support for batch files, including scripts in BinWrappers under BaseTools. - Converted input commands from lists to strings to ensure proper argument interpretation in POSIX-like shell scripts. Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
2025-03-25BaseTools: Fix missing module PCD in compile information of build reportZhiguang Liu1-1/+1
Module PCD in compile information is missed in module_report.json Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
2025-02-04BaseTools: Add @verbatim as allowed Doxygen tagRebecca Cran2-2/+2
Per the discussion in https://github.com/tianocore/edk2/pull/6476, update Ecc code to allow the @verbatim Doxygen tag. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2025-02-02BaseTools/AutoGen: GenMake response file quotes stringsMichael D Kinney1-3/+14
If command line options are moved into a response file of a GCC family build, then the file path separators are converted from '\' to '/'. However, this can corrupt command line options that are quoted strings. Update GenMake to no convert '\' to '/' in quoted strings. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-01-27BaseTools: Fix NoneType parent reference in FMMT operationsAshraf Ali S1-3/+12
This patch addresses an issue in the FMMT operations where the parent reference is not checked for NoneType. This oversight can lead to an AttributeError: 'NoneType' object has no attribute 'Name' when attempting to access the parent reference. The fix involves adding a check for NoneType before accessing the parent reference to ensure that the operations handle such cases gracefully. The affected functions include: - AddNewFfs - ReplaceFfs - ExtractFfs These functions now include proper checks to prevent the AttributeError. Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
2025-01-09BaseTools: Clean up os.path.normcase and os.path.normpath usageYang Gang5-12/+12
Refer to the docs of python, `os.path.normcase(path)` function: "Normalize the case of a pathname. On Windows, convert all characters in the pathname to lowercase, and also convert forward slashes to backward slashes. On other operating systems, return the path unchanged." `os.path.normpath(path)` also convert forward slashes to backward slashes. So call `os.path.normcase` after `os.path.normpath` just convert path to lowercase on Windows(only). And Windows is case-insensitive but case-preserving. So the usage of `os.path.normcase(os.path.normpath(path))` can be simplified to `os.path.normpath(path)`. Then we can use case-preserving paths rather than lowercase paths in compile_commands.json file or build log. But this patch continue to use `os.path.normcase` when comparing/searching paths. Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2024-12-24Remove dependancy on re.TAshraf Ali1-1/+0
Signed-off-by: Ashraf Ali <ashraf.ali.s@intel.com>
2024-12-11BaseTools: Typo fixesDionna Glaze6-15/+13
Some in error messages, some in local variable names. Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
2024-12-06BaseTools: Improve error messages from UefiCapsuleHeader.pyRebecca Cran1-2/+2
Instead of throwing ValueErrors with no explanation, add a message explaining what went wrong. Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2024-09-23BaseTools: Fix multiple 'invalid escape sequence' warnings in testsMike Beaton18-72/+72
In Python 3.12 invalid escape sequences in strings moved from DeprecationWarning to SyntaxWarning (ref https://docs.python.org/3/whatsnew/changelog.html#python-3-12-0-final and search for gh-98401). In a future Python version this will become SyntaxError. Multiple instances of these SyntaxWarnings are currently printed when running the BaseTools tests using Python 3.12 (though without actually failing the affected tests). This commit updates all lines which were causing this type of warning. Typical examples which needed fixing are: - "BaseTools\Source\Python" representing a path: "\S" and "\P" are invalid escape sequences, therefore left unchanged, therefore the test works (with a warning in Python 3.12). r"BaseTools\Source\Python" represents the same string, but with escapes turned off completely thus no warning. - Where '\t\s' is used as a regex pattern, then chr(9) + '\\s' is sent to the regex parser (with a warning in Python 3.12) since '\s' is not a valid Python escape sequence. This works correctly, though arguably for the wrong reasons. r'\t\s' sends the same as '\\t\\s', as originally intended and with no warning. (Note that ' and " are not fundamentally different in Python.) Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2024-09-13BaseTools: Update Stack Cookie LogicTaylor Beebe3-1/+54
This patch updates the GenC logic to generate a random stack cookie value for the stack check libraries. These random values improve security for modules which cannot update the global intrinsics. If the stack cookie value is randomized in the AutoGen.h file each build, the build system will determine the module/library must be rebuilt causing effectively a clean build every time. This also makes binary reproducibility impossible. This patch updates the early build scripts to create 32 and 64-bit JSON files in the build output directory which each contain 100 randomized stack cookie values for each bitwidth. If the JSON files are already present, then they are not recreated which allows them to be stored and moved to other builds for binary reproducibility. Because they are in the build directory, a clean build will cause the values to be regenerated. The logic which creates AutoGen.h will read these JSON files and use a hash of the module GUID (the hash seed is fixed in Basetools) to index into the array of stack cookie values for the module bitwidth. This model is necessary because there isn't thread-consistent data so we cannot use a locking mechanism to ensure only one thread is writing to the stack cookie files at a time. With this model, the build threads only need to read from the files. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-10BaseTools: Remove Pip BaseToolsOliver Smith-Denny1-29/+0
BaseTools was moved out to a separate repo and consumed as a pip module by edk2 CI. This process has not led to the desired goals of doing so, so this patch removes the pip based BaseTools from edk2 CI. The original goal of moving BaseTools to a pip module was primarily to speed up the development process, as the old edk2 mailing list was slow. However, with edk2 moving to PRs, it now actually slows the BaseTools development process to have to do a PR in another repo, publish the module, and then make a PR in edk2 to consume the new BaseTools. It also holds up using the features in a new BaseTools in other PRs. There were other goals of moving, such as allowing projects to use the BaseTools outside of edk2. This can still be accomplished outside of this PR, this PR simply stops edk2 CI from using the pip module. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-02BaseTools: GenMake: FIx missing logs from GenMake.pyKen Lautner1-0/+1
EdkLogger logs were not showing up as part of the build log output. Adding the EdkLogger import to GenMake.py fixes the missing log prints. Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
2024-08-31BaseTools: Trim: Add header/footer for ASL includeJoey Vagedes1-5/+28
When including one ASL file in another, add a header / footer to the included file to easily tell where the included file starts and ends. Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
2024-08-05BaseTools/Capsule: Support Different Hash Algorithm for Payload DigestJason1 Lin1-14/+103
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4821 - The capsule payload digest got hardcoded inside the GenerateCapsule script as "sha256". - It would be hard for the caller to change the supported hash algorithm which supported on OpenSSL or Windows signtool program and platform. - Capsule payload digest signed data is followed by the PKCS#7 standard, in EDK-II CryptoPkg "Pkcs7Verify ()" is supported to validate with several hash algorithms naturally. (md5, sha1, sha256, sha384, and sha512) - Deliver below changes within this patch, (1) Introduce an optional argument "--hash-algorithm" to assign the caller expected one and leave the default value "sha256" to support the backward compatibility. (2) Add the double quotes to put the string of certificate's subject name inside it. (3) Set "Open" argument of "SignToolSubjectName" into "False". (4) Set "Convert" argument of "SignToolSubjectName: into "str". (5) Correct the actual name of the "--subject-name" flag. (6) Add back correct number of arguments for PayloadDescriptor class object initializing. Note: - Platform needs to support the correspond hash algorithm to validate the digital signature or the failure would be observed. - Set the md5 and sha1 algorithm as EOL based on the CryptoPkg supported table and reject the capsule creation. Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
2024-07-15BaseTools: drop GeneralCheckNonAscii() from ECCLeif Lindholm4-27/+0
The GeneralCheckNonAscii() function is a sledgehammer rejecting any file containing any character outside of the 7-bit ASCII encoding space, as well as the DEL character (which seems unrelated). This conflicts with basic stuff like correctly spelling certain proper nouns in comments (like copyright statements), or string literals (for example in multi-language driver binding ComponentNames). So rip it out, to be replaced by more fine-grained checks to be added as identified and needed. Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
2024-07-15BaseTools: fix consistent Ecc misspelling of ASCIILeif Lindholm4-13/+13
Ecc concistently referred to ASCII/Ascii as ACSII/Acsii, which bugged me to no end when trying to figure out how those tests worked. Fix all instances. Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
2024-07-10BaseTools/Ecc: Allow `static` as a modifierMichael Kubacki1-1/+1
Currently, `STATIC` is allowed as a function modifier but `static` results in the below ECC errors: ``` *Error code: 5001 *Return type of a function should exist and in the first line *file: D:\src\edk2\Build\.pytool\Plugin\EccCheck\MdePkg\Library\UefiDebugLibDebugPortProtocol\DebugLibConstructor.c *Line number: 37 *[UefiDebugLibDebugPortProtocolExitBootServicesCallback] Return Type should appear at the start of line EFI coding style error *Error code: 5002 *Any optional functional modifiers should exist and next to the return type *file: D:\src\edk2\Build\.pytool\Plugin\EccCheck\MdePkg\Library\UefiDebugLibDebugPortProtocol\DebugLibConstructor.c *Line number: 37 ``` This is because `GetDataTypeFromModifier()` will return both `static` and the return type (e.g. `VOID`) whereas for a modifier in the list (e.g. `STATIC`) it will return only the return type allowing logic in Ecc/c.py to process the modifier and return type with current logic. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-07-05BaseTools/GenerateCapsule.py: Fix checking for DepExp presenceSergii Dmytruk1-2/+2
struct.unpack() returns a tuple even for a single-element pack, resulting in signature verification being evaluated to false even when the signature is there. This fixes --decode and --dump-info actions incorrectly reporting issues with parsing capsule dependencies when there are none. Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-07-05BaseTools/GenerateCapsule.py: Fix inconsistent error formattingSergii Dmytruk1-2/+2
Just add a space between colon and a more detailed error message in two places. Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-07-05BaseTools/GenerateCapsule.py: Require --output for --decodeSergii Dmytruk1-0/+4
--decode unconditionally uses args.OutputFile.name as a prefix for output files that it creates and fails in a non-pretty way without --output option. This doesn't address creation/truncation of the file specified via --output, but at least you're able to decode a capsule. Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-07-05BaseTools/GenerateCapsule.py: Better error message on --decode failureSergii Dmytruk1-2/+2
Print error text from the exception. Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-07-05BaseTools/GenerateCapsule.py: Disallow UpdateImageIndex == 0 on --encodeSergii Dmytruk1-3/+3
This field seems to be one-based according UEFI specification, default value is 1 and --decode of GenerateCapsule.py errors upon seeing UpdateImageIndex less than 1. So align --encode behaviour to enforce a value within the 1..255 range. Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>