summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
AgeCommit message (Collapse)AuthorFilesLines
2026-02-11Revert "BaseTools: Add support for out-of-tree builds"HEADmasterMichael D Kinney1-2/+1
This reverts commit 3fe1d56cc98e011bbde8348f13dfa5e38c95f49e. PR https://github.com/tianocore/edk2/pull/11757 introduced a "Breaking Change" feature for out of tree builds of tools. This breaking change is blocking testing of edk2-stable202602 due to side effects on building FitGen tool in edk2-platforms. Revert this feature for the edk2-stable202602 release and work on this feature after the release. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-02-02BaseTools: Add support for out-of-tree buildsOleksandr Tymoshenko1-1/+2
Main EDK2 build supports out-of-tree builds but BaseTools make process still creates tools and object files in-tree. In order to make out-of-tree build support complete move the generated tools and interim obj files to $WORKSPACE location as well. This patch also changes the location of BaseTools for in-tree builds (default behavior when WORKSPACE is not provided before calling edksetup) to $WORKSPACE/BaseTools/Build/... It may potentially break external workflows that invoke tools from the default location outside of the build tool. Signed-off-by: Oleksandr Tymoshenko <ovt@google.com>
2026-01-30BaseTools: Prevent Subsection PCDs from polluting global expressionsPaddyDeng1-2/+3
The PCD value defined in module subsections can be added to global PCD database. Therefore the unsolved expressions, even belongs to the global scope, can incorrectly refer to the value from module subsection. This only happens when the referred PCD has no value assignment in the platform dsc file. Which also should raise an error. Signed-off-by: Paddy Deng <paddydeng@ami.com>
2026-01-06BaseTools/build: Add defines for Windows build environmentsMichael D Kinney1-0/+5
The stuart tools automatically add -D WIN_HOST_BUILD to edk2 build command line if a Windows build environment is detected. This behavior is added to build.py so that builds of the EmulatorPkg using build.py are not required to add the option -D WIN_HOST_BUILD when building in a Windows environment. This aligns Linux and Windows builds of the EmulatorPkg removing the need to specify extra defines. In order to build the EmulatorPkg for Windows Mingw environments, EmulatorPkg DSC/FDF files require a way to detect if Windows Mingw environment is present. The Windows Mingw environment can be detected if CLANG_BIN is set and mingw32-make.exe is detected in the CLANG_BIN directory. If a Windows Mingw environment is detected, add -D WIN_MINGW32_BUILD to the edk2 build command line. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-12-24BaseTools: GNUMakefiles must use CMD.EXE in WindowsMichael D Kinney1-1/+9
Use $(OS) in all GNUMakefiles to detect if the GNUMakefile is being used in a Windows OS. If a Windows OS is detected, then override SHELL to use cmd.exe. This prevents make utility from using sh.exe if sh.exe happens to be in PATH. If sh.exe is used, then backslash (\) characters in file paths are removed and builds break for files not found. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-12-03BaseTools: Cap AutoGen thread count to avoid file descriptor exhaustionAyden Meng1-1/+10
When the number of build threads multiplied by per-thread file descriptor usage exceeds the system's open file descriptor limit, some threads may fail to acquire necessary resources (e.g., pipes or semaphores), leading to deadlocks or hangs during parallel builds. To prevent this situation, calculate the safety upper limit of concurrency by dividing the system's maximum file descriptor limit by 3 (An empirical value derived from balancing performance overhead against the theoretical number of file descriptors consumed per thread). The actual thread count is then clamped to this safe value. Other usages of ThreadNum()—such as during actual compilation or log queue creation—do not significantly contribute to file descriptor consumption. Therefore, adjusting ThreadNum() globally would be unwarranted, as it could unnecessarily restrict parallelism in stages that are not FD-bound. This ensures stable parallel builds even under constrained resource limits. Signed-off-by: Ayden Meng <mengxiangdong@loongson.cn>
2025-12-03BaseTools: Handle file descriptor exhaustion during parallel buildAyden Meng1-0/+7
Previously, when file descriptors were exhausted in high-concurrency builds (e.g., 512 threads with 1024 FD limit), the build would hang or fail silently without clear indication of the root cause. This change catches relevant OSError instances and terminates the build, ensuring failures due to resource limits are explicit. Signed-off-by: Ayden Meng <mengxiangdong@loongson.cn>
2025-12-02BaseTools: AutoGen: Optimize tuple creation using tuple() for PcdDbBufferJeremy Compostella1-6/+2
Replace manual loop-based tuple construction with the built-in tuple() function when converting PcdDbBuffer to a tuple. This change significantly improves performance—approximately three times faster—resulting in substantial build time savings in large environments. Previously, the code iterated over each byte in PcdDbBuffer, unpacking and appending it to a tuple. The new approach leverages tuple(PcdDbBuffer) to achieve the same result more efficiently. The generated tuple remains identical to the original implementation. TEST=The generated tuple is the same than with to original code Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2025-11-23BaseTools: Enhance FMMT rebase feature with FFS type checkYuwei Chen2-12/+193
1.Add FFS file type check: Only allow rebase operation for EFI_FV_FILETYPE_SECURITY_CORE, EFI_FV_FILETYPE_PEI_CORE, EFI_FV_FILETYPE_DXE_CORE, EFI_FV_FILETYPE_PEIM, EFI_FV_FILETYPE_DRIVER, EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER,EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE types, improving safety and compliance. 2.Automatically detect and complete the PE/COFF or TE image relocation table (reloc section) to ensure integrity and compatibility of the rebase operation. 3.After rebase, automatically update FFS checksum and FV header information to ensure correct data structure. 4.Support recursive processing for nested FVs, ensuring all related FFS files' PE/TE images are properly rebased and reloc tables are completed. 5.Use table-driven architecture for relocation types, making it easier to extend to more platforms. 6.Improve error handling and logging for better robustness and maintainability. Please attention, only IA32 and X64 PE/COFF image are supported now. For other Arch, will support it after testing. Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
2025-11-23BaseTools: Enable FMMT Rebase functionYuwei Chen10-26/+1400
This patch adds and improves the rebase functionality for firmware images (PE/COFF/TE) in the FMMT tool. Key features include: 1.Automatically rebases PE/COFF/TE images within FFS files when the firmware volume (FV) layout is adjusted or FFS files are moved, ensuring correct loading and execution at new addresses. 2.Implements recursive rebase logic for nested sections, guaranteeing all relevant images are properly relocated. 3.Adds support for rebasing subsequent FFS files within the same FV, enhancing compatibility and stability during firmware layout changes. 4.Core code changes are mainly in FvHandler.py, BiosTreeNode.py, and BinaryFactoryProduct.py, covering rebase flag detection, address calculation, and actual relocation operations. 5.This feature improves the flexibility of firmware space management and enhances the automation and reliability of the FMMT tool. Co-Auther: Ashraf Ali S <ashraf.ali.s@intel.com> Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
2025-11-22BaseTools: FMMT: Fix incorrect size calculation in ModifyTest()Evgenii Shatokhin1-3/+4
There is another issue in FvHander.py similar to the one fixed by a60334ad59eb ("BaseTools: Fix FMMT FvHandler Padding operation issue"). For a guided section (ParTree.Data.Type == 0x02), the length of ParTree.Data.OriData is used to obtain the original size of the data even after ParTree.Data.OriData has changed, which is incorrect. This caused the following issue I observed. I built OVMF image for Aarch64 and then tried to add a couple FFS modules to it with 'FMMT -a [...]'. The resulting image turned out to be invalid: the total size of the image was less than the size of the firmware volume within it. UEFITool failed to load such firmware image and complained: "parseRawArea: one of objects inside overlaps the end of data". This patch fixes the issue. Signed-off-by: Evgenii Shatokhin <euspectre@gmail.com>
2025-11-21BaseTools: fix various typosPhilipp Schuster2-3/+3
This commit is the first in a series of multiple commits to fix various typos in the code, originating mostly from copy&paste over the years. Most of them only affect documentation and not code. Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
2025-10-30BaseTools: Remove DXE_SAL_DRIVERSathya Ravichandran12-27/+15
The DXE_SAL_DRIVER module type was introduced to support Itanium (IPF) platforms. Since support for Itanium processors has been dropped, the instances of DXE_SAL_DRIVER have been removed. Ref: [3cb0a311cb7e747d7be5c5076d0fff76ad256d2b] Cc: Sachin Ganesh <sachinganesh@ami.com> Signed-off-by: Sathya Ravichandran <sathyar@ami.com>
2025-10-21BaseTools:Remove deprecated ast.Str import for Python 3.14 compatibilityAshraf Ali S1-1/+0
- Str is not being used in FvHeader.py - Removed import of ast.Str as it was removed in Python 3.14. - Ensures compatibility with Python 3.14 and later. - https://docs.python.org/3/whatsnew/3.14.html#id9 This addresses ImportError caused by removal of deprecated AST classes including ast.Str. Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
2025-10-16BaseTools/FMMT: Fix errors when operating the FV with CRC32 sectionPhil Noh1-6/+1
Currently the FMMT tool supports CRC32 GUID section (Ref. GuidTools.py). But it is found that there are errors for the FV with CRC32 section. For example, the errors are checked on the following commands. --v : Show FV information except for the FV --a : Show "Target Fv not found!!!" when adding an FFS file to the FV --d : Show "Target Ffs not found!!!" when deleting an FFS file in the FV They are caused by the mismatch for CRC32 section data between the FMMT and GenCrc32 tools. The FMMT tool returns CRC32 section data without CRC checksum field (4 bytes). The GenCrc32 tool (with -d option, verify CRC32 value for the input file) requires CRC32 section data including CRC checksum field (4 bytes). Fix the issue through adjusting the section data to include CRC checksum field. Currently DataOffset field for CRC32 GUID section is reported as 0x1C differently (GUID Section header length: 0x18 + Checksum field: 0x4). Instead of DataOffset field that includes CRC checksum field, configure the section data based on the offset from section header length (0x18) that was previously calculated. This update enables GUID sections to use the same offset consistently. Signed-off-by: Phil Noh <Phil.Noh@amd.com>
2025-10-16BaseTools/build.py: set BUILD_TIME_EPOCH if not already in environmentLeif Lindholm1-1/+22
Set BUILD_TIME_EPOCH to the current UTC timestamp if not already present in the environment. Use the resulting value to print the "Build start time:" message. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-10-16BaseTools/build.py: language cleanup around CheckEnvVariableLeif Lindholm1-3/+3
The function CheckEnvVariable in fact checks several environment variables. And the comment at its invocation enumerates a specific set of variables, which defeats half the point of abstracting it out into a helper function. Rename the function to the plural form and turn the comment into a list of examples. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-09-25BaseTools: Remove ARM32 SupportOliver Smith-Denny9-53/+15
edk2 is dropping support for the ARM32 architecture. This commit removes ARM32 code from BaseTools. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-08-25BaseTools: 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-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-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-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-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>