[edk2] [Patch] BaseTools: Enable component override functionality
https://bugzilla.tianocore.org/show_bug.cgi?id=1449 This patch enable build tools to recognize that when two given files have the same GUID, file path and ARCH in Dsc, The later one's definition will be used. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Carsey Jaben --- .../Source/Python/Workspace/DscBuildData.py | 24 --- .../Source/Python/Workspace/MetaFileParser.py | 5 .../Source/Python/Workspace/MetaFileTable.py | 7 -- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 7e82e8e934..f9805f58f5 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -704,36 +704,44 @@ class DscBuildData(PlatformBuildClassObject): if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores: self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0, TAB_DEFAULT_STORES_DEFAULT) GlobalData.gDefaultStores = sorted(self.DefaultStores.keys()) return self.DefaultStores +def OverrideDuplicateModule(self): +RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] +Macros = self._Macros +Macros["EDK_SOURCE"] = GlobalData.gEcpSource +Components = {} +for Record in RecordList: +ModuleId = Record[6] +file_guid = self._RawData[MODEL_META_DATA_HEADER, self._Arch, None, ModuleId] +file_guid_str = file_guid[0][2] if file_guid else "NULL" +ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch) +if self._Arch != TAB_ARCH_COMMON and (file_guid_str,str(ModuleFile)) in Components: + self._RawData.DisableOverrideComponent(Components[(file_guid_str,str(ModuleFile))]) +Components[(file_guid_str,str(ModuleFile))] = ModuleId +self._RawData._PostProcessed = False ## Retrieve [Components] section information @property def Modules(self): if self._Modules is not None: return self._Modules - +self.OverrideDuplicateModule() self._Modules = OrderedDict() RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] Macros = self._Macros Macros["EDK_SOURCE"] = GlobalData.gEcpSource for Record in RecordList: -DuplicatedFile = False - ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch) ModuleId = Record[6] LineNo = Record[7] # check the file validation ErrorCode, ErrorInfo = ModuleFile.Validate('.inf') if ErrorCode != 0: EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo, ExtraData=ErrorInfo) -# Check duplication -# If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected -if self._Arch != TAB_ARCH_COMMON and ModuleFile in self._Modules: -DuplicatedFile = True Module = ModuleBuildClassObject() Module.MetaFile = ModuleFile # get module private library instance @@ -792,12 +800,10 @@ class DscBuildData(PlatformBuildClassObject): else: OptionString = Module.BuildOptions[ToolChainFamily, ToolChain] Module.BuildOptions[ToolChainFamily, ToolChain] = OptionString + " " + Option RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, None, ModuleId] -if DuplicatedFile and not RecordList: -EdkLogger.error('build', FILE_DUPLICATED, File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo) if RecordList: if len(RecordList) != 1: EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_GUID can be listed in section.', File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo) ModuleFile = ProcessDuplicatedInf(ModuleFile, RecordList[0][2], GlobalData.gWorkspace) diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 032220813b..a52e9229df 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1711,10 +1711,15 @@ class DscParser(MetaFileParser): def __ProcessBuildOption(self): self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=False) for Value in self._ValueList] +def DisableOverrideComponent(self,module_id): +for ori_id in self._IdMapping: +if self._IdMapping[ori_id] == module_id: +s
[edk2] [Patch 3/3 V2] BaseTools: Remove unused ECP related code from C tools
From: "Feng, Bob C" https://bugzilla.tianocore.org/show_bug.cgi?id=1350 Remove ECP support from BaseTools C code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/C/Include/IndustryStandard/pci22.h | 1 - 1 file changed, 1 deletion(-) diff --git a/BaseTools/Source/C/Include/IndustryStandard/pci22.h b/BaseTools/Source/C/Include/IndustryStandard/pci22.h index d7c5f0c858..873ce69094 100644 --- a/BaseTools/Source/C/Include/IndustryStandard/pci22.h +++ b/BaseTools/Source/C/Include/IndustryStandard/pci22.h @@ -178,11 +178,10 @@ typedef struct { #define PCI_IF_16850 0x05 #define PCI_IF_16950 0x06 #define PCI_SUBCLASS_PARALLEL 0x01 #define PCI_IF_PARALLEL_PORT 0x00 #define PCI_IF_BI_DIR_PARALLEL_PORT 0x01 -#define PCI_IF_ECP_PARALLEL_PORT 0x02 #define PCI_IF_1284_CONTROLLER0x03 #define PCI_IF_1284_DEVICE0xFE #define PCI_SUBCLASS_MULTIPORT_SERIAL 0x02 #define PCI_SUBCLASS_MODEM0x03 #define PCI_IF_GENERIC_MODEM 0x00 -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch 3/3 V2] BaseTools: Remove unused logic from C tools
From: "Feng, Bob C" https://bugzilla.tianocore.org/show_bug.cgi?id=1350 Remove IA64 support from BaseTools C code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/C/Common/BasePeCoff.c| 14 +- BaseTools/Source/C/Common/PeCoffLoaderEx.c| 162 +- BaseTools/Source/C/EfiRom/EfiRom.h| 3 +- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 72 +--- BaseTools/Source/C/GenFv/GenFvInternalLib.h | 10 -- BaseTools/Source/C/GenFw/Elf64Convert.c | 5 - BaseTools/Source/C/GenFw/GenFw.c | 6 +- BaseTools/Source/C/GenFw/elf_common.h | 85 - .../C/Include/IndustryStandard/PeImage.h | 3 - BaseTools/Source/C/Makefiles/header.makefile | 1 - BaseTools/Source/C/VolInfo/VolInfo.c | 2 +- 11 files changed, 10 insertions(+), 353 deletions(-) diff --git a/BaseTools/Source/C/Common/BasePeCoff.c b/BaseTools/Source/C/Common/BasePeCoff.c index 1d89a300de..d5cefbd0b0 100644 --- a/BaseTools/Source/C/Common/BasePeCoff.c +++ b/BaseTools/Source/C/Common/BasePeCoff.c @@ -54,17 +54,10 @@ PeCoffLoaderRelocateIa32Image ( IN OUT CHAR8 *Fixup, IN OUT CHAR8 **FixupData, IN UINT64 Adjust ); -RETURN_STATUS -PeCoffLoaderRelocateIpfImage ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ); RETURN_STATUS PeCoffLoaderRelocateArmImage ( IN UINT16 **Reloc, IN OUT CHAR8 *Fixup, @@ -182,11 +175,10 @@ Returns: } else { ImageContext->Machine = TeHdr->Machine; } if (ImageContext->Machine != EFI_IMAGE_MACHINE_IA32 && \ - ImageContext->Machine != EFI_IMAGE_MACHINE_IA64 && \ ImageContext->Machine != EFI_IMAGE_MACHINE_X64 && \ ImageContext->Machine != EFI_IMAGE_MACHINE_ARMT && \ ImageContext->Machine != EFI_IMAGE_MACHINE_EBC && \ ImageContext->Machine != EFI_IMAGE_MACHINE_AARCH64) { if (ImageContext->Machine == IMAGE_FILE_MACHINE_ARM) { @@ -814,13 +806,10 @@ Returns: Status = PeCoffLoaderRelocateIa32Image (Reloc, Fixup, &FixupData, Adjust); break; case EFI_IMAGE_MACHINE_ARMT: Status = PeCoffLoaderRelocateArmImage (&Reloc, Fixup, &FixupData, Adjust); break; -case EFI_IMAGE_MACHINE_IA64: - Status = PeCoffLoaderRelocateIpfImage (Reloc, Fixup, &FixupData, Adjust); - break; default: Status = RETURN_UNSUPPORTED; break; } if (RETURN_ERROR (Status)) { @@ -1317,13 +1306,12 @@ PeCoffLoaderGetPdbPointer ( // Assume PE32 image with IA32 Machine field. // Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; break; case EFI_IMAGE_MACHINE_X64: -case EFI_IMAGE_MACHINE_IPF: // - // Assume PE32+ image with X64 or IPF Machine field + // Assume PE32+ image with X64 Machine field // Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; break; default: // diff --git a/BaseTools/Source/C/Common/PeCoffLoaderEx.c b/BaseTools/Source/C/Common/PeCoffLoaderEx.c index 2d9a2a8978..fa8c7e3d17 100644 --- a/BaseTools/Source/C/Common/PeCoffLoaderEx.c +++ b/BaseTools/Source/C/Common/PeCoffLoaderEx.c @@ -1,7 +1,7 @@ /** @file -IA32, X64 and IPF Specific relocation fixups +IA32 and X64 Specific relocation fixups Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -97,170 +97,10 @@ Returns: --*/ { return RETURN_UNSUPPORTED; } -RETURN_STATUS -PeCoffLoaderRelocateIpfImage ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an Itanium-based specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - Status code - ---*/ -{ - UINT64 *F64; - UINT64 FixupVal; - - switch ((*Reloc) >> 12) { - -case EFI_IMAGE_REL_BASED_IA64_IMM64: - - // - // Align it to bundle address before fixing up the - // 64-bit immediate value of the movl instruction. - // - - Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15)); - FixupVal = (UINT64)0; - - // - // Extract the lower 32 bits of IMM64 from bundle - // - EXT_IMM64(FixupVal, -(UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X, -IMM64_IMM7B_SIZE_X, -IMM64_IMM7B_INST_WORD_POS_X, -IMM64_IMM7B_VAL_POS_X -); - - EXT_IMM64(FixupVal, -(UINT32 *)Fixup
[edk2] [Patch 1/3 V2] BaseTools: Remove unused logic for EDKI
From: "Feng, Bob C" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350 Remove EDK module type support from BaseTools python code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py| 93 ++--- BaseTools/Source/Python/AutoGen/GenC.py | 90 - BaseTools/Source/Python/AutoGen/GenMake.py| 18 +- BaseTools/Source/Python/Common/DataType.py| 2 - BaseTools/Source/Python/Common/GlobalData.py | 6 - .../Source/Python/Workspace/DecBuildData.py | 1 - .../Source/Python/Workspace/DscBuildData.py | 3 - .../Source/Python/Workspace/InfBuildData.py | 191 +- .../Source/Python/Workspace/MetaFileParser.py | 22 -- .../Python/Workspace/WorkspaceCommon.py | 29 +-- BaseTools/Source/Python/build/BuildReport.py | 54 ++--- BaseTools/Source/Python/build/build.py| 65 -- edksetup.bat | 3 - 13 files changed, 116 insertions(+), 461 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index d646cd50ce..d3d0d96e71 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2174,46 +2174,11 @@ class PlatformAutoGen(AutoGen): Pcd.MaxDatumSize = str(len(Value.split(','))) else: Pcd.MaxDatumSize = str(len(Value) - 1) return Pcds.values() -## Resolve library names to library modules -# -# (for Edk.x modules) -# -# @param Module The module from which the library names will be resolved -# -# @retval library_listThe list of library modules -# -def ResolveLibraryReference(self, Module): -EdkLogger.verbose("") -EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch)) -LibraryConsumerList = [Module] - -# "CompilerStub" is a must for Edk modules -if Module.Libraries: -Module.Libraries.append("CompilerStub") -LibraryList = [] -while len(LibraryConsumerList) > 0: -M = LibraryConsumerList.pop() -for LibraryName in M.Libraries: -Library = self.Platform.LibraryClasses[LibraryName, ':dummy:'] -if Library is None: -for Key in self.Platform.LibraryClasses.data: -if LibraryName.upper() == Key.upper(): -Library = self.Platform.LibraryClasses[Key, ':dummy:'] -break -if Library is None: -EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M), -ExtraData="\t%s [%s]" % (str(Module), self.Arch)) -continue -if Library not in LibraryList: -LibraryList.append(Library) -LibraryConsumerList.append(Library) -EdkLogger.verbose("\t" + LibraryName + " : " + str(Library) + ' ' + str(type(Library))) -return LibraryList ## Calculate the priority value of the build option # # @paramKeyBuild option definition contain: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE # @@ -2377,16 +2342,12 @@ class PlatformAutoGen(AutoGen): # # @retval options The options appended with build options in platform # def ApplyBuildOption(self, Module): # Get the different options for the different style module -if Module.AutoGenVersion < 0x00010005: -PlatformOptions = self.EdkBuildOption -ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDK_NAME, Module.ModuleType) -else: -PlatformOptions = self.EdkIIBuildOption -ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType) +PlatformOptions = self.EdkIIBuildOption +ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType) ModuleTypeOptions = self._ExpandBuildOption(ModuleTypeOptions) ModuleOptions = self._ExpandBuildOption(Module.BuildOptions) if Module in self.Platform.Modules: PlatformModule = self.Platform.Modules[str(Module)] PlatformModuleOptions = self._ExpandBuildOption(PlatformModule.BuildOptions) @@ -2422,15 +2383,10 @@ class PlatformAutoGen(AutoGen): if Attr != 'PATH': BuildOptions[Tool][Attr] += " " + mws.handleWsMacro(Value) else: BuildOptions[Tool][Attr] = mws.handleWsMacro(Value) -if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag is not None: -# -# Override UNI flag only for EDK module.
[edk2] [Patch 3/3] BaseTools: Remove unused logic from C tools
From: "Feng, Bob C" Remove EDK module and IA64 support from BaseTools C code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/C/Common/BasePeCoff.c| 14 +- BaseTools/Source/C/Common/PeCoffLoaderEx.c| 162 +- BaseTools/Source/C/EfiRom/EfiRom.h| 3 +- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 72 +--- BaseTools/Source/C/GenFv/GenFvInternalLib.h | 10 -- BaseTools/Source/C/GenFw/Elf64Convert.c | 5 - BaseTools/Source/C/GenFw/GenFw.c | 6 +- BaseTools/Source/C/GenFw/elf_common.h | 85 - .../C/Include/IndustryStandard/PeImage.h | 3 - .../Source/C/Include/IndustryStandard/pci22.h | 1 - BaseTools/Source/C/Makefiles/header.makefile | 1 - BaseTools/Source/C/VolInfo/VolInfo.c | 2 +- 12 files changed, 10 insertions(+), 354 deletions(-) diff --git a/BaseTools/Source/C/Common/BasePeCoff.c b/BaseTools/Source/C/Common/BasePeCoff.c index 1d89a300de..d5cefbd0b0 100644 --- a/BaseTools/Source/C/Common/BasePeCoff.c +++ b/BaseTools/Source/C/Common/BasePeCoff.c @@ -54,17 +54,10 @@ PeCoffLoaderRelocateIa32Image ( IN OUT CHAR8 *Fixup, IN OUT CHAR8 **FixupData, IN UINT64 Adjust ); -RETURN_STATUS -PeCoffLoaderRelocateIpfImage ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ); RETURN_STATUS PeCoffLoaderRelocateArmImage ( IN UINT16 **Reloc, IN OUT CHAR8 *Fixup, @@ -182,11 +175,10 @@ Returns: } else { ImageContext->Machine = TeHdr->Machine; } if (ImageContext->Machine != EFI_IMAGE_MACHINE_IA32 && \ - ImageContext->Machine != EFI_IMAGE_MACHINE_IA64 && \ ImageContext->Machine != EFI_IMAGE_MACHINE_X64 && \ ImageContext->Machine != EFI_IMAGE_MACHINE_ARMT && \ ImageContext->Machine != EFI_IMAGE_MACHINE_EBC && \ ImageContext->Machine != EFI_IMAGE_MACHINE_AARCH64) { if (ImageContext->Machine == IMAGE_FILE_MACHINE_ARM) { @@ -814,13 +806,10 @@ Returns: Status = PeCoffLoaderRelocateIa32Image (Reloc, Fixup, &FixupData, Adjust); break; case EFI_IMAGE_MACHINE_ARMT: Status = PeCoffLoaderRelocateArmImage (&Reloc, Fixup, &FixupData, Adjust); break; -case EFI_IMAGE_MACHINE_IA64: - Status = PeCoffLoaderRelocateIpfImage (Reloc, Fixup, &FixupData, Adjust); - break; default: Status = RETURN_UNSUPPORTED; break; } if (RETURN_ERROR (Status)) { @@ -1317,13 +1306,12 @@ PeCoffLoaderGetPdbPointer ( // Assume PE32 image with IA32 Machine field. // Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; break; case EFI_IMAGE_MACHINE_X64: -case EFI_IMAGE_MACHINE_IPF: // - // Assume PE32+ image with X64 or IPF Machine field + // Assume PE32+ image with X64 Machine field // Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; break; default: // diff --git a/BaseTools/Source/C/Common/PeCoffLoaderEx.c b/BaseTools/Source/C/Common/PeCoffLoaderEx.c index 2d9a2a8978..fa8c7e3d17 100644 --- a/BaseTools/Source/C/Common/PeCoffLoaderEx.c +++ b/BaseTools/Source/C/Common/PeCoffLoaderEx.c @@ -1,7 +1,7 @@ /** @file -IA32, X64 and IPF Specific relocation fixups +IA32 and X64 Specific relocation fixups Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -97,170 +97,10 @@ Returns: --*/ { return RETURN_UNSUPPORTED; } -RETURN_STATUS -PeCoffLoaderRelocateIpfImage ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an Itanium-based specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - Status code - ---*/ -{ - UINT64 *F64; - UINT64 FixupVal; - - switch ((*Reloc) >> 12) { - -case EFI_IMAGE_REL_BASED_IA64_IMM64: - - // - // Align it to bundle address before fixing up the - // 64-bit immediate value of the movl instruction. - // - - Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15)); - FixupVal = (UINT64)0; - - // - // Extract the lower 32 bits of IMM64 from bundle - // - EXT_IMM64(FixupVal, -(UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X, -IMM64_IMM7B_SIZE_X, -IMM64_IMM7B_INST_WORD_POS_X, -IMM64_IMM7B_VAL_POS_X -); - - EXT_IMM64(FixupVal, -
[edk2] [Patch 1/3] BaseTools: Remove unused logic for EDKI
From: "Feng, Bob C" Remove EDK module type support from BaseTools C code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py| 93 ++--- BaseTools/Source/Python/AutoGen/GenC.py | 90 - BaseTools/Source/Python/AutoGen/GenMake.py| 18 +- BaseTools/Source/Python/Common/DataType.py| 2 - BaseTools/Source/Python/Common/GlobalData.py | 6 - .../Source/Python/Workspace/DecBuildData.py | 1 - .../Source/Python/Workspace/DscBuildData.py | 3 - .../Source/Python/Workspace/InfBuildData.py | 191 +- .../Source/Python/Workspace/MetaFileParser.py | 22 -- .../Python/Workspace/WorkspaceCommon.py | 29 +-- BaseTools/Source/Python/build/BuildReport.py | 54 ++--- BaseTools/Source/Python/build/build.py| 65 -- edksetup.bat | 3 - 13 files changed, 116 insertions(+), 461 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index d646cd50ce..d3d0d96e71 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2174,46 +2174,11 @@ class PlatformAutoGen(AutoGen): Pcd.MaxDatumSize = str(len(Value.split(','))) else: Pcd.MaxDatumSize = str(len(Value) - 1) return Pcds.values() -## Resolve library names to library modules -# -# (for Edk.x modules) -# -# @param Module The module from which the library names will be resolved -# -# @retval library_listThe list of library modules -# -def ResolveLibraryReference(self, Module): -EdkLogger.verbose("") -EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch)) -LibraryConsumerList = [Module] - -# "CompilerStub" is a must for Edk modules -if Module.Libraries: -Module.Libraries.append("CompilerStub") -LibraryList = [] -while len(LibraryConsumerList) > 0: -M = LibraryConsumerList.pop() -for LibraryName in M.Libraries: -Library = self.Platform.LibraryClasses[LibraryName, ':dummy:'] -if Library is None: -for Key in self.Platform.LibraryClasses.data: -if LibraryName.upper() == Key.upper(): -Library = self.Platform.LibraryClasses[Key, ':dummy:'] -break -if Library is None: -EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M), -ExtraData="\t%s [%s]" % (str(Module), self.Arch)) -continue -if Library not in LibraryList: -LibraryList.append(Library) -LibraryConsumerList.append(Library) -EdkLogger.verbose("\t" + LibraryName + " : " + str(Library) + ' ' + str(type(Library))) -return LibraryList ## Calculate the priority value of the build option # # @paramKeyBuild option definition contain: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE # @@ -2377,16 +2342,12 @@ class PlatformAutoGen(AutoGen): # # @retval options The options appended with build options in platform # def ApplyBuildOption(self, Module): # Get the different options for the different style module -if Module.AutoGenVersion < 0x00010005: -PlatformOptions = self.EdkBuildOption -ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDK_NAME, Module.ModuleType) -else: -PlatformOptions = self.EdkIIBuildOption -ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType) +PlatformOptions = self.EdkIIBuildOption +ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType) ModuleTypeOptions = self._ExpandBuildOption(ModuleTypeOptions) ModuleOptions = self._ExpandBuildOption(Module.BuildOptions) if Module in self.Platform.Modules: PlatformModule = self.Platform.Modules[str(Module)] PlatformModuleOptions = self._ExpandBuildOption(PlatformModule.BuildOptions) @@ -2422,15 +2383,10 @@ class PlatformAutoGen(AutoGen): if Attr != 'PATH': BuildOptions[Tool][Attr] += " " + mws.handleWsMacro(Value) else: BuildOptions[Tool][Attr] = mws.handleWsMacro(Value) -if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag is not None: -# -# Override UNI flag only for EDK module. -# -BuildOptions['BUILD']['FLAGS'] =
[edk2] [Patch 2/3] BaseTools: Remove unused logic for IPF
From: "Feng, Bob C" Remove IPF support from BaseTools C code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/Common/DataType.py| 19 +- .../Source/Python/CommonDataClass/FdfClass.py | 20 -- BaseTools/Source/Python/Eot/EotMain.py| 2 - .../Python/GenFds/ComponentStatement.py | 29 --- BaseTools/Source/Python/GenFds/Fd.py | 56 + BaseTools/Source/Python/GenFds/FdfParser.py | 223 +- BaseTools/Source/Python/GenFds/Fv.py | 12 +- BaseTools/Source/Python/GenFds/GenFds.py | 11 +- .../Python/GenFds/GenFdsGlobalVariable.py | 1 - BaseTools/Source/Python/GenFds/Region.py | 5 +- BaseTools/Source/Python/GenFds/Vtf.py | 200 .../Source/Python/TargetTool/TargetTool.py| 4 +- BaseTools/Source/Python/build/build.py| 20 +- 13 files changed, 20 insertions(+), 582 deletions(-) delete mode 100644 BaseTools/Source/Python/GenFds/ComponentStatement.py delete mode 100644 BaseTools/Source/Python/GenFds/Vtf.py diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index ec0a4f3d59..798c0e353d 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -52,16 +52,15 @@ TAB_FV_DIRECTORY = 'FV' TAB_ARCH_NULL = '' TAB_ARCH_COMMON = 'COMMON' TAB_ARCH_IA32 = 'IA32' TAB_ARCH_X64 = 'X64' -TAB_ARCH_IPF = 'IPF' TAB_ARCH_ARM = 'ARM' TAB_ARCH_EBC = 'EBC' TAB_ARCH_AARCH64 = 'AARCH64' -ARCH_SET_FULL = {TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64, TAB_ARCH_COMMON} +ARCH_SET_FULL = {TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64, TAB_ARCH_COMMON} SUP_MODULE_BASE = 'BASE' SUP_MODULE_SEC = 'SEC' SUP_MODULE_PEI_CORE = 'PEI_CORE' SUP_MODULE_PEIM = 'PEIM' @@ -134,74 +133,66 @@ PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE' TAB_SOURCES = 'Sources' TAB_SOURCES_COMMON = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_COMMON TAB_SOURCES_IA32 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IA32 TAB_SOURCES_X64 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_X64 -TAB_SOURCES_IPF = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IPF TAB_SOURCES_ARM = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_ARM TAB_SOURCES_EBC = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_EBC TAB_SOURCES_AARCH64 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_BINARIES = 'Binaries' TAB_BINARIES_COMMON = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_COMMON TAB_BINARIES_IA32 = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_IA32 TAB_BINARIES_X64 = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_X64 -TAB_BINARIES_IPF = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_IPF TAB_BINARIES_ARM = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_ARM TAB_BINARIES_EBC = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_EBC TAB_BINARIES_AARCH64 = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_INCLUDES = 'Includes' TAB_INCLUDES_COMMON = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_COMMON TAB_INCLUDES_IA32 = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_IA32 TAB_INCLUDES_X64 = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_X64 -TAB_INCLUDES_IPF = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_IPF TAB_INCLUDES_ARM = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_ARM TAB_INCLUDES_EBC = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_EBC TAB_INCLUDES_AARCH64 = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_GUIDS = 'Guids' TAB_GUIDS_COMMON = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_COMMON TAB_GUIDS_IA32 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_IA32 TAB_GUIDS_X64 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_X64 -TAB_GUIDS_IPF = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_IPF TAB_GUIDS_ARM = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_ARM TAB_GUIDS_EBC = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_EBC TAB_GUIDS_AARCH64 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PROTOCOLS = 'Protocols' TAB_PROTOCOLS_COMMON = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_COMMON TAB_PROTOCOLS_IA32 = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_IA32 TAB_PROTOCOLS_X64 = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_X64 -TAB_PROTOCOLS_IPF = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_IPF TAB_PROTOCOLS_ARM = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_ARM TAB_PROTOCOLS_EBC = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_EBC TAB_PROTOCOLS_AARCH64 = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PPIS = 'Ppis' TAB_PPIS_COMMON = TAB_PPIS + TAB_SPLIT + TAB_ARCH_COMMON TAB_PPIS_IA32 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_IA32 TAB_PPIS_X64 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_X64 -TAB_PPIS_IPF = TAB_PPIS + TAB_SPLIT + TAB_ARCH_IPF TAB_PPIS_ARM = TAB_PPIS + TAB_SPLIT + TAB_ARCH_ARM TAB_PPIS_EBC = TAB_PPIS + TAB_SPLIT + TAB_ARCH_EBC TAB_PPIS_AARCH64 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_LIBRARY_CLASSES = 'LibraryClasses' TAB_LIBRARY_CLASSES_COMMON = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_COMMON TAB_LIBRARY_CLASSES_IA32 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_IA32 TAB_LIBRARY_CLASSES_X64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_X64 -TAB_LIBRARY_CLASSES_IPF = TAB_LI
[edk2] [Patch 0/3] BaseTools: Remove unused logic in BaseTools
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1350 BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1104 Based on the requestion the above BZ, this patch serial removes the BaseTools C and Python code for EDKI, IPF support. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Jaben Carsey Feng, Bob C (3): BaseTools: Remove unused logic for EDKI BaseTools: Remove unused logic for IPF BaseTools: Remove unused logic from C tools BaseTools/Source/C/Common/BasePeCoff.c| 14 +- BaseTools/Source/C/Common/PeCoffLoaderEx.c| 162 + BaseTools/Source/C/EfiRom/EfiRom.h| 3 +- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 72 +- BaseTools/Source/C/GenFv/GenFvInternalLib.h | 10 - BaseTools/Source/C/GenFw/Elf64Convert.c | 5 - BaseTools/Source/C/GenFw/GenFw.c | 6 +- BaseTools/Source/C/GenFw/elf_common.h | 85 --- .../C/Include/IndustryStandard/PeImage.h | 3 - .../Source/C/Include/IndustryStandard/pci22.h | 1 - BaseTools/Source/C/Makefiles/header.makefile | 1 - BaseTools/Source/C/VolInfo/VolInfo.c | 2 +- BaseTools/Source/Python/AutoGen/AutoGen.py| 93 +--- BaseTools/Source/Python/AutoGen/GenC.py | 90 +++ BaseTools/Source/Python/AutoGen/GenMake.py| 18 +- BaseTools/Source/Python/Common/DataType.py| 21 +- BaseTools/Source/Python/Common/GlobalData.py | 6 - .../Source/Python/CommonDataClass/FdfClass.py | 20 -- BaseTools/Source/Python/Eot/EotMain.py| 2 - .../Python/GenFds/ComponentStatement.py | 29 --- BaseTools/Source/Python/GenFds/Fd.py | 56 + BaseTools/Source/Python/GenFds/FdfParser.py | 223 +- BaseTools/Source/Python/GenFds/Fv.py | 12 +- BaseTools/Source/Python/GenFds/GenFds.py | 11 +- .../Python/GenFds/GenFdsGlobalVariable.py | 1 - BaseTools/Source/Python/GenFds/Region.py | 5 +- BaseTools/Source/Python/GenFds/Vtf.py | 200 .../Source/Python/TargetTool/TargetTool.py| 4 +- .../Source/Python/Workspace/DecBuildData.py | 1 - .../Source/Python/Workspace/DscBuildData.py | 3 - .../Source/Python/Workspace/InfBuildData.py | 191 --- .../Source/Python/Workspace/MetaFileParser.py | 22 -- .../Python/Workspace/WorkspaceCommon.py | 29 +-- BaseTools/Source/Python/build/BuildReport.py | 54 ++--- BaseTools/Source/Python/build/build.py| 85 +-- edksetup.bat | 3 - 36 files changed, 146 insertions(+), 1397 deletions(-) delete mode 100644 BaseTools/Source/Python/GenFds/ComponentStatement.py delete mode 100644 BaseTools/Source/Python/GenFds/Vtf.py -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Report Error if use SET in Dsc
Build tool do not support SET syntax in DSC. If the SET statement is used in DSC, build tool just ignore it. That behavior confused some users that they think SET statement works in DSC like in FDF. To avoid such confusion, build tool report ERROR if there is "SET" statement in Dsc file. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/MetaFileParser.py | 5 + 1 file changed, 5 insertions(+) diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 032220813b..19d8452a35 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -975,10 +975,15 @@ class DscParser(MetaFileParser): else: SectionType = self._SectionType self._ItemType = SectionType self._ValueList = ['', '', ''] +# "SET pcd = pcd_expression" syntax is not supported in Dsc file. +if self._CurrentLine.upper().strip().startswith("SET "): +EdkLogger.error('Parser', FORMAT_INVALID, '''"SET pcd = pcd_expression" syntax is not support in Dsc file''', +ExtraData=self._CurrentLine, +File=self.MetaFile, Line=self._LineIndex + 1) self._SectionParser[SectionType](self) if self._ValueList is None: continue # # Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1, -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fixed build report issue.
From: "Feng, Bob C" This patch is going to fix the regression issue by 72a1d77694d51914c0dd6aa97dbfa58634b0a4a5 After enable PCD array, the Pcd.OverrideStruct has a new key, array index, but the build report is not changed correspondingly. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/build/BuildReport.py | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index d379866618..3f3c1a12f1 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -1422,13 +1422,14 @@ class PcdReport(object): self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) def OverrideFieldValue(self, Pcd, OverrideStruct): OverrideFieldStruct = collections.OrderedDict() if OverrideStruct: -for Key, Values in OverrideStruct.items(): -if Values[1] and Values[1].endswith('.dsc'): -OverrideFieldStruct[Key] = Values +for _, Values in OverrideStruct.items(): +for Key,value in Values.items(): +if value[1] and value[1].endswith('.dsc'): +OverrideFieldStruct[Key] = value if Pcd.PcdFieldValueFromFdf: for Key, Values in Pcd.PcdFieldValueFromFdf.items(): if Key in OverrideFieldStruct and Values[0] == OverrideFieldStruct[Key][0]: continue OverrideFieldStruct[Key] = Values -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Correct PcdArray value assigment statement
https://bugzilla.tianocore.org/show_bug.cgi?id=1410 BaseTools should not generate C structure array initial value if the value is not specified with CODE style. This patch is going to remove the incorrect initial value statement and correct the Pcd Array value assignment statement. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Python/Workspace/BuildClassObject.py | 1 - .../Source/Python/Workspace/DscBuildData.py | 117 +++--- 2 files changed, 73 insertions(+), 45 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 52b3369561..73920c5153 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -99,11 +99,10 @@ class PcdClassObject(object): for demesionattr in self.DefaultValues: deme = ArrayIndex.findall(demesionattr) for i in range(len(deme)-1): if int(deme[i].lstrip("[").rstrip("]").strip()) > int(self._Capacity[i]): print "error" -self._Capacity = [str(int(d) + 1) for d in self._Capacity] return self._Capacity @property def DatumType(self): return self._DatumType diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 7f6e966b5f..7e82e8e934 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1738,21 +1738,26 @@ class DscBuildData(PlatformBuildClassObject): def GenerateSizeFunction(self, Pcd): CApp = "// Default Value in Dec \n" CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) if Pcd.IsArray(): -if (len(Pcd.Capacity) == 1 and Pcd.Capacity[0] != '0') or (len(Pcd.Capacity) >1 and reduce(lambda x,y:int(x)*int(y), Pcd.Capacity)) > 0: -CApp += " *Size = (sizeof (%s) * (%s) > *Size) ? sizeof (%s) * (%s): *Size; \n" % (Pcd.BaseDatumType, "*".join(Pcd.Capacity),Pcd.BaseDatumType, "*".join(Pcd.Capacity)) -if "{CODE(" in Pcd.DefaultValueFromDec: -CApp += " *Size = (sizeof (%s_%s_INIT_Value) > *Size ? sizeof (%s_%s_INIT_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,Pcd.TokenSpaceGuidCName,Pcd.TokenCName) -for skuname in Pcd.SkuInfoList: -skuobj = Pcd.SkuInfoList[skuname] -if skuobj.VariableName: -for defaultstore in skuobj.DefaultStoreDict: -CApp += " *Size = (sizeof (%s_%s_%s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore) -else: -CApp += " *Size = (sizeof (%s_%s_%s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,TAB_DEFAULT_STORES_DEFAULT,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,TAB_DEFAULT_STORES_DEFAULT) +if Pcd.Type in PCD_DYNAMIC_TYPE_SET | PCD_DYNAMIC_EX_TYPE_SET: +for skuname in Pcd.SkuInfoList: +skuobj = Pcd.SkuInfoList[skuname] +if skuobj.VariableName: +for defaultstore in skuobj.DefaultStoreDict: +pcddef = self.GetPcdDscRawDefaultValue(Pcd,skuname,defaultstore) +if pcddef and "{CODE(" in pcddef: +CApp += " *Size = (sizeof (%s_%s_%s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore) +else: +pcddef = self.GetPcdDscRawDefaultValue(Pcd,skuname,TAB_DEFAULT_STORES_DEFAULT) +if pcddef and "{CODE(" in pcddef: +CApp += " *Size = (sizeof (%s_%s_%s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,TAB_DEFAULT_STORES_DEFAULT,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,TAB_DEFAULT_STORES_DEFAULT) +else: +pcddef = self.GetPcdDscRawDefaultValue(Pcd,TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT) +if pcddef and "{CODE(" in pcddef: +CApp += " *Size = (sizeof (%s_%s_%s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCName,Pcd.TokenCName,TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT) for index in Pcd.DefaultValues: FieldList = Pcd.DefaultValues[index] if not Field
[edk2] [Patch] BaseTools: Reset FdsGlobalVariable
https://bugzilla.tianocore.org/show_bug.cgi?id=1418 This patch is going to fix a regression issue that is introduced by commit b3497bad1221704a5dbc5da0b10f42625f1ad2ed. Before commit b3497b, build launched a external GenFds.py to generate Fd, so the global variable in GenFds.py was reset in each execution. After commit b3497b, each GenFds run in the same python interpeter, so we need to explicitly reset global variable in each GenFdsApi call. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Ard Biesheuvel --- BaseTools/Source/Python/GenFds/GenFds.py | 51 1 file changed, 51 insertions(+) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 51655cc09c..447aa7f5eb 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -39,10 +39,12 @@ from Common.BuildToolError import FatalError, GENFDS_ERROR, CODE_ERROR, FORMAT_I from Workspace.WorkspaceDatabase import WorkspaceDatabase from .FdfParser import FdfParser, Warning from .GenFdsGlobalVariable import GenFdsGlobalVariable from .FfsFileStatement import FileStatement +import Common.DataType as DataType +from struct import Struct ## Version and Copyright versionNumber = "1.0" + ' ' + gBUILD_VERSION __version__ = "%prog Version " + versionNumber __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation All rights reserved." @@ -60,15 +62,64 @@ def main(): global Options Options = myOptionParser() EdkLogger.Initialize() return GenFdsApi(OptionsToCommandDict(Options)) +def resetFdsGlobalVariable(): +GenFdsGlobalVariable.FvDir = '' +GenFdsGlobalVariable.OutputDirDict = {} +GenFdsGlobalVariable.BinDir = '' +# will be FvDir + os.sep + 'Ffs' +GenFdsGlobalVariable.FfsDir = '' +GenFdsGlobalVariable.FdfParser = None +GenFdsGlobalVariable.LibDir = '' +GenFdsGlobalVariable.WorkSpace = None +GenFdsGlobalVariable.WorkSpaceDir = '' +GenFdsGlobalVariable.ConfDir = '' +GenFdsGlobalVariable.EdkSourceDir = '' +GenFdsGlobalVariable.OutputDirFromDscDict = {} +GenFdsGlobalVariable.TargetName = '' +GenFdsGlobalVariable.ToolChainTag = '' +GenFdsGlobalVariable.RuleDict = {} +GenFdsGlobalVariable.ArchList = None +GenFdsGlobalVariable.VtfDict = {} +GenFdsGlobalVariable.ActivePlatform = None +GenFdsGlobalVariable.FvAddressFileName = '' +GenFdsGlobalVariable.VerboseMode = False +GenFdsGlobalVariable.DebugLevel = -1 +GenFdsGlobalVariable.SharpCounter = 0 +GenFdsGlobalVariable.SharpNumberPerLine = 40 +GenFdsGlobalVariable.FdfFile = '' +GenFdsGlobalVariable.FdfFileTimeStamp = 0 +GenFdsGlobalVariable.FixedLoadAddress = False +GenFdsGlobalVariable.PlatformName = '' + +GenFdsGlobalVariable.BuildRuleFamily = DataType.TAB_COMPILER_MSFT +GenFdsGlobalVariable.ToolChainFamily = DataType.TAB_COMPILER_MSFT +GenFdsGlobalVariable.__BuildRuleDatabase = None +GenFdsGlobalVariable.GuidToolDefinition = {} +GenFdsGlobalVariable.FfsCmdDict = {} +GenFdsGlobalVariable.SecCmdList = [] +GenFdsGlobalVariable.CopyList = [] +GenFdsGlobalVariable.ModuleFile = '' +GenFdsGlobalVariable.EnableGenfdsMultiThread = False + +GenFdsGlobalVariable.LargeFileInFvFlags = [] +GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID = '5473C07A-3DCB-4dca-BD6F-1E9689E7349A' +GenFdsGlobalVariable.LARGE_FILE_SIZE = 0x100 + +GenFdsGlobalVariable.SectionHeader = Struct("3B 1B") + +# FvName, FdName, CapName in FDF, Image file name +GenFdsGlobalVariable.ImageBinDict = {} + def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None): global Workspace Workspace = "" ArchList = None ReturnCode = 0 +resetFdsGlobalVariable() try: if FdsCommandDict.get("verbose"): EdkLogger.SetLevel(EdkLogger.VERBOSE) GenFdsGlobalVariable.VerboseMode = True -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch V2] BaseTools: Fixed metafile parser issues
https://bugzilla.tianocore.org/show_bug.cgi?id=1406 This patch is going to fix the regressions that is introduced by commit 2f818ed0fb57d98985d151781a2ce9b8683129ee The internal array for storing the metadata info should be cached so that the meta file is parsed only once in one build. Change-Id: I62c00e9f439e5d632c4b3f58cc5c4181d8acc52d Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 2 +- .../Source/Python/Workspace/MetaFileParser.py | 25 +++--- .../Source/Python/Workspace/MetaFileTable.py | 34 +++ .../Python/Workspace/WorkspaceDatabase.py | 4 +-- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 4543ae7dc0..2c1e783d2e 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -879,11 +879,11 @@ class DscBuildData(PlatformBuildClassObject): Library = self._Bdb[File, self._Arch, self._Target, self._Toolchain] self._LibraryClasses[Library.BaseName, ':dummy:'] = Library return self._LibraryClasses def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo): -if self._DecPcds is None: +if not self._DecPcds: FdfInfList = [] if GlobalData.gFdfParser: FdfInfList = GlobalData.gFdfParser.Profile.InfList diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index eaedba0c12..032220813b 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -204,13 +204,11 @@ class MetaFileParser(object): self._PostProcessed = False ## Set parsing complete flag in both class and table def _Done(self): self._Finished = True -## Do not set end flag when processing included files -if self._From == -1: -self._Table.SetEndFlag() +self._Table.SetEndFlag() def _PostProcess(self): self._PostProcessed = True ## Get the parse complete flag @@ -239,17 +237,11 @@ class MetaFileParser(object): def __getitem__(self, DataInfo): if not isinstance(DataInfo, type(())): DataInfo = (DataInfo,) # Parse the file first, if necessary -if not self._Finished: -if self._RawTable.IsIntegrity(): -self._Finished = True -else: -self._Table = self._RawTable -self._PostProcessed = False -self.Start() +self.StartParse() # No specific ARCH or Platform given, use raw data if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] is None): return self._FilterRecordList(self._RawTable.Query(*DataInfo), self._Arch) @@ -257,10 +249,18 @@ class MetaFileParser(object): if not self._PostProcessed: self._PostProcess() return self._FilterRecordList(self._Table.Query(*DataInfo), DataInfo[1]) +def StartParse(self): +if not self._Finished: +if self._RawTable.IsIntegrity(): +self._Finished = True +else: +self._Table = self._RawTable +self._PostProcessed = False +self.Start() ## Data parser for the common format in different type of file # # The common format in the meatfile is like # # xxx1 | xxx2 | xxx3 @@ -915,10 +915,11 @@ class DscParser(MetaFileParser): self._IdMapping = {-1:-1} self._PcdCodeValue = "" self._PcdDataTypeCODE = False self._CurrentPcdName = "" +self._Content = None ## Parser starter def Start(self): Content = '' try: @@ -1643,13 +1644,11 @@ class DscParser(MetaFileParser): Parser._InSubsection = self._InSubsection Parser._SectionType = self._SectionType Parser._Scope = self._Scope Parser._Enabled = self._Enabled # Parse the included file -Parser.Start() - - +Parser.StartParse() # Insert all records in the table for the included file into dsc file table Records = IncludedFileTable.GetAll() if Records: self._Content[self._ContentIndex:self._ContentIndex] = Records self._Content.pop(self._ContentIndex - 1) diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py index 081970dba8..004e9494c3 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -24,38 +24,42 @@ from CommonDataClass.DataClass impo
[edk2] [Patch] BaseTools: Fixed metafile parser issues
This patch is going to fix the regressions that is introduced by commit 2f818ed0fb57d98985d151781a2ce9b8683129ee The meta file should be parsed only once in one build. So adding cache for meta file data array and check if the meta file is already parsed before start parsing file. Change the meta file data array index data type from float to int. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 2 +- .../Source/Python/Workspace/MetaFileParser.py | 21 +-- .../Source/Python/Workspace/MetaFileTable.py | 36 +++ .../Python/Workspace/WorkspaceDatabase.py | 4 +-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 4543ae7dc0..2c1e783d2e 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -879,11 +879,11 @@ class DscBuildData(PlatformBuildClassObject): Library = self._Bdb[File, self._Arch, self._Target, self._Toolchain] self._LibraryClasses[Library.BaseName, ':dummy:'] = Library return self._LibraryClasses def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo): -if self._DecPcds is None: +if not self._DecPcds: FdfInfList = [] if GlobalData.gFdfParser: FdfInfList = GlobalData.gFdfParser.Profile.InfList diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index eaedba0c12..45736d4953 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -239,17 +239,11 @@ class MetaFileParser(object): def __getitem__(self, DataInfo): if not isinstance(DataInfo, type(())): DataInfo = (DataInfo,) # Parse the file first, if necessary -if not self._Finished: -if self._RawTable.IsIntegrity(): -self._Finished = True -else: -self._Table = self._RawTable -self._PostProcessed = False -self.Start() +self.StartParse() # No specific ARCH or Platform given, use raw data if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] is None): return self._FilterRecordList(self._RawTable.Query(*DataInfo), self._Arch) @@ -257,10 +251,18 @@ class MetaFileParser(object): if not self._PostProcessed: self._PostProcess() return self._FilterRecordList(self._Table.Query(*DataInfo), DataInfo[1]) +def StartParse(self): +if not self._Finished: +if self._RawTable.IsIntegrity(): +self._Finished = True +else: +self._Table = self._RawTable +self._PostProcessed = False +self.Start() ## Data parser for the common format in different type of file # # The common format in the meatfile is like # # xxx1 | xxx2 | xxx3 @@ -915,10 +917,11 @@ class DscParser(MetaFileParser): self._IdMapping = {-1:-1} self._PcdCodeValue = "" self._PcdDataTypeCODE = False self._CurrentPcdName = "" +self._Content = None ## Parser starter def Start(self): Content = '' try: @@ -1643,13 +1646,11 @@ class DscParser(MetaFileParser): Parser._InSubsection = self._InSubsection Parser._SectionType = self._SectionType Parser._Scope = self._Scope Parser._Enabled = self._Enabled # Parse the included file -Parser.Start() - - +Parser.StartParse() # Insert all records in the table for the included file into dsc file table Records = IncludedFileTable.GetAll() if Records: self._Content[self._ContentIndex:self._ContentIndex] = Records self._Content.pop(self._ContentIndex - 1) diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py index 081970dba8..6142ee325a 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -24,38 +24,42 @@ from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE MODEL_FILE_OTHERS from Common.DataType import * class MetaFileTable(): # TRICK: use file ID as the part before '.' -_ID_STEP_ = 0.0001 -_ID_MAX_ = 0. +_ID_STEP_ = 1 +_ID_MAX_ = ## Constructor def __init__(self, DB, MetaFile, FileType, Temporary, FromItem=None): self.MetaFile = MetaFile self.TableName = "
[edk2] [Patch V2] BaseTools: Fix PcdArray issue
From: "Feng, Bob C" https://bugzilla.tianocore.org/show_bug.cgi?id=1390 1. support hex number for array index 2. support Non-Dynamic Pcd for array data type 3. support {} and {CODE()} for array data type 4. Change GetStructurePcdMaxSize to be a static function since it need to be called in another static function. And this function does not depend on it's class instance. 5. Add unittest for RemoveCComments function and ArrayIndex regular expression. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Ard Biesheuvel Cc: Philippe Mathieu-Daudé --- BaseTools/Source/Python/Common/Misc.py| 6 ++ .../Python/Workspace/BuildClassObject.py | 3 +- .../Source/Python/Workspace/DscBuildData.py | 59 --- BaseTools/Tests/TestRegularExpression.py | 54 + 4 files changed, 99 insertions(+), 23 deletions(-) create mode 100644 BaseTools/Tests/TestRegularExpression.py diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b063f064fb..ea09f85e70 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2144,10 +2144,16 @@ def CopyDict(ori_dict): if isinstance(ori_dict[key],(dict,OrderedDict)): new_dict[key] = CopyDict(ori_dict[key]) else: new_dict[key] = ori_dict[key] return new_dict + +# +# Remove the c/c++ comments: // and /* */ +# +def RemoveCComments(ctext): +return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.S) ## # # This acts like the main() function for the script, unless it is 'import'ed into another # script. # diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 008eee1a16..e9a1195fd2 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -17,11 +17,11 @@ import collections import re from collections import OrderedDict from Common.Misc import CopyDict import copy StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') -ArrayIndex = re.compile("\[\s*\d{0,1}\s*\]") +ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") ## PcdClassObject # # This Class is used for PcdObject # # @param object: Inherited from object class @@ -82,10 +82,11 @@ class PcdClassObject(object): dimension = ArrayIndex.findall(self._DatumType) for item in dimension: maxsize = item.lstrip("[").rstrip("]").strip() if not maxsize: maxsize = "-1" +maxsize = str(int(maxsize,16)) if maxsize.startswith(("0x","0X")) else maxsize self._Capacity.append(maxsize) if hasattr(self, "SkuOverrideValues"): for sku in self.SkuOverrideValues: for defaultstore in self.SkuOverrideValues[sku]: fields = self.SkuOverrideValues[sku][defaultstore] diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b485c75a84..37fb8d56b6 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -31,11 +31,11 @@ from .MetaDataTable import * from .MetaFileTable import * from .MetaFileParser import * from .WorkspaceCommon import GetDeclaredPcd from Common.Misc import AnalyzeDscPcd -from Common.Misc import ProcessDuplicatedInf +from Common.Misc import ProcessDuplicatedInf,RemoveCComments import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess @@ -1573,11 +1573,11 @@ class DscBuildData(PlatformBuildClassObject): mindefaultstorename = DefaultStoreObj.GetMin(PcdDefaultStoreSet) str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].HiiDefaultValue = str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].DefaultStoreDict[mindefaultstorename] for str_pcd_obj in S_pcd_set.values(): -str_pcd_obj.MaxDatumSize = self.GetStructurePcdMaxSize(str_pcd_obj) +str_pcd_obj.MaxDatumSize = DscBuildData.GetStructurePcdMaxSize(str_pcd_obj) Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCName] = str_pcd_obj Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCName].CustomAttribute['IsStru']=True for pcdkey in Pcds: pcd = Pcds[pcdkey] @@ -1687,13 +1687,14 @@ class DscBuildData(PlatformBuildClassObject): if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue: Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DEFAULT_STORES_DEFAULT] = Settings[0] return Pcds -def GetStructurePcdMaxSize(self, str_pcd):
[edk2] [Patch] BaseTools: Fix PcdArray issue
https://bugzilla.tianocore.org/show_bug.cgi?id=1390 1. support hex number for array index 2. support Non-Dynamic Pcd for array data type 3. support {} and {CODE()} for array data type Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Ard Biesheuvel --- BaseTools/Source/Python/Common/Misc.py| 6 ++ .../Python/Workspace/BuildClassObject.py | 3 +- .../Source/Python/Workspace/DscBuildData.py | 59 --- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b063f064fb..ea09f85e70 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2144,10 +2144,16 @@ def CopyDict(ori_dict): if isinstance(ori_dict[key],(dict,OrderedDict)): new_dict[key] = CopyDict(ori_dict[key]) else: new_dict[key] = ori_dict[key] return new_dict + +# +# Remove the c/c++ comments: // and /* */ +# +def RemoveCComments(ctext): +return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.S) ## # # This acts like the main() function for the script, unless it is 'import'ed into another # script. # diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 008eee1a16..e9a1195fd2 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -17,11 +17,11 @@ import collections import re from collections import OrderedDict from Common.Misc import CopyDict import copy StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') -ArrayIndex = re.compile("\[\s*\d{0,1}\s*\]") +ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") ## PcdClassObject # # This Class is used for PcdObject # # @param object: Inherited from object class @@ -82,10 +82,11 @@ class PcdClassObject(object): dimension = ArrayIndex.findall(self._DatumType) for item in dimension: maxsize = item.lstrip("[").rstrip("]").strip() if not maxsize: maxsize = "-1" +maxsize = str(int(maxsize,16)) if maxsize.startswith(("0x","0X")) else maxsize self._Capacity.append(maxsize) if hasattr(self, "SkuOverrideValues"): for sku in self.SkuOverrideValues: for defaultstore in self.SkuOverrideValues[sku]: fields = self.SkuOverrideValues[sku][defaultstore] diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b485c75a84..37fb8d56b6 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -31,11 +31,11 @@ from .MetaDataTable import * from .MetaFileTable import * from .MetaFileParser import * from .WorkspaceCommon import GetDeclaredPcd from Common.Misc import AnalyzeDscPcd -from Common.Misc import ProcessDuplicatedInf +from Common.Misc import ProcessDuplicatedInf,RemoveCComments import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess @@ -1573,11 +1573,11 @@ class DscBuildData(PlatformBuildClassObject): mindefaultstorename = DefaultStoreObj.GetMin(PcdDefaultStoreSet) str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].HiiDefaultValue = str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].DefaultStoreDict[mindefaultstorename] for str_pcd_obj in S_pcd_set.values(): -str_pcd_obj.MaxDatumSize = self.GetStructurePcdMaxSize(str_pcd_obj) +str_pcd_obj.MaxDatumSize = DscBuildData.GetStructurePcdMaxSize(str_pcd_obj) Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCName] = str_pcd_obj Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCName].CustomAttribute['IsStru']=True for pcdkey in Pcds: pcd = Pcds[pcdkey] @@ -1687,13 +1687,14 @@ class DscBuildData(PlatformBuildClassObject): if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue: Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DEFAULT_STORES_DEFAULT] = Settings[0] return Pcds -def GetStructurePcdMaxSize(self, str_pcd): +@staticmethod +def GetStructurePcdMaxSize(str_pcd): pcd_default_value = str_pcd.DefaultValue -sku_values = [skuobj.HiiDefaultValue if str_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]] else skuobj.DefaultValue for skuobj in str_pcd.SkuInfoList.values()] +sku_values = [skuobj.HiiDefaultValue if str_pcd.Type in [DscBuildData._PCD_
[edk2] [Patch V3] BaseTools: Fix PcdNvStoreDefaultValueBuffer Value.
From: "Feng, Bob C" https://bugzilla.tianocore.org/show_bug.cgi?id=1385 This patch is going to fix the regression issue that is introduced by commit e6eae3b4c7b9b756263ecec79694de5f1e85b73a and commit 0b6c5954e1d9a17e01eee7d5ef840a5b4790e2e8. PcdNvStoreDefaultValueBuffer value is update to Vpd Info File, but it is not update into a internal cache. This patch will fix this incorrect value in that internal cache. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Leif Lindholm --- BaseTools/Source/Python/AutoGen/AutoGen.py| 16 BaseTools/Source/Python/Common/VpdInfoFile.py | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 12e53010a5..d646cd50ce 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1568,10 +1568,16 @@ class PlatformAutoGen(AutoGen): if VpdFile.GetCount() != 0: self.FixVpdOffset(VpdFile) self.FixVpdOffset(self.UpdateNVStoreMaxSize(VpdFile)) +PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"] +if PcdNvStoreDfBuffer: +PcdName,PcdGuid = PcdNvStoreDfBuffer[0].TokenCName, PcdNvStoreDfBuffer[0].TokenSpaceGuidCName +if (PcdName,PcdGuid) in VpdSkuMap: +DefaultSku = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT) +VpdSkuMap[(PcdName,PcdGuid)] = {DefaultSku.DefaultValue:[DefaultSku]} # Process VPD map file generated by third party BPDG tool if NeedProcessVpdMapFile: VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid) if os.path.exists(VpdMapFilePath): @@ -1885,19 +1891,21 @@ class PlatformAutoGen(AutoGen): @cached_property def NonDynamicPcdDict(self): return {(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):Pcd for Pcd in self.NonDynamicPcdList} ## Get list of non-dynamic PCDs -@cached_property +@property def NonDynamicPcdList(self): -self.CollectPlatformDynamicPcds() +if not self._NonDynamicPcdList: +self.CollectPlatformDynamicPcds() return self._NonDynamicPcdList ## Get list of dynamic PCDs -@cached_property +@property def DynamicPcdList(self): -self.CollectPlatformDynamicPcds() +if not self._DynamicPcdList: +self.CollectPlatformDynamicPcds() return self._DynamicPcdList ## Generate Token Number for all PCD @cached_property def PcdTokenNumber(self): diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index 3be0670e36..cebc1f7187 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -175,12 +175,12 @@ class VpdInfoFile: EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath) Found = False if (TokenSpaceName, PcdTokenName) not in self._VpdInfo: -self._VpdInfo[(TokenSpaceName, PcdTokenName)] = [] -self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId, Offset, Value)) +self._VpdInfo[(TokenSpaceName, PcdTokenName)] = {} +self._VpdInfo[(TokenSpaceName, PcdTokenName)][(SkuId, Offset)] = Value for VpdObject in self._VpdArray: VpdObjectTokenCName = VpdObject.TokenCName for PcdItem in GlobalData.MixedPcd: if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: VpdObjectTokenCName = PcdItem[0] @@ -217,11 +217,11 @@ class VpdInfoFile: return None return self._VpdArray[vpd] def GetVpdInfo(self, arg): (PcdTokenName, TokenSpaceName) = arg -return self._VpdInfo.get((TokenSpaceName, PcdTokenName)) +return [(sku,offset,value) for (sku,offset),value in self._VpdInfo.get((TokenSpaceName, PcdTokenName)).items()] ## Call external BPDG tool to process VPD file # # @param ToolPath The string path name for BPDG tool # @param VpdFileName The string path name for VPD information guid.txt -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch V3] BaseTools: Fixed the build fail issue for cases
From: "Feng, Bob C" https://bugzilla.tianocore.org/show_bug.cgi?id=1386 This patch is going to fix the regression issue that is introduced by commit 72a1d77694d51914c0dd6aa97dbfa58634b0a4a5 The issue will happen in the following cases: 1. There is no Pcd value assignment in Dsc file 2. There are duplicate Pcd filed assignment Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Leif Lindholm --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 +- BaseTools/Source/Python/Workspace/MetaFileParser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 008eee1a16..d02232b546 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -289,11 +289,11 @@ class StructurePcd(PcdClassObject): if DefaultStoreName not in self.SkuOverrideValues[SkuName]: self.SkuOverrideValues[SkuName][DefaultStoreName] = OrderedDict() if DimensionAttr not in self.SkuOverrideValues[SkuName][DefaultStoreName]: self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr] = collections.OrderedDict() if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr]: -del self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName][DimensionAttr] +del self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] = [Value.strip(), FileName, LineNo] return self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] def SetPcdMode (self, PcdMode): self.PcdMode = PcdMode diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 4bd52619a9..eaedba0c12 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1201,11 +1201,11 @@ class DscParser(MetaFileParser): else: self._ValueList = None return TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) self._CurrentPcdName = TokenList[0] -if TokenList[1].strip().startswith("{CODE"): +if len(TokenList) == 2 and TokenList[1].strip().startswith("{CODE"): self._PcdDataTypeCODE = True self._PcdCodeValue = TokenList[1].strip() if self._PcdDataTypeCODE: if self._CurrentLine.endswith(")}"): -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch V3] BaseTools: Fixed bugs in CopyDict function
From: "Feng, Bob C" https://bugzilla.tianocore.org/show_bug.cgi?id=1387 This patch is going to fix the regression issue which is introduced by commit bf9e636605188e291d33ab694ff1c5926b6f0800. This patch Remove the CopyDict incorrect usage for non-dict input data. Add a check for CopyDict input. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Leif Lindholm --- BaseTools/Source/Python/Common/Misc.py| 2 ++ BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b063f064fb..6a22d01012 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2137,10 +2137,12 @@ def PackByteFormatGUID(Guid): # # @retval new dict or orderdict # def CopyDict(ori_dict): dict_type = ori_dict.__class__ +if dict_type not in (dict,OrderedDict): +return ori_dict new_dict = dict_type() for key in ori_dict: if isinstance(ori_dict[key],(dict,OrderedDict)): new_dict[key] = CopyDict(ori_dict[key]) else: diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b485c75a84..4543ae7dc0 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -972,11 +972,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in pcd.SkuInfoList: skuobj = pcd.SkuInfoList.get(skuid) if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict: PcdDefaultStoreSet = set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict) mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) -skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) +skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = skuobj.DefaultStoreDict[mindefaultstorename] return Pcds def RecoverCommandLinePcd(self): def UpdateCommandLineValue(pcd): if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], @@ -2767,11 +2767,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in PcdObj.SkuInfoList: skuobj = PcdObj.SkuInfoList[skuid] mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict)) for defaultstorename in DefaultStores: if defaultstorename not in skuobj.DefaultStoreDict: -skuobj.DefaultStoreDict[defaultstorename] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) +skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename] skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename] for skuname, skuid in SkuIds.items(): if skuname not in PcdObj.SkuInfoList: nextskuid = self.SkuIdMgr.GetNextSkuId(skuname) while nextskuid not in PcdObj.SkuInfoList: -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch V2] BaseTools: Fix PcdNvStoreDefaultValueBuffer Value.
From: "Feng, Bob C" V2: update the commit log. This issue is related to the commit e6eae3b4c7b9b756263ecec79694de5f1e85b73a and 0b6c5954e1d9a17e01eee7d5ef840a5b4790e2e8 V1: https://bugzilla.tianocore.org/show_bug.cgi?id=1385 PcdNvStoreDefaultValueBuffer value is update to Vpd Info File, but it is not update into a internal cache. This patch is going to fix this incorrect value in that internal cache. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py| 16 BaseTools/Source/Python/Common/VpdInfoFile.py | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 12e53010a5..d646cd50ce 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1568,10 +1568,16 @@ class PlatformAutoGen(AutoGen): if VpdFile.GetCount() != 0: self.FixVpdOffset(VpdFile) self.FixVpdOffset(self.UpdateNVStoreMaxSize(VpdFile)) +PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"] +if PcdNvStoreDfBuffer: +PcdName,PcdGuid = PcdNvStoreDfBuffer[0].TokenCName, PcdNvStoreDfBuffer[0].TokenSpaceGuidCName +if (PcdName,PcdGuid) in VpdSkuMap: +DefaultSku = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT) +VpdSkuMap[(PcdName,PcdGuid)] = {DefaultSku.DefaultValue:[DefaultSku]} # Process VPD map file generated by third party BPDG tool if NeedProcessVpdMapFile: VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid) if os.path.exists(VpdMapFilePath): @@ -1885,19 +1891,21 @@ class PlatformAutoGen(AutoGen): @cached_property def NonDynamicPcdDict(self): return {(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):Pcd for Pcd in self.NonDynamicPcdList} ## Get list of non-dynamic PCDs -@cached_property +@property def NonDynamicPcdList(self): -self.CollectPlatformDynamicPcds() +if not self._NonDynamicPcdList: +self.CollectPlatformDynamicPcds() return self._NonDynamicPcdList ## Get list of dynamic PCDs -@cached_property +@property def DynamicPcdList(self): -self.CollectPlatformDynamicPcds() +if not self._DynamicPcdList: +self.CollectPlatformDynamicPcds() return self._DynamicPcdList ## Generate Token Number for all PCD @cached_property def PcdTokenNumber(self): diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index 3be0670e36..cebc1f7187 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -175,12 +175,12 @@ class VpdInfoFile: EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath) Found = False if (TokenSpaceName, PcdTokenName) not in self._VpdInfo: -self._VpdInfo[(TokenSpaceName, PcdTokenName)] = [] -self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId, Offset, Value)) +self._VpdInfo[(TokenSpaceName, PcdTokenName)] = {} +self._VpdInfo[(TokenSpaceName, PcdTokenName)][(SkuId, Offset)] = Value for VpdObject in self._VpdArray: VpdObjectTokenCName = VpdObject.TokenCName for PcdItem in GlobalData.MixedPcd: if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: VpdObjectTokenCName = PcdItem[0] @@ -217,11 +217,11 @@ class VpdInfoFile: return None return self._VpdArray[vpd] def GetVpdInfo(self, arg): (PcdTokenName, TokenSpaceName) = arg -return self._VpdInfo.get((TokenSpaceName, PcdTokenName)) +return [(sku,offset,value) for (sku,offset),value in self._VpdInfo.get((TokenSpaceName, PcdTokenName)).items()] ## Call external BPDG tool to process VPD file # # @param ToolPath The string path name for BPDG tool # @param VpdFileName The string path name for VPD information guid.txt -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch V2] BaseTools: Fixed bugs in CopyDict function
From: "Feng, Bob C" V2: update commit log. This issue is introduced by commit bf9e636605188e291d33ab694ff1c5926b6f0800 V1: https://bugzilla.tianocore.org/show_bug.cgi?id=1387 Remove the CopyDict incorrect usage for non-dict input data. Add a check for CopyDict input. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Common/Misc.py| 2 ++ BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b063f064fb..6a22d01012 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2137,10 +2137,12 @@ def PackByteFormatGUID(Guid): # # @retval new dict or orderdict # def CopyDict(ori_dict): dict_type = ori_dict.__class__ +if dict_type not in (dict,OrderedDict): +return ori_dict new_dict = dict_type() for key in ori_dict: if isinstance(ori_dict[key],(dict,OrderedDict)): new_dict[key] = CopyDict(ori_dict[key]) else: diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b485c75a84..4543ae7dc0 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -972,11 +972,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in pcd.SkuInfoList: skuobj = pcd.SkuInfoList.get(skuid) if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict: PcdDefaultStoreSet = set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict) mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) -skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) +skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = skuobj.DefaultStoreDict[mindefaultstorename] return Pcds def RecoverCommandLinePcd(self): def UpdateCommandLineValue(pcd): if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], @@ -2767,11 +2767,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in PcdObj.SkuInfoList: skuobj = PcdObj.SkuInfoList[skuid] mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict)) for defaultstorename in DefaultStores: if defaultstorename not in skuobj.DefaultStoreDict: -skuobj.DefaultStoreDict[defaultstorename] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) +skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename] skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename] for skuname, skuid in SkuIds.items(): if skuname not in PcdObj.SkuInfoList: nextskuid = self.SkuIdMgr.GetNextSkuId(skuname) while nextskuid not in PcdObj.SkuInfoList: -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch V2] BaseTools: Fixed the build fail issue for cases
From: "Feng, Bob C" V2: update the commit log. This issue is introduced by the commit 72a1d77694d51914c0dd6aa97dbfa58634b0a4a5 V1: https://bugzilla.tianocore.org/show_bug.cgi?id=1386 1. There is no Pcd value assignment in Dsc file 2. There are duplicate Pcd filed assignment Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 +- BaseTools/Source/Python/Workspace/MetaFileParser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 008eee1a16..d02232b546 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -289,11 +289,11 @@ class StructurePcd(PcdClassObject): if DefaultStoreName not in self.SkuOverrideValues[SkuName]: self.SkuOverrideValues[SkuName][DefaultStoreName] = OrderedDict() if DimensionAttr not in self.SkuOverrideValues[SkuName][DefaultStoreName]: self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr] = collections.OrderedDict() if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr]: -del self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName][DimensionAttr] +del self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] = [Value.strip(), FileName, LineNo] return self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] def SetPcdMode (self, PcdMode): self.PcdMode = PcdMode diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 4bd52619a9..eaedba0c12 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1201,11 +1201,11 @@ class DscParser(MetaFileParser): else: self._ValueList = None return TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) self._CurrentPcdName = TokenList[0] -if TokenList[1].strip().startswith("{CODE"): +if len(TokenList) == 2 and TokenList[1].strip().startswith("{CODE"): self._PcdDataTypeCODE = True self._PcdCodeValue = TokenList[1].strip() if self._PcdDataTypeCODE: if self._CurrentLine.endswith(")}"): -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fixed the build fail issue for cases
https://bugzilla.tianocore.org/show_bug.cgi?id=1386 1. There is no Pcd value assignment in Dsc file 2. There are duplicate Pcd filed assignment Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 +- BaseTools/Source/Python/Workspace/MetaFileParser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 008eee1a16..d02232b546 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -289,11 +289,11 @@ class StructurePcd(PcdClassObject): if DefaultStoreName not in self.SkuOverrideValues[SkuName]: self.SkuOverrideValues[SkuName][DefaultStoreName] = OrderedDict() if DimensionAttr not in self.SkuOverrideValues[SkuName][DefaultStoreName]: self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr] = collections.OrderedDict() if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr]: -del self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName][DimensionAttr] +del self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] = [Value.strip(), FileName, LineNo] return self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldName] def SetPcdMode (self, PcdMode): self.PcdMode = PcdMode diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 4bd52619a9..eaedba0c12 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1201,11 +1201,11 @@ class DscParser(MetaFileParser): else: self._ValueList = None return TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) self._CurrentPcdName = TokenList[0] -if TokenList[1].strip().startswith("{CODE"): +if len(TokenList) == 2 and TokenList[1].strip().startswith("{CODE"): self._PcdDataTypeCODE = True self._PcdCodeValue = TokenList[1].strip() if self._PcdDataTypeCODE: if self._CurrentLine.endswith(")}"): -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fix PcdNvStoreDefaultValueBuffer Value.
https://bugzilla.tianocore.org/show_bug.cgi?id=1385 PcdNvStoreDefaultValueBuffer value is update to Vpd Info File, but it is not update into a internal cache. This patch is going to fix this incorrect value in that internal cache. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py| 16 BaseTools/Source/Python/Common/VpdInfoFile.py | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 12e53010a5..d646cd50ce 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1568,10 +1568,16 @@ class PlatformAutoGen(AutoGen): if VpdFile.GetCount() != 0: self.FixVpdOffset(VpdFile) self.FixVpdOffset(self.UpdateNVStoreMaxSize(VpdFile)) +PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"] +if PcdNvStoreDfBuffer: +PcdName,PcdGuid = PcdNvStoreDfBuffer[0].TokenCName, PcdNvStoreDfBuffer[0].TokenSpaceGuidCName +if (PcdName,PcdGuid) in VpdSkuMap: +DefaultSku = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT) +VpdSkuMap[(PcdName,PcdGuid)] = {DefaultSku.DefaultValue:[DefaultSku]} # Process VPD map file generated by third party BPDG tool if NeedProcessVpdMapFile: VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid) if os.path.exists(VpdMapFilePath): @@ -1885,19 +1891,21 @@ class PlatformAutoGen(AutoGen): @cached_property def NonDynamicPcdDict(self): return {(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):Pcd for Pcd in self.NonDynamicPcdList} ## Get list of non-dynamic PCDs -@cached_property +@property def NonDynamicPcdList(self): -self.CollectPlatformDynamicPcds() +if not self._NonDynamicPcdList: +self.CollectPlatformDynamicPcds() return self._NonDynamicPcdList ## Get list of dynamic PCDs -@cached_property +@property def DynamicPcdList(self): -self.CollectPlatformDynamicPcds() +if not self._DynamicPcdList: +self.CollectPlatformDynamicPcds() return self._DynamicPcdList ## Generate Token Number for all PCD @cached_property def PcdTokenNumber(self): diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index 3be0670e36..cebc1f7187 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -175,12 +175,12 @@ class VpdInfoFile: EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath) Found = False if (TokenSpaceName, PcdTokenName) not in self._VpdInfo: -self._VpdInfo[(TokenSpaceName, PcdTokenName)] = [] -self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId, Offset, Value)) +self._VpdInfo[(TokenSpaceName, PcdTokenName)] = {} +self._VpdInfo[(TokenSpaceName, PcdTokenName)][(SkuId, Offset)] = Value for VpdObject in self._VpdArray: VpdObjectTokenCName = VpdObject.TokenCName for PcdItem in GlobalData.MixedPcd: if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: VpdObjectTokenCName = PcdItem[0] @@ -217,11 +217,11 @@ class VpdInfoFile: return None return self._VpdArray[vpd] def GetVpdInfo(self, arg): (PcdTokenName, TokenSpaceName) = arg -return self._VpdInfo.get((TokenSpaceName, PcdTokenName)) +return [(sku,offset,value) for (sku,offset),value in self._VpdInfo.get((TokenSpaceName, PcdTokenName)).items()] ## Call external BPDG tool to process VPD file # # @param ToolPath The string path name for BPDG tool # @param VpdFileName The string path name for VPD information guid.txt -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fixed bugs in CopyDict function
https://bugzilla.tianocore.org/show_bug.cgi?id=1387 Remove the CopyDict incorrect usage for non-dict input data. Add a check for CopyDict input Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Common/Misc.py| 2 ++ BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b063f064fb..6a22d01012 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2137,10 +2137,12 @@ def PackByteFormatGUID(Guid): # # @retval new dict or orderdict # def CopyDict(ori_dict): dict_type = ori_dict.__class__ +if dict_type not in (dict,OrderedDict): +return ori_dict new_dict = dict_type() for key in ori_dict: if isinstance(ori_dict[key],(dict,OrderedDict)): new_dict[key] = CopyDict(ori_dict[key]) else: diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b485c75a84..4543ae7dc0 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -972,11 +972,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in pcd.SkuInfoList: skuobj = pcd.SkuInfoList.get(skuid) if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict: PcdDefaultStoreSet = set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict) mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) -skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) +skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = skuobj.DefaultStoreDict[mindefaultstorename] return Pcds def RecoverCommandLinePcd(self): def UpdateCommandLineValue(pcd): if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], @@ -2767,11 +2767,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in PcdObj.SkuInfoList: skuobj = PcdObj.SkuInfoList[skuid] mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict)) for defaultstorename in DefaultStores: if defaultstorename not in skuobj.DefaultStoreDict: -skuobj.DefaultStoreDict[defaultstorename] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) +skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename] skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename] for skuname, skuid in SkuIds.items(): if skuname not in PcdObj.SkuInfoList: nextskuid = self.SkuIdMgr.GetNextSkuId(skuname) while nextskuid not in PcdObj.SkuInfoList: -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Correct CCFLAG for PcdValueInit
https://bugzilla.tianocore.org/show_bug.cgi?id=1361 This patch is going to correct the CCFlag for building PcdValueInit Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 24 +-- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 11aa63fb26..c04f970c7d 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2184,20 +2184,20 @@ class DscBuildData(PlatformBuildClassObject): return False return True def ParseCCFlags(self, ccflag): ccflags = set() -flag = "" -for ch in ccflag: -if ch in (r"/", "-"): -if flag.strip(): -ccflags.add(flag.strip()) -flag = ch -else: -flag += ch -if flag.strip(): -ccflags.add(flag.strip()) +ccflaglist = ccflag.split(" ") +i = 0 +while i < len(ccflaglist): +item = ccflaglist[i].strip() +if item in (r"/D", r"/U","-D","-U"): +ccflags.add(" ".join((ccflaglist[i],ccflaglist[i+1]))) +i = i+1 +elif item.startswith((r"/D", r"/U","-D","-U")): +ccflags.add(item) +i +=1 return ccflags def GenerateByteArrayValue (self, StructuredPcds): # # Generate/Compile/Run C application to determine if there are any flexible array members # @@ -2318,11 +2318,11 @@ class DscBuildData(PlatformBuildClassObject): if Target == "*" or Target == self._Target: if Tag == "*" or Tag == self._Toolchain: if 'COMMON' not in BuildOptions: BuildOptions['COMMON'] = set() if Arch == "*": -BuildOptions['COMMON'].add(self.BuildOptions[Options]) +BuildOptions['COMMON']|= self.ParseCCFlags(self.BuildOptions[Options]) if Arch in self.SupArchList: if Arch not in BuildOptions: BuildOptions[Arch] = set() BuildOptions[Arch] |= self.ParseCCFlags(self.BuildOptions[Options]) @@ -2332,11 +2332,11 @@ class DscBuildData(PlatformBuildClassObject): BuildOptions['COMMON'] |= (ArchBuildOptions.values()[0]) elif len(ArchBuildOptions.keys()) > 1: CommonBuildOptions = reduce(lambda x,y: x&y, ArchBuildOptions.values()) BuildOptions['COMMON'] |= CommonBuildOptions ValueList = list(BuildOptions['COMMON']) -CC_FLAGS += " ".join([item for item in ValueList if item.startswith(('-D', '/D', '-U', '/U'))]) +CC_FLAGS += " ".join(ValueList) MakeApp += CC_FLAGS if sys.platform == "win32": MakeApp = MakeApp + PcdMakefileEnd MakeApp = MakeApp + AppTarget % ("""\tcopy $(APPLICATION) $(APPFILE) /y """) -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] Edk2: Update BaseTools Maintainers
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Yonghong Zhu Cc: Liming Gao --- Maintainers.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Maintainers.txt b/Maintainers.txt index 9a36f0232b..babed93284 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -77,12 +77,13 @@ M: Laszlo Ersek M: Ard Biesheuvel R: Julien Grall BaseTools W: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools -M: Yonghong Zhu +M: Bob Feng M: Liming Gao +R: Yonghong Zhu BeagleBoardPkg W: https://github.com/tianocore/tianocore.github.io/wiki/BeagleBoardPkg M: Leif Lindholm M: Ard Biesheuvel -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fix the problem using FILE_GUID override in .dsc
https://bugzilla.tianocore.org/show_bug.cgi?id=1330 This patch is going to fix the problem using FILE_GUID override in .dsc. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/GenFds/FdfParser.py | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 44cc8f63d0..2fbbad114c 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -22,11 +22,11 @@ from re import compile, DOTALL from string import hexdigits from uuid import UUID from Common.BuildToolError import * from Common import EdkLogger -from Common.Misc import PathClass, tdict +from Common.Misc import PathClass, tdict, ProcessDuplicatedInf from Common.StringUtils import NormPath, ReplaceMacro from Common import GlobalData from Common.Expression import * from Common.DataType import * from Common.MultipleWorkspace import MultipleWorkspace as mws @@ -2414,12 +2414,16 @@ class FdfParser: #do case sensitive check for file path ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate() if ErrorCode != 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo) -if not ffsInf.InfFileName in self.Profile.InfList: -self.Profile.InfList.append(ffsInf.InfFileName) +NewFileName = ffsInf.InfFileName +if ffsInf.OverrideGuid: +NewFileName = ProcessDuplicatedInf(PathClass(ffsInf.InfFileName,GenFdsGlobalVariable.WorkSpaceDir), ffsInf.OverrideGuid, GenFdsGlobalVariable.WorkSpaceDir).Path + +if not NewFileName in self.Profile.InfList: +self.Profile.InfList.append(NewFileName) FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber) self.Profile.InfFileLineList.append(FileLineTuple) if ffsInf.UseArch: if ffsInf.UseArch not in self.Profile.InfDict: self.Profile.InfDict[ffsInf.UseArch] = [ffsInf.InfFileName] @@ -4344,12 +4348,16 @@ class FdfParser: #check for file path ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate() if ErrorCode != 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo) -if not ffsInf.InfFileName in self.Profile.InfList: -self.Profile.InfList.append(ffsInf.InfFileName) +NewFileName = ffsInf.InfFileName +if ffsInf.OverrideGuid: +NewFileName = ProcessDuplicatedInf(PathClass(ffsInf.InfFileName,GenFdsGlobalVariable.WorkSpaceDir), ffsInf.OverrideGuid, GenFdsGlobalVariable.WorkSpaceDir).Path + +if not NewFileName in self.Profile.InfList: +self.Profile.InfList.append(NewFileName) FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber) self.Profile.InfFileLineList.append(FileLineTuple) if ffsInf.UseArch: if ffsInf.UseArch not in self.Profile.InfDict: self.Profile.InfDict[ffsInf.UseArch] = [ffsInf.InfFileName] -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch V2] BaseTools: Replace the sqlite database with list
https://bugzilla.tianocore.org/show_bug.cgi?id=1288 [V2] Optimize this patch so that it can be easy to review. This patch is just apply the change to original files while not create new similar files. [V1] This patch is one of build tool performance improvement series patches. This patch is going to use python list to store the parser data instead of using sqlite database. The replacement solution is as below: SQL insert: list.append() SQL select: list comprehension. for example: Select * from table where field = “something” -> [ item for item in table if item[3] == “something”] SQL update: python map function. for example: Update table set field1=newvalue where filed2 = “something”. -> map(lambda x: x[1] = newvalue, [item for item in table if item[2] == “something”]) SQL delete: list comprehension. With this change, We can save the time of interpreting SQL statement and the time of write database to file system Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/GenFds/GenFds.py | 3 +- .../Source/Python/Workspace/MetaDataTable.py | 93 ++- .../Source/Python/Workspace/MetaFileParser.py | 5 +- .../Source/Python/Workspace/MetaFileTable.py | 248 ++ .../Python/Workspace/WorkspaceDatabase.py | 131 + BaseTools/Source/Python/build/build.py| 27 +- 6 files changed, 186 insertions(+), 321 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 0c8091b798..4fd96706af 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -222,12 +222,11 @@ def main(): if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag """call Workspace build create database""" GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) -BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath) -BuildWorkSpace.InitDatabase() +BuildWorkSpace = WorkspaceDatabase() # # Get files real name in workspace dir # GlobalData.gAllFiles = DirCache(Workspace) diff --git a/BaseTools/Source/Python/Workspace/MetaDataTable.py b/BaseTools/Source/Python/Workspace/MetaDataTable.py index bd751eadfb..8becddbe08 100644 --- a/BaseTools/Source/Python/Workspace/MetaDataTable.py +++ b/BaseTools/Source/Python/Workspace/MetaDataTable.py @@ -37,84 +37,58 @@ class Table(object): _COLUMN_ = '' _ID_STEP_ = 1 _ID_MAX_ = 0x8000 _DUMMY_ = 0 -def __init__(self, Cursor, Name='', IdBase=0, Temporary=False): -self.Cur = Cursor +def __init__(self, Db, Name='', IdBase=0, Temporary=False): +self.Db = Db self.Table = Name self.IdBase = int(IdBase) self.ID = int(IdBase) self.Temporary = Temporary +self.Contents = [] def __str__(self): return self.Table ## Create table # # Create a table # def Create(self, NewTable=True): -if NewTable: -self.Drop() - -if self.Temporary: -SqlCommand = """create temp table IF NOT EXISTS %s (%s)""" % (self.Table, self._COLUMN_) -else: -SqlCommand = """create table IF NOT EXISTS %s (%s)""" % (self.Table, self._COLUMN_) -EdkLogger.debug(EdkLogger.DEBUG_8, SqlCommand) -self.Cur.execute(SqlCommand) +self.Db.CreateEmptyTable(self.Table) self.ID = self.GetId() ## Insert table # # Insert a record into a table # def Insert(self, *Args): self.ID = self.ID + self._ID_STEP_ if self.ID >= (self.IdBase + self._ID_MAX_): self.ID = self.IdBase + self._ID_STEP_ -Values = ", ".join(str(Arg) for Arg in Args) -SqlCommand = "insert into %s values(%s, %s)" % (self.Table, self.ID, Values) -EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand) -self.Cur.execute(SqlCommand) -return self.ID +row = [self.ID] +row.extend(Args) +self.Contents.append(row) -## Query table -# -# Query all records of the table -# -def Query(self): -SqlCommand = """select * from %s""" % self.Table -self.Cur.execute(SqlCommand) -for Rs in self.Cur: -EdkLogger.verbose(str(Rs)) -TotalCount = self.GetId() +return self.ID -## Drop a table -# -# Drop the table -# -def Drop(self): -SqlCommand = """drop table IF EXISTS %s""" % self.Table -self.Cur.
[edk2] [Patch] BaseTools: Optimize string concatenation
https://bugzilla.tianocore.org/show_bug.cgi?id=1288 This patch is one of build tool performance improvement series patches. This patch is going to use join function instead of string += string2 statement. Current code use string += string2 in a loop to combine a string. while creating a string list in a loop and using "".join(stringlist) after the loop will be much faster. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/AutoGen/StrGather.py | 39 +-- BaseTools/Source/Python/Common/Misc.py| 21 +- .../Source/Python/Workspace/InfBuildData.py | 4 +- .../Python/Workspace/WorkspaceCommon.py | 11 ++ 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index 361d499076..d34a9e9447 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -135,11 +135,11 @@ def AscToHexList(Ascii): # @param UniGenCFlag UniString is generated into AutoGen C file when it is set to True # # @retval Str: A string of .h file content # def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): -Str = '' +Str = [] ValueStartPtr = 60 Line = COMMENT_DEFINE_STR + ' ' + LANGUAGE_NAME_STRING_NAME + ' ' * (ValueStartPtr - len(DEFINE_STR + LANGUAGE_NAME_STRING_NAME)) + DecToHexStr(0, 4) + COMMENT_NOT_REFERENCED Str = WriteLine(Str, Line) Line = COMMENT_DEFINE_STR + ' ' + PRINTABLE_LANGUAGE_NAME_STRING_NAME + ' ' * (ValueStartPtr - len(DEFINE_STR + PRINTABLE_LANGUAGE_NAME_STRING_NAME)) + DecToHexStr(1, 4) + COMMENT_NOT_REFERENCED Str = WriteLine(Str, Line) @@ -164,16 +164,16 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED else: Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED UnusedStr = WriteLine(UnusedStr, Line) -Str = ''.join([Str, UnusedStr]) +Str.extend( UnusedStr) Str = WriteLine(Str, '') if IsCompatibleMode or UniGenCFlag: Str = WriteLine(Str, 'extern unsigned char ' + BaseName + 'Strings[];') -return Str +return "".join(Str) ## Create a complete .h file # # Create a complet .h file with file header and file content # @@ -185,11 +185,11 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): # @retval Str: A string of complete .h file # def CreateHFile(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): HFile = WriteLine('', CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag)) -return HFile +return "".join(HFile) ## Create a buffer to store all items in an array # # @param BinBuffer Buffer to contain Binary data. # @param Array: The array need to be formatted @@ -209,11 +209,11 @@ def CreateBinBuffer(BinBuffer, Array): # def CreateArrayItem(Array, Width = 16): MaxLength = Width Index = 0 Line = ' ' -ArrayItem = '' +ArrayItem = [] for Item in Array: if Index < MaxLength: Line = Line + Item + ', ' Index = Index + 1 @@ -221,11 +221,11 @@ def CreateArrayItem(Array, Width = 16): ArrayItem = WriteLine(ArrayItem, Line) Line = ' ' + Item + ', ' Index = 1 ArrayItem = Write(ArrayItem, Line.rstrip()) -return ArrayItem +return "".join(ArrayItem) ## CreateCFileStringValue # # Create a line with string value # @@ -236,11 +236,11 @@ def CreateArrayItem(Array, Width = 16): def CreateCFileStringValue(Value): Value = [StringBlockType] + Value Str = WriteLine('', CreateArrayItem(Value)) -return Str +return "".join(Str) ## GetFilteredLanguage # # apply get best language rules to the UNI language code list # @@ -438,11 +438,11 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniBinBuffer, # # Join package data # AllStr = Write(AllStr, Str) -return AllStr +return "".join(AllStr) ## Create end of .c file # # Create end of .c file # @@ -465,11 +465,11 @@ def CreateCFileEnd(): # def CreateCFile(BaseName, UniObjectClass, IsCompatibleMode, FilterInfo): CFile = '' CFile = WriteLine(CFile, CreateCFileContent(BaseName, UniObjectClass, IsCompatible
[edk2] [Patch] BaseTools: Add cache for UniToHexList
From: "bob.c.f...@intel.com" https://bugzilla.tianocore.org/show_bug.cgi?id=1288 This patch is one of build tool performance improvement series patches. This patch is going to add cache for UniToHexList function. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/AutoGen/UniClassObject.py | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 384f31b165..e889af9e82 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -43,10 +43,11 @@ LF = u'\u000A' NULL = u'\u' TAB = u'\t' BACK_SLASH_PLACEHOLDER = u'\u0006' gIncludePattern = re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", re.MULTILINE | re.UNICODE) +UniTokenCache = dict() ## Convert a python unicode string to a normal string # # Convert a python unicode string to a normal string # UniToStr(u'I am a string') is 'I am a string' @@ -66,16 +67,18 @@ def UniToStr(Uni): # @param Uni:The python unicode string # # @retval List: The formatted hex list # def UniToHexList(Uni): -List = [] -for Item in Uni: -Temp = '%04X' % ord(Item) -List.append('0x' + Temp[2:4]) -List.append('0x' + Temp[0:2]) -return List +if Uni not in UniTokenCache: +List = [] +for Item in Uni: +Temp = '%04X' % ord(Item) +List.append('0x' + Temp[2:4]) +List.append('0x' + Temp[0:2]) +UniTokenCache[Uni] = List +return UniTokenCache[Uni] LangConvTable = {'eng':'en', 'fra':'fr', \ 'aar':'aa', 'abk':'ab', 'ave':'ae', 'afr':'af', 'aka':'ak', 'amh':'am', \ 'arg':'an', 'ara':'ar', 'asm':'as', 'ava':'av', 'aym':'ay', 'aze':'az', \ 'bak':'ba', 'bel':'be', 'bul':'bg', 'bih':'bh', 'bis':'bi', 'bam':'bm', \ -- 2.19.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Customize deepcopy function.
https://bugzilla.tianocore.org/show_bug.cgi?id=1288 This patch is one of build tool performance improvement series patches. This patch is going to customize the deepcopy function for SkuClass, PcdClassObject and python dictionary. python deepcopy copy everything of a object, but for our current usage we just need to copy the data we care about recursively. By implementing __deepcopy__ for SkuClass, PcdClassObject, we can customize deepcopy function for them. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey --- BaseTools/Source/Python/Common/Expression.py | 4 +- BaseTools/Source/Python/Common/Misc.py| 16 ++ .../Python/CommonDataClass/CommonClass.py | 15 ++ .../Python/Workspace/BuildClassObject.py | 52 +++ .../Source/Python/Workspace/DscBuildData.py | 6 +-- 5 files changed, 88 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index a21ab5daa7..091c0f4296 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -15,11 +15,11 @@ from __future__ import print_function from __future__ import absolute_import from Common.GlobalData import * from CommonDataClass.Exceptions import BadExpression from CommonDataClass.Exceptions import WrnExpression -from .Misc import GuidStringToGuidStructureString, ParseFieldValue +from .Misc import GuidStringToGuidStructureString, ParseFieldValue,CopyDict import Common.EdkLogger as EdkLogger import copy from Common.DataType import * import sys from random import sample @@ -353,11 +353,11 @@ class ValueExpression(BaseExpression): raise BadExpression(ERR_EMPTY_EXPR) # # The symbol table including PCD and macro mapping # -self._Symb = copy.deepcopy(SymbolTable) +self._Symb = CopyDict(SymbolTable) self._Symb.update(self.LogicalOperators) self._Idx = 0 self._Len = len(self._Expr) self._Token = '' self._WarnExcept = None diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 3b8efb2e71..80236db160 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -39,10 +39,11 @@ from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws import uuid from CommonDataClass.Exceptions import BadExpression from Common.caching import cached_property import subprocess +from collections import OrderedDict ## Regular expression used to find out place holders in string template gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE) ## regular expressions for map file processing startPatternGeneral = re.compile("^Start[' ']+Length[' ']+Name[' ']+Class") @@ -2129,10 +2130,25 @@ def PackByteFormatGUID(Guid): Guid[8], Guid[9], Guid[10], ) +## DeepCopy dict/OrderedDict recusively +# +# @param ori_dicta nested dict or ordereddict +# +# @retval new dict or orderdict +# +def CopyDict(ori_dict): +dict_type = ori_dict.__class__ +new_dict = dict_type() +for key in ori_dict: +if isinstance(ori_dict[key],(dict,OrderedDict)): +new_dict[key] = CopyDict(ori_dict[key]) +else: +new_dict[key] = ori_dict[key] +return new_dict ## # # This acts like the main() function for the script, unless it is 'import'ed into another # script. # diff --git a/BaseTools/Source/Python/CommonDataClass/CommonClass.py b/BaseTools/Source/Python/CommonDataClass/CommonClass.py index a98cf8a7c5..336bb11671 100644 --- a/BaseTools/Source/Python/CommonDataClass/CommonClass.py +++ b/BaseTools/Source/Python/CommonDataClass/CommonClass.py @@ -78,5 +78,20 @@ class SkuInfoClass(object): 'VariableOffset = ' + str(self.VariableOffset) + "," + \ 'HiiDefaultValue = ' + str(self.HiiDefaultValue) + "," + \ 'VpdOffset = ' + str(self.VpdOffset) + "," + \ 'DefaultValue = ' + str(self.DefaultValue) + "," return Rtn + +def __deepcopy__(self,memo): +new_sku = SkuInfoClass() +new_sku.SkuIdName = self.SkuIdName +new_sku.SkuId = self.SkuId +new_sku.VariableName = self.VariableName +new_sku.VariableGuid = self.VariableGuid +new_sku.VariableGuidValue = self.VariableGuidValue +new_sku.VariableOffset = self.VariableOffset +new_sku.HiiDefaultValue = self.HiiDefaultValue +new_sku.VariableAttribute = self.VariableAttribute +new_sku.DefaultStoreDict = {ke
[edk2] [PATCH] BaseTools: Enable Pcd Array support.
From: "bob.c.f...@intel.com" https://bugzilla.tianocore.org/show_bug.cgi?id=1292 This patch is going to enable Array data type for PCD. 1. Support Pcd ARRAY as Structure PCD type including basic datatype array and structure array. For example: gStructuredPcdPkgTokenSpaceGuid.PcdTest|{0x0}|TEST[10]|0x00010080 gStructuredPcdPkgTokenSpaceGuid.PcdTest2|{0x0}|UINT8[10]|0x00010081 2. Support C CODE style value initialization in DEC/DSC. For example: gStructuredPcdPkgTokenSpaceGuid.PcdTest|{CODE({ {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0, 0, 0, 0}}, })} Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Common/Expression.py | 396 +- BaseTools/Source/Python/Common/Misc.py| 2 + .../Python/Workspace/BuildClassObject.py | 85 +++- .../Source/Python/Workspace/DecBuildData.py | 29 +- .../Source/Python/Workspace/DscBuildData.py | 384 +++-- .../Source/Python/Workspace/MetaFileParser.py | 86 +++- 6 files changed, 644 insertions(+), 338 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index a21ab5daa7..f6e245be70 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -820,221 +820,219 @@ class ValueExpressionEx(ValueExpression): def __call__(self, RealValue=False, Depth=0): PcdValue = self.PcdValue -try: -PcdValue = ValueExpression.__call__(self, RealValue, Depth) -if self.PcdType == TAB_VOID and (PcdValue.startswith("'") or PcdValue.startswith("L'")): -PcdValue, Size = ParseFieldValue(PcdValue) -PcdValueList = [] -for I in range(Size): -PcdValueList.append('0x%02X'%(PcdValue & 0xff)) -PcdValue = PcdValue >> 8 -PcdValue = '{' + ','.join(PcdValueList) + '}' -elif self.PcdType in TAB_PCD_NUMERIC_TYPES and (PcdValue.startswith("'") or \ - PcdValue.startswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')): -raise BadExpression -except WrnExpression as Value: -PcdValue = Value.result -except BadExpression as Value: -if self.PcdType in TAB_PCD_NUMERIC_TYPES: -PcdValue = PcdValue.strip() -if PcdValue.startswith('{') and PcdValue.endswith('}'): -PcdValue = SplitPcdValueString(PcdValue[1:-1]) -if ERR_STRING_CMP.split(':')[0] in Value.message: -raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value)) -if isinstance(PcdValue, type([])): -TmpValue = 0 -Size = 0 -ValueType = '' -for Item in PcdValue: -Item = Item.strip() -if Item.startswith(TAB_UINT8): -ItemSize = 1 -ValueType = TAB_UINT8 -elif Item.startswith(TAB_UINT16): -ItemSize = 2 -ValueType = TAB_UINT16 -elif Item.startswith(TAB_UINT32): -ItemSize = 4 -ValueType = TAB_UINT32 -elif Item.startswith(TAB_UINT64): -ItemSize = 8 -ValueType = TAB_UINT64 -elif Item[0] in {'"', "'", 'L'}: -ItemSize = 0 -ValueType = TAB_VOID -else: -ItemSize = 0 -ValueType = TAB_UINT8 -Item = ValueExpressionEx(Item, ValueType, self._Symb)(True) - -if ItemSize == 0: -try: -tmpValue = int(Item, 0) -if tmpValue > 255: -raise BadExpression("Byte array number %s should less than 0xFF." % Item) -except BadExpression as Value: -raise BadExpression(Value) -except ValueError: -pass -ItemValue, ItemSize = ParseFieldValue(Item) -else: -ItemValue = ParseFieldValue(Item)[0] - -if isinstance(ItemValue, type('')): -
[edk2] [Patch V3] BaseTools: Use common cc flag for building PcdValueInit.
V3: Update the patch to avoid "reduce" function fail. V2: Support to extract the common cc flag from a combined cc flag string. For example MSFT:*_*_IA32_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES /DDEF_IA32 MSFT:*_*_X64_CC_FLAGS = /DDEF_X64 /D DISABLE_NEW_DEPRECATED_INTERFACES V1: Use common cc flags for building PcdValueInit. The common cc flags include the cc flag which is under common arch and under all build arches. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 55 +++ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 6d596b2b54..11aa63fb26 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2182,10 +2182,23 @@ class DscBuildData(PlatformBuildClassObject): for key in OverrideValues: if OverrideValues[key]: return False return True +def ParseCCFlags(self, ccflag): +ccflags = set() +flag = "" +for ch in ccflag: +if ch in (r"/", "-"): +if flag.strip(): +ccflags.add(flag.strip()) +flag = ch +else: +flag += ch +if flag.strip(): +ccflags.add(flag.strip()) +return ccflags def GenerateByteArrayValue (self, StructuredPcds): # # Generate/Compile/Run C application to determine if there are any flexible array members # if not StructuredPcds: @@ -2298,38 +2311,32 @@ class DscBuildData(PlatformBuildClassObject): if Family and Family != self.ToolChainFamily: continue Target, Tag, Arch, Tool, Attr = Options[1].split("_") if Tool != 'CC': continue - +if Attr != "FLAGS": +continue if Target == "*" or Target == self._Target: if Tag == "*" or Tag == self._Toolchain: +if 'COMMON' not in BuildOptions: +BuildOptions['COMMON'] = set() if Arch == "*": -if Tool not in BuildOptions: -BuildOptions[Tool] = OrderedDict() -if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='): -BuildOptions[Tool][Attr] = self.BuildOptions[Options] -else: -# append options for the same tool except PATH -if Attr != 'PATH': -BuildOptions[Tool][Attr] += " " + self.BuildOptions[Options] -else: -BuildOptions[Tool][Attr] = self.BuildOptions[Options] +BuildOptions['COMMON'].add(self.BuildOptions[Options]) +if Arch in self.SupArchList: +if Arch not in BuildOptions: +BuildOptions[Arch] = set() +BuildOptions[Arch] |= self.ParseCCFlags(self.BuildOptions[Options]) + if BuildOptions: -for Tool in BuildOptions: -for Attr in BuildOptions[Tool]: -if Attr == "FLAGS": -Value = BuildOptions[Tool][Attr] -ValueList = Value.split() -if ValueList: -for Id, Item in enumerate(ValueList): -if Item in ['-D', '/D', '-U', '/U']: -CC_FLAGS += ' ' + Item -if Id + 1 < len(ValueList): -CC_FLAGS += ' ' + ValueList[Id + 1] -elif Item.startswith(('-D', '/D', '-U', '/U')): -CC_FLAGS += ' ' + Item +ArchBuildOptions = {arch:flags for arch,flags in BuildOptions.items() if arch != 'COMMON'} +if len(ArchBuildOptions.keys()) == 1: +BuildOptions['COMMON'] |= (ArchBuildOptions.values()[0]) +elif len(ArchBuildOptions.keys()) > 1: +CommonBuildOptions = reduce(lambda x,y: x&y, ArchBuildOptions.values()) +BuildOptions['COMMON'] |= CommonBuildOptions +ValueList = list(BuildOptions['COMMON']) +CC_FLAGS += " ".join([item for item in ValueList if item.startswith(('-D', '/D', '-U', '/U'))]) MakeApp += CC_FLAGS if sys.platform == "win32": MakeApp = MakeApp + PcdMakefileEnd MakeApp = MakeApp + AppTarget % ("""\tcopy $(APPLICATION) $(APPFILE) /y """) -- 2.18.0.windows.1 __
[edk2] [Patch V2] BaseTools: Use common cc flag for building PcdValueInit.
V2: Support to extract the common cc flag from a combined cc flag string. For example MSFT:*_*_IA32_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES /DDEF_IA32 MSFT:*_*_X64_CC_FLAGS = /DDEF_X64 /D DISABLE_NEW_DEPRECATED_INTERFACES V1: Use common cc flags for building pcdinitvalue. The common cc flags include the cc flag which is under common arch and under all build arches. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 55 +++ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 6d596b2b54..0173323b36 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2182,10 +2182,23 @@ class DscBuildData(PlatformBuildClassObject): for key in OverrideValues: if OverrideValues[key]: return False return True +def ParseCCFlags(self, ccflag): +ccflags = set() +flag = "" +for ch in ccflag: +if ch in (r"/", "-"): +if flag.strip(): +ccflags.add(flag.strip()) +flag = ch +else: +flag += ch +if flag.strip(): +ccflags.add(flag.strip()) +return ccflags def GenerateByteArrayValue (self, StructuredPcds): # # Generate/Compile/Run C application to determine if there are any flexible array members # if not StructuredPcds: @@ -2298,38 +2311,32 @@ class DscBuildData(PlatformBuildClassObject): if Family and Family != self.ToolChainFamily: continue Target, Tag, Arch, Tool, Attr = Options[1].split("_") if Tool != 'CC': continue - +if Attr != "FLAGS": +continue if Target == "*" or Target == self._Target: if Tag == "*" or Tag == self._Toolchain: +if 'COMMON' not in BuildOptions: +BuildOptions['COMMON'] = set() if Arch == "*": -if Tool not in BuildOptions: -BuildOptions[Tool] = OrderedDict() -if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='): -BuildOptions[Tool][Attr] = self.BuildOptions[Options] -else: -# append options for the same tool except PATH -if Attr != 'PATH': -BuildOptions[Tool][Attr] += " " + self.BuildOptions[Options] -else: -BuildOptions[Tool][Attr] = self.BuildOptions[Options] +BuildOptions['COMMON'].add(self.BuildOptions[Options]) +if Arch in self.SupArchList: +if Arch not in BuildOptions: +BuildOptions[Arch] = set() +BuildOptions[Arch] |= self.ParseCCFlags(self.BuildOptions[Options]) + if BuildOptions: -for Tool in BuildOptions: -for Attr in BuildOptions[Tool]: -if Attr == "FLAGS": -Value = BuildOptions[Tool][Attr] -ValueList = Value.split() -if ValueList: -for Id, Item in enumerate(ValueList): -if Item in ['-D', '/D', '-U', '/U']: -CC_FLAGS += ' ' + Item -if Id + 1 < len(ValueList): -CC_FLAGS += ' ' + ValueList[Id + 1] -elif Item.startswith(('-D', '/D', '-U', '/U')): -CC_FLAGS += ' ' + Item +ArchBuildOptions = {arch:flags for arch,flags in BuildOptions.items() if arch != 'COMMON'} +if len(ArchBuildOptions.keys()) == 1: +BuildOptions['COMMON'] |= (ArchBuildOptions.values()[0]) +else: +CommonBuildOptions = reduce(lambda x,y: x&y, ArchBuildOptions.values()) +BuildOptions['COMMON'] |= CommonBuildOptions +ValueList = list(BuildOptions['COMMON']) +CC_FLAGS += " ".join([item for item in ValueList if item.startswith(('-D', '/D', '-U', '/U'))]) MakeApp += CC_FLAGS if sys.platform == "win32": MakeApp = MakeApp + PcdMakefileEnd MakeApp = MakeApp + AppTarget % ("""\tcopy $(APPLICATION) $(APPFILE) /y """) -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailma
[edk2] [Patch] BaseTools: Use common cc flag for building PcdValueInit.
Use common cc flags for building PcdValueInit. The common cc flags include the cc flag which is under common Arch and under all build Arches. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 48 +-- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 6d596b2b54..4807fff489 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2298,38 +2298,38 @@ class DscBuildData(PlatformBuildClassObject): if Family and Family != self.ToolChainFamily: continue Target, Tag, Arch, Tool, Attr = Options[1].split("_") if Tool != 'CC': continue - +if Attr != "FLAGS": +continue if Target == "*" or Target == self._Target: if Tag == "*" or Tag == self._Toolchain: +if 'COMMON' not in BuildOptions: +BuildOptions['COMMON'] = set() if Arch == "*": -if Tool not in BuildOptions: -BuildOptions[Tool] = OrderedDict() -if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='): -BuildOptions[Tool][Attr] = self.BuildOptions[Options] -else: -# append options for the same tool except PATH -if Attr != 'PATH': -BuildOptions[Tool][Attr] += " " + self.BuildOptions[Options] -else: -BuildOptions[Tool][Attr] = self.BuildOptions[Options] +BuildOptions['COMMON'].add(self.BuildOptions[Options]) +if Arch in self.SupArchList: +if Arch not in BuildOptions: +BuildOptions[Arch] = set() +BuildOptions[Arch].add(self.BuildOptions[Options]) + if BuildOptions: -for Tool in BuildOptions: -for Attr in BuildOptions[Tool]: -if Attr == "FLAGS": -Value = BuildOptions[Tool][Attr] -ValueList = Value.split() -if ValueList: -for Id, Item in enumerate(ValueList): -if Item in ['-D', '/D', '-U', '/U']: -CC_FLAGS += ' ' + Item -if Id + 1 < len(ValueList): -CC_FLAGS += ' ' + ValueList[Id + 1] -elif Item.startswith(('-D', '/D', '-U', '/U')): -CC_FLAGS += ' ' + Item +ArchBuildOptions = {arch:flags for arch,flags in BuildOptions.items() if arch != 'COMMON'} +if len(ArchBuildOptions.keys()) == 1: +BuildOptions['COMMON'] |= (ArchBuildOptions.values()[0]) +else: +CommonBuildOptions = reduce(lambda x,y: x&y, ArchBuildOptions.values()) +BuildOptions['COMMON'] |= CommonBuildOptions +ValueList = list(BuildOptions['COMMON']) +for Id, Item in enumerate(ValueList): +if Item in ['-D', '/D', '-U', '/U']: +CC_FLAGS += ' ' + Item +if Id + 1 < len(ValueList): +CC_FLAGS += ' ' + ValueList[Id + 1] +elif Item.startswith(('-D', '/D', '-U', '/U')): +CC_FLAGS += ' ' + Item MakeApp += CC_FLAGS if sys.platform == "win32": MakeApp = MakeApp + PcdMakefileEnd MakeApp = MakeApp + AppTarget % ("""\tcopy $(APPLICATION) $(APPFILE) /y """) -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Add checking to EFI variable attribute.
This patch is going to add a check that only if the attribute of a EFI variable include 'NV', it will be added into PcdNvStoreDefaultValueBuffer. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 9c3759c0f5..a1c8dc7efb 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1163,10 +1163,12 @@ class PlatformAutoGen(AutoGen): Sku = Pcd.SkuInfoList[SkuName] SkuId = Sku.SkuId if SkuId is None or SkuId == '': continue if len(Sku.VariableName) > 0: +if Sku.VariableAttribute and 'NV' not in Sku.VariableAttribute: +continue VariableGuidStructure = Sku.VariableGuidValue VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure) for StorageName in Sku.DefaultStoreDict: VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName] if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES else StringToArray(Sku.DefaultStoreDict[StorageName]), Pcd.DatumType, Pcd.CustomAttribute['DscPosition'], Pcd.CustomAttribute.get('IsStru',False))) Index += 1 -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Filter out unused structure pcds
V2: Fixed the issue that V1 adds new check to the Pcds in the platform unused library INF files. It breaks the existing platform. V1: The current code handle all the structure pcds even if there is no module or library use them. This patch is going to filter out the unused structure pcds. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 22 +++ .../Source/Python/Workspace/InfBuildData.py | 9 .../Python/Workspace/WorkspaceDatabase.py | 5 - 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 6d596b2b54..5d25d20639 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1467,10 +1467,11 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} else: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} S_pcd_set[Pcd] = str_pcd_obj_str +self.FilterStrcturePcd(S_pcd_set) if S_pcd_set: GlobalData.gStructurePcd[self.Arch] = S_pcd_set for stru_pcd in S_pcd_set.values(): for skuid in SkuIds: if skuid in stru_pcd.SkuOverrideValues: @@ -1562,10 +1563,31 @@ class DscBuildData(PlatformBuildClassObject): elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: del pcd.SkuInfoList[TAB_COMMON] map(self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType]) return Pcds +@cached_property +def PlatformUsedPcds(self): +FdfInfList = [] +if GlobalData.gFdfParser: +FdfInfList = GlobalData.gFdfParser.Profile.InfList +FdfModuleList = [PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch) for Inf in FdfInfList] +AllModulePcds = set() +ModuleSet = set(self._Modules.keys() + FdfModuleList) +for ModuleFile in ModuleSet: +ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain] +AllModulePcds = AllModulePcds | ModuleData.PcdsName +for ModuleFile in self.LibraryInstances: +ModuleData = self._Bdb.CreateBuildObject(ModuleFile, self._Arch, self._Target, self._Toolchain) +AllModulePcds = AllModulePcds | ModuleData.PcdsName +return AllModulePcds + +#Filter the StrucutrePcd that is not used by any module in dsc file and fdf file. +def FilterStrcturePcd(self, S_pcd_set): +UnusedStruPcds = set(S_pcd_set.keys()) - self.PlatformUsedPcds +for (Token, TokenSpaceGuid) in UnusedStruPcds: +del S_pcd_set[(Token, TokenSpaceGuid)] ## Retrieve non-dynamic PCD settings # # @param TypePCD type # diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index d615cccdf7..99bbecfd1f 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -792,10 +792,19 @@ class InfBuildData(ModuleBuildClassObject): RetVal.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG)) RetVal.update(self._GetPcd(MODEL_PCD_DYNAMIC)) RetVal.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX)) return RetVal +@cached_property +def PcdsName(self): +PcdsName = set() +for Type in (MODEL_PCD_FIXED_AT_BUILD,MODEL_PCD_PATCHABLE_IN_MODULE,MODEL_PCD_FEATURE_FLAG,MODEL_PCD_DYNAMIC,MODEL_PCD_DYNAMIC_EX): +RecordList = self._RawData[Type, self._Arch, self._Platform] +for TokenSpaceGuid, PcdCName, _, _, _, _, _ in RecordList: +PcdsName.add((PcdCName, TokenSpaceGuid)) +return PcdsName + ## Retrieve build options specific to this module @cached_property def BuildOptions(self): if self._BuildOptions is None: self._BuildOptions = OrderedDict() diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 3bb287b8b2..c41922f6f9 100644 --- a/BaseTools/Source/Python/Workspace/Works
[edk2] [Patch] BaseTools: Rollback Filter out unused structure pcds
This reverts commit 51d17bb7b0da0d9c9e91c226f1982d7020f43795. commit 51d17bb7b0da0d9c9e91c226f1982d7020f43795 adds new check of Pcds in the platform unused library INF files. It breaks the existing platform. To avoid the impact, roll back this change first. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob C Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 19 --- 1 file changed, 19 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 9882a36df8..6d596b2b54 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -280,11 +280,10 @@ class DscBuildData(PlatformBuildClassObject): self._RFCLanguages = None self._ISOLanguages = None self._VpdToolGuid = None self._MacroDict = None self.DefaultStores = None -self.UsedStructurePcd = None ## handle Override Path of Module def _HandleOverridePath(self): RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] for Record in RecordList: @@ -1468,11 +1467,10 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} else: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} S_pcd_set[Pcd] = str_pcd_obj_str -self.FilterStrcturePcd(S_pcd_set) if S_pcd_set: GlobalData.gStructurePcd[self.Arch] = S_pcd_set for stru_pcd in S_pcd_set.values(): for skuid in SkuIds: if skuid in stru_pcd.SkuOverrideValues: @@ -1564,27 +1562,10 @@ class DscBuildData(PlatformBuildClassObject): elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: del pcd.SkuInfoList[TAB_COMMON] map(self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType]) return Pcds -#Filter the StrucutrePcd that is not used by any module in dsc file and fdf file. -def FilterStrcturePcd(self, S_pcd_set): -if not self.UsedStructurePcd: -FdfInfList = [] -if GlobalData.gFdfParser: -FdfInfList = GlobalData.gFdfParser.Profile.InfList -FdfModuleList = [PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch) for Inf in FdfInfList] -AllModulePcds = set() -ModuleSet = set(self._Modules.keys() + self.LibraryInstances + FdfModuleList) -for ModuleFile in ModuleSet: -ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain] -AllModulePcds = AllModulePcds | set(ModuleData.Pcds.keys()) - -self.UsedStructurePcd = AllModulePcds -UnusedStruPcds = set(S_pcd_set.keys()) - self.UsedStructurePcd -for (Token, TokenSpaceGuid) in UnusedStruPcds: -del S_pcd_set[(Token, TokenSpaceGuid)] ## Retrieve non-dynamic PCD settings # # @param TypePCD type # -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Move PcdValueInit to platform build folder
PcdValueInit tool is platform scope. It should be generated into Platform output directory. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob C Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 25 +-- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 17e6f62cac..6fe03ff91a 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -84,10 +84,16 @@ PcdMakefileEnd = ''' LIBS = $(LIB_PATH)\Common.lib !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app ''' +AppTarget = ''' +all: $(APPFILE) +$(APPFILE): $(OBJECTS) +%s +''' + PcdGccMakefile = ''' MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C LIBS = -lCommon ''' @@ -2253,14 +2259,14 @@ class DscBuildData(PlatformBuildClassObject): CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName) SaveFileOnChange(CAppBaseFileName + '.c', CApp, False) MakeApp = PcdMakefileHeader if sys.platform == "win32": -MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = ' +MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = ' else: MakeApp = MakeApp + PcdGccMakefile -MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \ +MakeApp = MakeApp + 'APPFILE = %s/%s\n' % (self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \ 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +=' IncSearchList = [] PlatformInc = OrderedDict() for Cache in self._Bdb._CACHE_.values(): @@ -2332,10 +2338,13 @@ class DscBuildData(PlatformBuildClassObject): CC_FLAGS += ' ' + Item MakeApp += CC_FLAGS if sys.platform == "win32": MakeApp = MakeApp + PcdMakefileEnd +MakeApp = MakeApp + AppTarget % ("""\tcopy $(APPLICATION) $(APPFILE) /y """) +else: +MakeApp = MakeApp + AppTarget % ("""\tcp $(APPLICATION) $(APPFILE) """) MakeApp = MakeApp + '\n' IncludeFileFullPaths = [] for includefile in IncludeFiles: for includepath in IncSearchList: includefullpath = os.path.join(str(includepath), includefile) @@ -2355,25 +2364,25 @@ class DscBuildData(PlatformBuildClassObject): InputValueFile = os.path.join(self.OutputPath, 'Input.txt') OutputValueFile = os.path.join(self.OutputPath, 'Output.txt') SaveFileOnChange(InputValueFile, InitByteValue, False) -PcdValueInitExe = PcdValueInitName +Dest_PcdValueInitExe = PcdValueInitName if not sys.platform == "win32": -PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Source', 'C', 'bin', PcdValueInitName) +Dest_PcdValueInitExe = os.path.join(self.OutputPath, PcdValueInitName) else: -PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Bin', 'Win32', PcdValueInitName) +".exe" - +Dest_PcdValueInitExe = os.path.join(self.OutputPath, PcdValueInitName) +".exe" Messages = '' if sys.platform == "win32": MakeCommand = 'nmake -f %s' % (MakeFileName) returncode, StdOut, StdErr = DscBuildData.ExecuteCommand (MakeCommand) Messages = StdOut else: MakeCommand = 'make -f %s' % (MakeFileName) returncode, StdOut, StdErr = DscBuildData.ExecuteCommand (MakeCommand) Messages = StdErr + Messages = Messages.split('\n') MessageGroup = [] if returncode != 0: CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName) File = open (CAppBaseFileName + '.c', 'r') @@ -2414,12 +2423,12 @@ class DscBuildData(PlatformBuildClassObject): if MessageGroup: EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".join(MessageGroup) ) else: EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % MakeCommand) -if DscBuildData.NeedUpdateOutput(OutputValueFile, PcdValueInitExe, InputValueFile): -Command = PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, OutputValueFile) +if DscBuildData.NeedUpdateOutput(OutputValueFile, Dest_PcdValueInitExe, InputValueFile): +Command = Dest_PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, OutputValueFile)
[edk2] [Patch] BaseTools: Fixed a key error code bug.
There is a code bug that used a wrong key. This Patch is to correct it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index f2146a7790..87d6107035 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -567,12 +567,12 @@ class WorkspaceAutoGen(AutoGen): if (Name, Guid) not in DecPcds: EdkLogger.error( 'build', PARSER_ERROR, "PCD (%s.%s) used in FDF is not declared in DEC files." % (Guid, Name), -File = self.FdfProfile.PcdFileLineDict[Name, Guid][0], -Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1] +File = self.FdfProfile.PcdFileLineDict[Name, Guid,Fileds][0], +Line = self.FdfProfile.PcdFileLineDict[Name, Guid,Fileds][1] ) else: # Check whether Dynamic or DynamicEx PCD used in FDF file. If used, build break and give a error message. if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \ or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in DecPcdsKey \ @@ -581,12 +581,12 @@ class WorkspaceAutoGen(AutoGen): elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or (Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey: EdkLogger.error( 'build', PARSER_ERROR, "Using Dynamic or DynamicEx type of PCD [%s.%s] in FDF file is not allowed." % (Guid, Name), -File = self.FdfProfile.PcdFileLineDict[Name, Guid][0], -Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1] +File = self.FdfProfile.PcdFileLineDict[Name, Guid,Fileds][0], +Line = self.FdfProfile.PcdFileLineDict[Name, Guid,Fileds][1] ) Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch) # # Explicitly collect platform's dynamic PCDs -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Filter out unused structure pcds
The current code handle all the structure pcds even if there is no module or library use them. This patch is going to filter out the unused structure pcds. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 19 +++ 1 file changed, 19 insertions(+) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index e481ea4f64..31bce16d15 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -274,10 +274,11 @@ class DscBuildData(PlatformBuildClassObject): self._RFCLanguages = None self._ISOLanguages = None self._VpdToolGuid = None self._MacroDict = None self.DefaultStores = None +self.UsedStructurePcd = None ## handle Override Path of Module def _HandleOverridePath(self): RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] for Record in RecordList: @@ -1476,10 +1477,11 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} else: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} S_pcd_set[Pcd] = str_pcd_obj_str +self.FilterStrcturePcd(S_pcd_set) if S_pcd_set: GlobalData.gStructurePcd[self.Arch] = S_pcd_set for stru_pcd in S_pcd_set.values(): for skuid in SkuIds: if skuid in stru_pcd.SkuOverrideValues: @@ -1571,10 +1573,27 @@ class DscBuildData(PlatformBuildClassObject): elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: del pcd.SkuInfoList[TAB_COMMON] map(self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType]) return Pcds +#Filter the StrucutrePcd that is not used by any module in dsc file and fdf file. +def FilterStrcturePcd(self, S_pcd_set): +if not self.UsedStructurePcd: +FdfInfList = [] +if GlobalData.gFdfParser: +FdfInfList = GlobalData.gFdfParser.Profile.InfList +FdfModuleList = [PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch) for Inf in FdfInfList] +AllModulePcds = set() +ModuleSet = set(self._Modules.keys() + self.LibraryInstances + FdfModuleList) +for ModuleFile in ModuleSet: +ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain] +AllModulePcds = AllModulePcds | set(ModuleData.Pcds.keys()) + +self.UsedStructurePcd = AllModulePcds +UnusedStruPcds = set(S_pcd_set.keys()) - self.UsedStructurePcd +for (Token, TokenSpaceGuid) in UnusedStruPcds: +del S_pcd_set[(Token, TokenSpaceGuid)] ## Retrieve non-dynamic PCD settings # # @param TypePCD type # -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Remove Arch specific build options for PcdValueInit tool.
PcdValueInit tool is Arch independent, the Arch specific build options should be removed from PcdValueInit makefile. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob C Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 19ac71ac09..47f5033953 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2344,11 +2344,11 @@ class DscBuildData(PlatformBuildClassObject): if Tool != 'CC': continue if Target == "*" or Target == self._Target: if Tag == "*" or Tag == self._Toolchain: -if Arch == "*" or Arch == self.Arch: +if Arch == "*": if Tool not in BuildOptions: BuildOptions[Tool] = OrderedDict() if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='): BuildOptions[Tool][Attr] = self.BuildOptions[Options] else: -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Replace dict with OrderedDict.
Replace dict with OrderedDict for PCD so that the pcd list has same order. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/GenFds/FdfParser.py | 7 +++-- .../Python/Workspace/BuildClassObject.py | 11 --- .../Source/Python/Workspace/DscBuildData.py | 31 +++ 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 8de0b48ff6..7d1cd0d133 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -62,10 +62,11 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws import Common.LongFilePathOs as os from Common.LongFilePathSupport import OpenLongFilePath as open from .Capsule import EFI_CERT_TYPE_PKCS7_GUID from .Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID from Common.RangeExpression import RangeExpression +from collections import OrderedDict ##define T_CHAR_SPACE' ' ##define T_CHAR_NULL '\0' ##define T_CHAR_CR '\r' ##define T_CHAR_TAB '\t' @@ -225,12 +226,12 @@ class FileProfile : except: EdkLogger.error("FdfParser", FILE_OPEN_FAILURE, ExtraData=FileName) self.FileName = FileName -self.PcdDict = {} -self.PcdLocalDict = {} +self.PcdDict = OrderedDict() +self.PcdLocalDict = OrderedDict() self.InfList = [] self.InfDict = {'ArchTBD':[]} # ECC will use this Dict and List information self.PcdFileLineDict = {} self.InfFileLineList = [] @@ -272,11 +273,11 @@ class FdfParser: # Used to section info self.__CurSection = [] # Key: [section name, UI name, arch] # Value: {MACRO_NAME : MACRO_VALUE} self.__MacroDict = tdict(True, 3) -self.__PcdDict = {} +self.__PcdDict = OrderedDict() self.__WipeOffArea = [] if GenFdsGlobalVariable.WorkSpaceDir == '': GenFdsGlobalVariable.WorkSpaceDir = os.getenv("WORKSPACE") diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index e6f5650279..4aaf8da408 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -12,10 +12,11 @@ # from Common.DataType import * import collections import re +from collections import OrderedDict StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') ArrayIndex = re.compile("\[\s*\d{0,1}\s*\]") ## PcdClassObject # # This Class is used for PcdObject @@ -41,29 +42,29 @@ ArrayIndex = re.compile("\[\s*\d{0,1}\s*\]") # @var SkuInfoList: To store value for SkuInfoList # @var IsOverrided: To store value for IsOverrided # @var Phase:To store value for Phase, default is "DXE" # class PcdClassObject(object): -def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False, GuidValue = None, validateranges = [], validlists = [], expressions = [], IsDsc = False): +def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = None, IsOverrided = False, GuidValue = None, validateranges = None, validlists = None, expressions = None, IsDsc = False): self.TokenCName = Name self.TokenSpaceGuidCName = Guid self.TokenSpaceGuidValue = GuidValue self.Type = Type self._DatumType = DatumType self.DefaultValue = Value self.TokenValue = Token self.MaxDatumSize = MaxDatumSize self.MaxSizeUserSet = None -self.SkuInfoList = SkuInfoList +self.SkuInfoList = SkuInfoList if SkuInfoList is not None else OrderedDict() self.Phase = "DXE" self.Pending = False self.IsOverrided = IsOverrided self.IsFromBinaryInf = False self.IsFromDsc = False -self.validateranges = validateranges -self.validlists = validlists -self.expressions = expressions +self.validateranges = validateranges if validateranges is not None else [] +self.validlists = validlists if validlists is not None else [] +self.expressions = expressions if expressions is not None else [] self.DscDefaultValue = None self.DscRawValue = None if IsDsc: self.DscDefaultValue = Value self.PcdValueFromComm = "" diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index ed32dd0343..7b3f3bf23e 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1234,
[edk2] [PATCH] BaseTool: Support different PCDs to refer to the same EFI variable.
From: "bob.c.f...@intel.com" If Structure PCD and Normal Pcd refer to the same EFI variable, do EFI variable merge, otherwise, do EFI variable combination. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py| 3 +- BaseTools/Source/Python/AutoGen/GenVar.py | 71 ++- .../Python/Workspace/BuildClassObject.py | 2 + .../Source/Python/Workspace/DscBuildData.py | 2 + 4 files changed, 60 insertions(+), 18 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 4ce0489446..064b85fafe 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1213,7 +1213,7 @@ class PlatformAutoGen(AutoGen): VariableGuidStructure = Sku.VariableGuidValue VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure) for StorageName in Sku.DefaultStoreDict: -VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType)) +VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType, Pcd.CustomAttribute['DscPosition'], Pcd.CustomAttribute.get('IsStru',False))) Index += 1 return VariableInfo @@ -2112,6 +2112,7 @@ class PlatformAutoGen(AutoGen): ToPcd.validateranges = FromPcd.validateranges ToPcd.validlists = FromPcd.validlists ToPcd.expressions = FromPcd.expressions +ToPcd.CustomAttribute = FromPcd.CustomAttribute if FromPcd is not None and ToPcd.DatumType == TAB_VOID and not ToPcd.MaxDatumSize: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \ diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 75d455b407..036f00e2bb 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -22,7 +22,7 @@ from Common.Misc import * import collections import Common.DataType as DataType -var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type") +var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type,PcdDscLine,StructurePcd") NvStorageHeaderSize = 28 VariableHeaderSize = 32 @@ -56,6 +56,51 @@ class VariableMgr(object): value_str += ",".join(default_var_bin_strip) value_str += "}" return value_str +def Do_combine(self,sku_var_info_offset_list): +newvalue = {} +for item in sku_var_info_offset_list: +data_type = item.data_type +value_list = item.default_value.strip("{").strip("}").split(",") +if data_type in DataType.TAB_PCD_NUMERIC_TYPES: +data_flag = DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]] +data = value_list[0] +value_list = [] +for data_byte in pack(data_flag, int(data, 16) if data.upper().startswith('0X') else int(data)): +value_list.append(hex(unpack("B", data_byte)[0])) +newvalue[int(item.var_offset, 16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list +try: +newvaluestr = "{" + ",".join(VariableMgr.assemble_variable(newvalue)) +"}" +except: +EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join(item.pcdname for item in sku_var_info_offset_list))) +return newvaluestr +def Do_Merge(self,sku_var_info_offset_list): +StructrurePcds = sorted([item for item in sku_var_info_offset_list if item.StructurePcd], key = lambda x: x.PcdDscLine, reverse =True ) +Base = StructrurePcds[0] +BaseValue = Base.default_value.strip("{").strip("}").split(",") +Override = [item for item in sku_var_info_offset_list if not item.StructurePcd and item.PcdDscLine > Base.PcdDscLine] +newvalue = {} +for item in Override: +data_type = item.data_type +value_list = item.default_value.strip("{").strip("}").split(",") +if data_type in DataType.TAB_PCD_NUMERIC_TYPES: +data_flag = DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]] +data = value_list[0] +
[edk2] [Patch] BaseTool: Variable Merge.
If Structure PCD and Normal Pcd refer to the same variable, do variable merge. Enhance error message. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 3 +- BaseTools/Source/Python/AutoGen/GenVar.py | 71 -- .../Source/Python/Workspace/BuildClassObject.py| 2 + BaseTools/Source/Python/Workspace/DscBuildData.py | 3 +- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 95370d1821..d1bd1b1d4c 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1211,11 +1211,11 @@ class PlatformAutoGen(AutoGen): continue if len(Sku.VariableName) > 0: VariableGuidStructure = Sku.VariableGuidValue VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure) for StorageName in Sku.DefaultStoreDict: -VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType)) +VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType, Pcd.CustomAttribute['DscPosition'], Pcd.CustomAttribute.get('IsStru',False))) Index += 1 return VariableInfo def UpdateNVStoreMaxSize(self, OrgVpdFile): if self.VariableInfo: @@ -2104,10 +2104,11 @@ class PlatformAutoGen(AutoGen): EdkLogger.error('build', FORMAT_INVALID, Cause, File=self.MetaFile, ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName)) ToPcd.validateranges = FromPcd.validateranges ToPcd.validlists = FromPcd.validlists ToPcd.expressions = FromPcd.expressions +ToPcd.CustomAttribute = FromPcd.CustomAttribute if FromPcd is not None and ToPcd.DatumType == TAB_VOID and not ToPcd.MaxDatumSize: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \ % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value = ToPcd.DefaultValue diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 75d455b407..036f00e2bb 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -20,11 +20,11 @@ import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections import Common.DataType as DataType -var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type") +var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type,PcdDscLine,StructurePcd") NvStorageHeaderSize = 28 VariableHeaderSize = 32 class VariableMgr(object): def __init__(self, DefaultStoreMap, SkuIdMap): @@ -54,37 +54,74 @@ class VariableMgr(object): value_str = "{" default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin] value_str += ",".join(default_var_bin_strip) value_str += "}" return value_str +def Do_combine(self,sku_var_info_offset_list): +newvalue = {} +for item in sku_var_info_offset_list: +data_type = item.data_type +value_list = item.default_value.strip("{").strip("}").split(",") +if data_type in DataType.TAB_PCD_NUMERIC_TYPES: +data_flag = DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]] +data = value_list[0] +value_list = [] +for data_byte in pack(data_flag, int(data, 16) if data.upper().startswith('0X') else int(data)): +value_list.append(hex(unpack("B", data_byte)[0])) +newvalue[int(item.var_offset, 16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list +try: +newvaluestr = "{" + ",".join(VariableMgr.assemble_variable(newvalue)) +"}" +except: +EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join(item.pcdname for item in sku_var_info_offset_list))) +return newvaluestr +def Do_Merge(self,sku_var_info_offset_list): +StructrurePcds = sorted([item for item in
[edk2] [Patch] BaseTool: Variable Merge.
If Structure PCD and Normal Pcd refer to the same variable, do variable merge. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 3 +- BaseTools/Source/Python/AutoGen/GenVar.py | 71 -- .../Source/Python/Workspace/BuildClassObject.py| 2 + BaseTools/Source/Python/Workspace/DscBuildData.py | 3 +- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 95370d1821..d1bd1b1d4c 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1211,11 +1211,11 @@ class PlatformAutoGen(AutoGen): continue if len(Sku.VariableName) > 0: VariableGuidStructure = Sku.VariableGuidValue VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure) for StorageName in Sku.DefaultStoreDict: -VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType)) +VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType, Pcd.CustomAttribute['DscPosition'], Pcd.CustomAttribute.get('IsStru',False))) Index += 1 return VariableInfo def UpdateNVStoreMaxSize(self, OrgVpdFile): if self.VariableInfo: @@ -2104,10 +2104,11 @@ class PlatformAutoGen(AutoGen): EdkLogger.error('build', FORMAT_INVALID, Cause, File=self.MetaFile, ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName)) ToPcd.validateranges = FromPcd.validateranges ToPcd.validlists = FromPcd.validlists ToPcd.expressions = FromPcd.expressions +ToPcd.CustomAttribute = FromPcd.CustomAttribute if FromPcd is not None and ToPcd.DatumType == TAB_VOID and not ToPcd.MaxDatumSize: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \ % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value = ToPcd.DefaultValue diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 75d455b407..654ff7b14e 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -20,11 +20,11 @@ import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections import Common.DataType as DataType -var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type") +var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type,PcdDscLine,StructurePcd") NvStorageHeaderSize = 28 VariableHeaderSize = 32 class VariableMgr(object): def __init__(self, DefaultStoreMap, SkuIdMap): @@ -54,37 +54,74 @@ class VariableMgr(object): value_str = "{" default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin] value_str += ",".join(default_var_bin_strip) value_str += "}" return value_str +def Do_combine(self,sku_var_info_offset_list): +newvalue = {} +for item in sku_var_info_offset_list: +data_type = item.data_type +value_list = item.default_value.strip("{").strip("}").split(",") +if data_type in DataType.TAB_PCD_NUMERIC_TYPES: +data_flag = DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]] +data = value_list[0] +value_list = [] +for data_byte in pack(data_flag, int(data, 16) if data.upper().startswith('0X') else int(data)): +value_list.append(hex(unpack("B", data_byte)[0])) +newvalue[int(item.var_offset, 16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list +try: +newvaluestr = "{" + ",".join(VariableMgr.assemble_variable(newvalue)) +"}" +except: +EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join(item.pcdname for item in sku_var_info_offset_list))) +return newvaluestr +def Do_Merge(self,sku_var_info_offset_list): +StructrurePcds = sorted([item for item in sku_var_info_offset_list
[edk2] [Patch] BaseTools: Structure Pcd value override incorrect.
This patch is going to fix the issue that The Pcd field value is override incorrectly when there is no Pcd overall value assignment in Dsc file. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 1 + .../Source/Python/Workspace/BuildClassObject.py| 2 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 54 -- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 95370d1821..ac3cf7eef3 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1653,10 +1653,11 @@ class PlatformAutoGen(AutoGen): for (SkuName, SkuId) in allskuset: if type(SkuId) in (str, unicode) and eval(SkuId) == 0 or SkuId == 0: continue pcd.SkuInfoList[SkuName] = copy.deepcopy(pcd.SkuInfoList[TAB_DEFAULT]) pcd.SkuInfoList[SkuName].SkuId = SkuId +pcd.SkuInfoList[SkuName].SkuIdName = SkuName self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList def FixVpdOffset(self, VpdFile ): FvPath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY) if not os.path.exists(FvPath): diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index b2e5309a90..b0f3cde81a 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -59,11 +59,11 @@ class PcdClassObject(object): self.IsFromDsc = False self.validateranges = validateranges self.validlists = validlists self.expressions = expressions self.DscDefaultValue = None -self.DscRawValue = None +self.DscRawValue = {} if IsDsc: self.DscDefaultValue = Value self.PcdValueFromComm = "" self.PcdValueFromFdf = "" self.DefinitionPosition = ("","") diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 7d6536c4b6..f2fff4d9fd 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1403,11 +1403,11 @@ class DscBuildData(PlatformBuildClassObject): while nextskuid not in stru_pcd.SkuOverrideValues: if nextskuid == TAB_DEFAULT: NoDefault = True break nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) -stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {TAB_DEFAULT_STORES_DEFAULT:stru_pcd.DefaultValues}) +stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {}) #{TAB_DEFAULT_STORES_DEFAULT:stru_pcd.DefaultValues}) if not NoDefault: stru_pcd.ValueChain.add((skuid, '')) if stru_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: for skuid in SkuIds: nextskuid = skuid @@ -1556,11 +1556,13 @@ class DscBuildData(PlatformBuildClassObject): {}, False, None, IsDsc=True) - +if self.SkuIdMgr.SystemSkuId not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue: +Pcds[PcdCName, TokenSpaceGuid].DscRawValue[self.SkuIdMgr.SystemSkuId] = {} +Pcds[PcdCName, TokenSpaceGuid].DscRawValue[self.SkuIdMgr.SystemSkuId][TAB_DEFAULT_STORES_DEFAULT] = PcdValue return Pcds def GetStructurePcdMaxSize(self, str_pcd): pcd_default_value = str_pcd.DefaultValue sku_values = [skuobj.HiiDefaultValue if str_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]] else skuobj.DefaultValue for skuobj in str_pcd.SkuInfoList.values()] @@ -1788,15 +1790,12 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' CHAR8 *Value;\n' CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName] if (SkuName, Defau
[edk2] [Patch] BaseTool: Variable Merge.
If Structure PCD and Normal Pcd refer to the same variable, do variable merge. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 3 +- BaseTools/Source/Python/AutoGen/GenVar.py | 71 -- .../Source/Python/Workspace/BuildClassObject.py| 2 + BaseTools/Source/Python/Workspace/DscBuildData.py | 3 +- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 15365e7b1d..b50c5bc1ac 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1211,11 +1211,11 @@ class PlatformAutoGen(AutoGen): continue if len(Sku.VariableName) > 0: VariableGuidStructure = Sku.VariableGuidValue VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure) for StorageName in Sku.DefaultStoreDict: -VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType)) +VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType, Pcd.CustomAttribute['DscPosition'], Pcd.CustomAttribute.get('IsStru',False))) Index += 1 return VariableInfo def UpdateNVStoreMaxSize(self, OrgVpdFile): if self.VariableInfo: @@ -2104,10 +2104,11 @@ class PlatformAutoGen(AutoGen): EdkLogger.error('build', FORMAT_INVALID, Cause, File=self.MetaFile, ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName)) ToPcd.validateranges = FromPcd.validateranges ToPcd.validlists = FromPcd.validlists ToPcd.expressions = FromPcd.expressions +ToPcd.CustomAttribute = FromPcd.CustomAttribute if FromPcd is not None and ToPcd.DatumType == TAB_VOID and not ToPcd.MaxDatumSize: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \ % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value = ToPcd.DefaultValue diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 75d455b407..d5218619f0 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -20,11 +20,11 @@ import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections import Common.DataType as DataType -var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type") +var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type,PcdDscLine,StructurePcd") NvStorageHeaderSize = 28 VariableHeaderSize = 32 class VariableMgr(object): def __init__(self, DefaultStoreMap, SkuIdMap): @@ -54,37 +54,74 @@ class VariableMgr(object): value_str = "{" default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin] value_str += ",".join(default_var_bin_strip) value_str += "}" return value_str +def Do_combine(self,sku_var_info_offset_list): +newvalue = {} +for item in sku_var_info_offset_list: +data_type = item.data_type +value_list = item.default_value.strip("{").strip("}").split(",") +if data_type in DataType.TAB_PCD_NUMERIC_TYPES: +data_flag = DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]] +data = value_list[0] +value_list = [] +for data_byte in pack(data_flag, int(data, 16) if data.upper().startswith('0X') else int(data)): +value_list.append(hex(unpack("B", data_byte)[0])) +newvalue[int(item.var_offset, 16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list +try: +newvaluestr = "{" + ",".join(VariableMgr.assemble_variable(newvalue)) +"}" +except: +EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join(item.pcdname for item in sku_var_info_offset_list))) +return newvaluestr +def Do_Merge(self,sku_var_info_offset_list): +StructrurePcds = sorted([item for item in sku_var_info_offset_list
[edk2] [Patch] BaseTools: Involve Dec default value to calculate Maxsize
Involve Dec default value to calculate Maxsize for structure PCD Cc: Liming Gao Cc: Yonghong Zhu Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng --- .../Source/Python/Workspace/BuildClassObject.py| 34 +++--- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 88465c59ea..b2e5309a90 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -66,35 +66,35 @@ class PcdClassObject(object): self.DscDefaultValue = Value self.PcdValueFromComm = "" self.PcdValueFromFdf = "" self.DefinitionPosition = ("","") +@staticmethod +def GetPcdMaxSizeWorker(PcdString, MaxSize): +if PcdString.startswith("{") and PcdString.endswith("}"): +return max([len(PcdString.split(",")),MaxSize]) + +if PcdString.startswith("\"") or PcdString.startswith("\'"): +return max([len(PcdString)-2+1,MaxSize]) + +if PcdString.startswith("L\""): +return max([2*(len(PcdString)-3+1),MaxSize]) + +return max([len(PcdString),MaxSize]) + ## Get the maximum number of bytes def GetPcdMaxSize(self): if self.DatumType in TAB_PCD_NUMERIC_TYPES: return MAX_SIZE_TYPE[self.DatumType] MaxSize = int(self.MaxDatumSize, 10) if self.MaxDatumSize else 0 if self.PcdValueFromFdf: -if self.PcdValueFromFdf.startswith("{") and self.PcdValueFromFdf.endswith("}"): -MaxSize = max([len(self.PcdValueFromFdf.split(",")),MaxSize]) -elif self.PcdValueFromFdf.startswith("\"") or self.PcdValueFromFdf.startswith("\'"): -MaxSize = max([len(self.PcdValueFromFdf)-2+1,MaxSize]) -elif self.PcdValueFromFdf.startswith("L\""): -MaxSize = max([2*(len(self.PcdValueFromFdf)-3+1),MaxSize]) -else: -MaxSize = max([len(self.PcdValueFromFdf),MaxSize]) - +MaxSize = self.GetPcdMaxSizeWorker(self.PcdValueFromFdf,MaxSize) if self.PcdValueFromComm: -if self.PcdValueFromComm.startswith("{") and self.PcdValueFromComm.endswith("}"): -return max([len(self.PcdValueFromComm.split(",")), MaxSize]) -elif self.PcdValueFromComm.startswith("\"") or self.PcdValueFromComm.startswith("\'"): -return max([len(self.PcdValueFromComm)-2+1, MaxSize]) -elif self.PcdValueFromComm.startswith("L\""): -return max([2*(len(self.PcdValueFromComm)-3+1), MaxSize]) -else: -return max([len(self.PcdValueFromComm), MaxSize]) +MaxSize = self.GetPcdMaxSizeWorker(self.PcdValueFromComm,MaxSize) +if hasattr(self, "DefaultValueFromDec"): +MaxSize = self.GetPcdMaxSizeWorker(self.DefaultValueFromDec,MaxSize) return MaxSize ## Get the number of bytes def GetPcdSize(self): if self.DatumType in TAB_PCD_NUMERIC_TYPES: -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Involve Dec default value to calculate Maxsize
Involve Dec default value to calculate Maxsize for structure PCD Cc: Bob Feng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 9 + 1 file changed, 9 insertions(+) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 88465c59ea..32d202de5e 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -91,10 +91,19 @@ class PcdClassObject(object): return max([len(self.PcdValueFromComm)-2+1, MaxSize]) elif self.PcdValueFromComm.startswith("L\""): return max([2*(len(self.PcdValueFromComm)-3+1), MaxSize]) else: return max([len(self.PcdValueFromComm), MaxSize]) +if hasattr(self, "DefaultValueFromDec"): +if self.DefaultValueFromDec.startswith("{") and self.DefaultValueFromDec.endswith("}"): +return max([len(self.DefaultValueFromDec.split(",")), MaxSize]) +elif self.DefaultValueFromDec.startswith("\"") or self.DefaultValueFromDec.startswith("\'"): +return max([len(self.DefaultValueFromDec)-2+1, MaxSize]) +elif self.DefaultValueFromDec.startswith("L\""): +return max([2*(len(self.DefaultValueFromDec)-3+1), MaxSize]) +else: +return max([len(self.DefaultValueFromDec), MaxSize]) return MaxSize ## Get the number of bytes def GetPcdSize(self): if self.DatumType in TAB_PCD_NUMERIC_TYPES: -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Dynamic Pcd value override from command line.
Fixed the pcd value override issue when Dynamic Pcd is from command line but is not list in Dsc file. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 748452623f..d553536961 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1268,13 +1268,18 @@ class DscBuildData(PlatformBuildClassObject): PcdInDec = self.DecPcds.get((Name, Guid)) if PcdInDec: PcdInDec.PcdValueFromComm = NoFiledValues[(Guid, Name)][0] if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE], - self._PCD_TYPE_STRING_[MODEL_PCD_FEATURE_FLAG]]: + self._PCD_TYPE_STRING_[MODEL_PCD_FEATURE_FLAG], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX]]: self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec) self.Pcds[Name, Guid].DefaultValue = NoFiledValues[( Guid, Name)][0] +if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX]]: +self.Pcds[Name, Guid].SkuInfoList = {TAB_DEFAULT:SkuInfoClass(TAB_DEFAULT, self.SkuIds[TAB_DEFAULT][0], '', '', '', '', '', NoFiledValues[( Guid, Name)][0])} return AllPcds def OverrideByFdfOverAll(self,AllPcds): if GlobalData.gFdfParser is None: -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fixed the PcdValue trailing zero issue.
1. Not append trailing zero for PcdValue 2. make sure the point to Variable Name in PCD DataBase 2 bytes aligned. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 6 ++ BaseTools/Source/Python/Common/StringUtils.py | 7 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 2176bbefeb..5b260cd515 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -1182,10 +1182,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): Pcd.InitString = 'INIT' # Store all variable names of one HII PCD under different SKU to stringTable # and calculate the VariableHeadStringIndex VariableNameStructure = StringToArray(Sku.VariableName) + +# Make pointer of VaraibleName(HII PCD) 2 bytes aligned +VariableNameStructureBytes = VariableNameStructure.lstrip("{").rstrip("}").split(",") +if len(VariableNameStructureBytes) % 2: +VariableNameStructure = "{%s,0x00}" % ",".join(VariableNameStructureBytes) + if VariableNameStructure not in Dict['STRING_TABLE_VALUE']: Dict['STRING_TABLE_CNAME'].append(CName) Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid) if StringTableIndex == 0: Dict['STRING_TABLE_INDEX'].append('') diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py index da2949dbad..d5afde7a95 100644 --- a/BaseTools/Source/Python/Common/StringUtils.py +++ b/BaseTools/Source/Python/Common/StringUtils.py @@ -833,16 +833,11 @@ def StringToArray(String): if StringLen % 2: return "{%s,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1]) else: return "{%s,0x00,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1]) elif String.startswith('{'): -StringLen = len(String.split(",")) -if StringLen % 2: -return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1].split(',')) -else: -return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(',')) - +return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(',')) else: if len(String.split()) % 2: return '{%s,0}' % ','.join(String.split()) else: return '{%s,0,0}' % ','.join(String.split()) -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF.
From: Zhaozh1x 1. When assign dynamic hii pcd value in dsc file, missed the DefaultValue, build should be fail. 2. Check the EBNF of SkuId. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: ZhiqiangX Zhao Cc: Liming Gao Cc: Yonghong Zhu Cc: Bob Feng --- BaseTools/Source/Python/Common/Misc.py| 4 +++- BaseTools/Source/Python/Workspace/DscBuildData.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 74a5f0bca5..8debb0fdf8 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1525,6 +1525,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): Size = -1 return [VpdOffset, str(Size), Value], IsValid, 2 elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII): +IsValid = (3 <= len(FieldList) <= 5) HiiString = FieldList[0] Guid = Offset = Value = Attribute = '' if len(FieldList) > 1: @@ -1533,9 +1534,10 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): Offset = FieldList[2] if len(FieldList) > 3: Value = FieldList[3] +if not Value: +IsValid = False if len(FieldList) > 4: Attribute = FieldList[4] -IsValid = (3 <= len(FieldList) <= 5) return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3 return [], False, 0 diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index e8b36a3868..dd30067491 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -92,7 +92,7 @@ LIBS = -lCommon ''' variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$') - +SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$') ## regular expressions for finding decimal and hex numbers Pattern = re.compile('^[1-9]\d*|0$') HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$') @@ -646,8 +646,8 @@ class DscBuildData(PlatformBuildClassObject): if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]): EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber", File=self.MetaFile, Line=Record[-1]) -if not IsValidWord(Record[1]): -EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'", +if not SkuIdPattern.match(Record[1]) or (Record[2] and not SkuIdPattern.match(Record[2])): +EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z_)(a-zA-Z0-9_)*'", File=self.MetaFile, Line=Record[-1]) self._SkuIds[Record[1].upper()] = (str(DscBuildData.ToInt(Record[0])), Record[1].upper(), Record[2].upper()) if TAB_DEFAULT not in self._SkuIds: -- 2.14.1.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fixed build Ovmfpkg failed issue.
Fixed a code bug. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 804eafa619..e8b36a3868 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1293,14 +1293,14 @@ class DscBuildData(PlatformBuildClassObject): def OverrideByFdfOverAll(self,AllPcds): if GlobalData.gFdfParser is None: return AllPcds NoFiledValues = GlobalData.gFdfParser.Profile.PcdDict -for Guid,Name,Field in NoFiledValues: +for Name,Guid,Field in NoFiledValues: if len(Field): continue -Value = NoFiledValues[(Guid,Name,Field)] +Value = NoFiledValues[(Name,Guid,Field)] if (Name,Guid) in AllPcds: Pcd = AllPcds.get((Name,Guid)) if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName), None),StructurePcd): self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName)).PcdValueFromComm = Value else: @@ -1323,11 +1323,11 @@ class DscBuildData(PlatformBuildClassObject): MaxSize = max(CurrentSize, OptionSize) Pcd.MaxDatumSize = str(MaxSize) else: PcdInDec = self.DecPcds.get((Name,Guid)) if PcdInDec: -PcdInDec.PcdValueFromComm = Value +PcdInDec.PcdValueFromFdf = Value if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE], self._PCD_TYPE_STRING_[MODEL_PCD_FEATURE_FLAG]]: self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec) self.Pcds[Name, Guid].DefaultValue = Value -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTool: Fixed the incorrect cache key.
From: "bob.c.f...@intel.com" This patch is to fix the incorrect cache key of skip ModuleAutoGen cache. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index b27290989e..54c6b7330f 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -4320,7 +4320,7 @@ class ModuleAutoGen(AutoGen): # If any source file is newer than the module than we cannot skip # def CanSkip(self): -if self.MetaFile in GlobalData.gSikpAutoGenCache: +if self.MakeFileDir in GlobalData.gSikpAutoGenCache: return True if not os.path.exists(self.GetTimeStampPath()): return False @@ -4340,7 +4340,7 @@ class ModuleAutoGen(AutoGen): ModuleAutoGen.TimeDict[source] = os.stat(source)[8] if ModuleAutoGen.TimeDict[source] > DstTimeStamp: return False -GlobalData.gSikpAutoGenCache.add(self.MetaFile) +GlobalData.gSikpAutoGenCache.add(self.MakeFileDir) return True def GetTimeStampPath(self): -- 2.18.0.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Remove a unused function.
the call statement of _CheckDuplicateInFV() was commented out in 2014. There is no call statement of _CheckDuplicateInFV(), so remove it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 128 - 1 file changed, 128 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index d100648606..57a4b4923f 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -617,13 +617,10 @@ class WorkspaceAutoGen(AutoGen): # # Check PCD type and definition between DSC and DEC # self._CheckPcdDefineAndType() -# if self.FdfFile: -# self._CheckDuplicateInFV(Fdf) - # # Create BuildOptions Macro & PCD metafile, also add the Active Platform and FDF file. # content = 'gCommandLineDefines: ' content += str(GlobalData.gCommandLineDefines) @@ -759,135 +756,10 @@ class WorkspaceAutoGen(AutoGen): for filePath in self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]._RawData.IncludedFiles: AllWorkSpaceMetaFiles.add(filePath.Path) return AllWorkSpaceMetaFiles -## _CheckDuplicateInFV() method -# -# Check whether there is duplicate modules/files exist in FV section. -# The check base on the file GUID; -# -def _CheckDuplicateInFV(self, Fdf): -for Fv in Fdf.Profile.FvDict: -_GuidDict = {} -for FfsFile in Fdf.Profile.FvDict[Fv].FfsList: -if FfsFile.InfFileName and FfsFile.NameGuid is None: -# -# Get INF file GUID -# -InfFoundFlag = False -for Pa in self.AutoGenObjectList: -if InfFoundFlag: -break -for Module in Pa.ModuleAutoGenList: -if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName): -InfFoundFlag = True -if Module.Guid.upper() not in _GuidDict: -_GuidDict[Module.Guid.upper()] = FfsFile -break -else: -EdkLogger.error("build", -FORMAT_INVALID, -"Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum, - FfsFile.CurrentLineContent, - _GuidDict[Module.Guid.upper()].CurrentLineNum, - _GuidDict[Module.Guid.upper()].CurrentLineContent, - Module.Guid.upper()), -ExtraData=self.FdfFile) -# -# Some INF files not have entity in DSC file. -# -if not InfFoundFlag: -if FfsFile.InfFileName.find('$') == -1: -InfPath = NormPath(FfsFile.InfFileName) -if not os.path.exists(InfPath): -EdkLogger.error('build', GENFDS_ERROR, "Non-existant Module %s !" % (FfsFile.InfFileName)) - -PathClassObj = PathClass(FfsFile.InfFileName, self.WorkspaceDir) -# -# Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use -# BuildObject from one of AutoGenObjectList is enough. -# -InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_ARCH_COMMON, self.BuildTarget, self.ToolChain] -if InfObj.Guid.upper() not in _GuidDict: -_GuidDict[InfObj.Guid.upper()] = FfsFile -else: -EdkLogger.error("build", -FORMAT_INVALID, -"Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum, -
[edk2] [Patch] BaseTool: Add cache for the result of SkipAutogen.
Add a cache for the value of skip ModuleAutoGen process flag. This cache can improve build performance. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 4 BaseTools/Source/Python/Common/GlobalData.py | 1 + 2 files changed, 5 insertions(+) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 381dbc0a71..fc242992b7 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -4305,15 +4305,18 @@ class ModuleAutoGen(AutoGen): ## Decide whether we can skip the ModuleAutoGen process def CanSkipbyHash(self): if GlobalData.gUseHashCache: return not self.GenModuleHash() +return False ## Decide whether we can skip the ModuleAutoGen process # If any source file is newer than the module than we cannot skip # def CanSkip(self): +if self.MetaFile in GlobalData.gSikpAutoGenCache: +return True if not os.path.exists(self.GetTimeStampPath()): return False #last creation time of the module DstTimeStamp = os.stat(self.GetTimeStampPath())[8] @@ -4328,10 +4331,11 @@ class ModuleAutoGen(AutoGen): return False if source not in ModuleAutoGen.TimeDict : ModuleAutoGen.TimeDict[source] = os.stat(source)[8] if ModuleAutoGen.TimeDict[source] > DstTimeStamp: return False +GlobalData.gSikpAutoGenCache.add(self.MetaFile) return True def GetTimeStampPath(self): if self._TimeStampPath is None: self._TimeStampPath = os.path.join(self.MakeFileDir, 'AutoGenTimeStamp') diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py index afb3d8f020..fac7cde708 100644 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -111,5 +111,6 @@ gBinCacheDest = None gBinCacheSource = None gPlatformHash = None gPackageHash = {} gModuleHash = {} gEnableGenfdsMultiThread = False +gSikpAutoGenCache = set() -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Enable structure pcd in FDF file
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 3 +- BaseTools/Source/Python/AutoGen/GenC.py| 4 + BaseTools/Source/Python/GenFds/FdfParser.py| 81 -- .../Source/Python/Workspace/BuildClassObject.py| 14 ++ BaseTools/Source/Python/Workspace/DscBuildData.py | 171 - BaseTools/Source/Python/build/BuildReport.py | 3 + 6 files changed, 256 insertions(+), 20 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index ed0be3bc74..e3f404bd6b 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -565,11 +565,11 @@ class WorkspaceAutoGen(AutoGen): for Pcd in Pkg.Pcds: DecPcds.add((Pcd[0], Pcd[1])) DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2])) Platform.SkuName = self.SkuId -for Name, Guid in PcdSet: +for Name, Guid,Fileds in PcdSet: if (Name, Guid) not in DecPcds: EdkLogger.error( 'build', PARSER_ERROR, "PCD (%s.%s) used in FDF is not declared in DEC files." % (Guid, Name), @@ -579,11 +579,10 @@ class WorkspaceAutoGen(AutoGen): else: # Check whether Dynamic or DynamicEx PCD used in FDF file. If used, build break and give a error message. if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \ or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in DecPcdsKey \ or (Name, Guid, TAB_PCDS_FEATURE_FLAG) in DecPcdsKey: -Platform.AddPcd(Name, Guid, PcdSet[Name, Guid]) continue elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or (Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey: EdkLogger.error( 'build', PARSER_ERROR, diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index ae3af085a1..d186f399ba 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -888,10 +888,12 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName FixedPcdSizeVariableName = '_gPcd_FixedAtBuild_Size_' + TokenCName if Pcd.PcdValueFromComm: Pcd.DefaultValue = Pcd.PcdValueFromComm +elif Pcd.PcdValueFromFdf: +Pcd.DefaultValue = Pcd.PcdValueFromFdf if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: TokenNumber = int(Pcd.TokenValue, 0) # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with # different Guids but same TokenCName @@ -1181,10 +1183,12 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): PatchPcdMaxSizeVariable = '_gPcd_BinaryPatch_MaxSize_' + TokenCName FixedPcdSizeVariableName = '_gPcd_FixedAtBuild_Size_' + TokenCName if Pcd.PcdValueFromComm: Pcd.DefaultValue = Pcd.PcdValueFromComm +elif Pcd.PcdValueFromFdf: +Pcd.DefaultValue = Pcd.PcdValueFromFdf # # Write PCDs # if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: TokenNumber = int(Pcd.TokenValue, 0) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 78cb049c61..a8a2e7d70e 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -80,17 +80,16 @@ T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, T_CHAR_ (' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#') SEPERATOR_TUPLE = ('=', '|', ',', '{', '}') RegionSizePattern = re.compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*") -RegionSizeGuidPattern = re.compile("\s*(?P\w+\.\w+)\s*\|\s*(?P\w+\.\w+)\s*") -RegionOffsetPcdPattern = re.compile("\s*(?P\w+\.\w+)\s*$") +RegionSizeGuidPattern = re.compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P\w+\.\w+[\.\w\[\]]*)\s*") +RegionOffsetPcdPattern = re.compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*$") ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P\w+\.\w+)\s*") BaseAddrValuePattern = re.compile('^0[xX][0-9a-fA-F]+') FileExtensionPattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)') TokenFindPattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') - AllIncludeFileList = [] # Get the closest parent def GetParentAtLine (Line): for Profile in AllIncludeFileList: @@ -223,12 +222,13 @@ class FileProfile : fsock.close() except: EdkLogger.err
[edk2] [Patch] BaseTools: Structure pcd value assignment
Enable Structure pcd value assigned by FixedPcd Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/MetaFileParser.py | 23 +++--- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 88c7bb374c..ac08f39c30 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1609,17 +1609,26 @@ class DscParser(MetaFileParser): ValList, Valid, Index = AnalyzeDscPcd(self._ValueList[2], self._ItemType) if not Valid: EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self._FileWithError, Line=self._LineIndex + 1, ExtraData="%s.%s|%s" % (self._ValueList[0], self._ValueList[1], self._ValueList[2])) PcdValue = ValList[Index] -if PcdValue and "." not in self._ValueList[0]: -try: -ValList[Index] = ValueExpression(PcdValue, self._Macros)(True) -except WrnExpression, Value: -ValList[Index] = Value.result -except: -pass +if PcdValue: +if "." not in self._ValueList[0]: +try: +ValList[Index] = ValueExpression(PcdValue, self._Macros)(True) +except WrnExpression, Value: +ValList[Index] = Value.result +except: +pass +else: +if PcdValue in self._Macros: +try: +ValList[Index] = ValueExpression(PcdValue, self._Macros)(True) +except WrnExpression, Value: +ValList[Index] = Value.result +except: +pass if ValList[Index] == 'True': ValList[Index] = '1' if ValList[Index] == 'False': ValList[Index] = '0' -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Fixed the bug of Boolean Hii Pcd packing.
When packing HiiPcd into PcdNvStoreDefaultValueBuffer, The boolean type pcd value packing incorrect. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenVar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 3675be8de9..bf3d225c21 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -294,11 +294,11 @@ class VariableMgr(object): if tail: for value_char in tail.split(","): Buffer += pack("=B",int(value_char,16)) data_len += len(tail.split(",")) elif data_type == "BOOLEAN": -Buffer += pack("=B",True) if var_value.upper() == "TRUE" else pack("=B",False) +Buffer += pack("=B",True) if var_value.upper() in ["TRUE","1"] else pack("=B",False) data_len += 1 elif data_type == DataType.TAB_UINT8: Buffer += pack("=B",GetIntegerValue(var_value)) data_len += 1 elif data_type == DataType.TAB_UINT16: -- 2.16.2.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Fixed the issue of empty PcdDB.
If there is no dynamic pcds, there should be DB header in the Pcd DataBase. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index e2848e7aaf..e4d7f3b759 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -978,12 +978,10 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): DbFile.write(PcdDbBuffer) Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True) def CreatePcdDataBase(PcdDBData): delta = {} basedata = {} -if not PcdDBData: -return "" for skuname,skuid in PcdDBData: if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[("DEFAULT","0")][1]): EdkLogger.ERROR("The size of each sku in one pcd are not same") for skuname,skuid in PcdDBData: if skuname == "DEFAULT": @@ -1059,13 +1057,16 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): VarCheckTable = CreateVarCheckBin(VarCheckTableData) VarCheckTable.dump(dest, Phase) AdditionalAutoGenH, AdditionalAutoGenC = CreateAutoGen(PcdDriverAutoGenData) else: AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer,VarCheckTab = CreatePcdDatabasePhaseSpecificAutoGen (Platform,{}, Phase) +final_data = () +for item in PcdDbBuffer: +final_data += unpack("B",item) +PcdDBData[("DEFAULT","0")] = (PcdDbBuffer, final_data) -PcdDbBuffer = CreatePcdDataBase(PcdDBData) -return AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer +return AdditionalAutoGenH, AdditionalAutoGenC, CreatePcdDataBase(PcdDBData) ## Create PCD database in DXE or PEI phase # # @param PlatformThe platform object # @retval tuple Two TemplateString objects for C code and header file, # respectively -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Error handling for PCD datumtype.
Report error if the Pcd DatumType is wrong. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 ++ BaseTools/Source/Python/Workspace/DecBuildData.py | 13 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 1352fa21c8..a306dc0b23 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -67,10 +67,11 @@ class PcdClassObject(object): self.DscDefaultValue = None self.DscRawValue = None if IsDsc: self.DscDefaultValue = Value self.PcdValueFromComm = "" +self.DefinitionPosition = ("","") ## Convert the class to a string # # Convert each member of the class to string # Organize to a signle line format string @@ -176,10 +177,11 @@ class StructurePcd(PcdClassObject): self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm +self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition if type(PcdObject) is StructurePcd: self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index ee00ec0719..4d6edadc8f 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -392,15 +392,11 @@ class DecBuildData(PackageBuildClassObject): struct_pcd.SetDecDefaultValue(item.DefaultValue) else: struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo) struct_pcd.PackageDecs = dep_pkgs -if not struct_pcd.StructuredPcdIncludeFile: -EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,self.MetaFile.File,LineNo )) - str_pcd_set.append(struct_pcd) - return str_pcd_set ## Retrieve PCD declarations for given type def _GetPcd(self, Type): Pcds = sdict() @@ -444,18 +440,27 @@ class DecBuildData(PackageBuildClassObject): None, list(validateranges), list(validlists), list(expressions) ) +PcdObj.DefinitionPosition = (self.MetaFile.File,LineNo) if "." in TokenSpaceGuid: StrPcdSet.append((PcdObj,LineNo)) else: Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdObj StructurePcds = self.ProcessStructurePcd(StrPcdSet) for pcd in StructurePcds: Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd +StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') +for pcd in Pcds.values(): +if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: +if StructPattern.match(pcd.DatumType) == None: +EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", pcd.DefinitionPosition[0],pcd.DefinitionPosition[1]) +for struct_pcd in Pcds.values(): +if isinstance(struct_pcd,StructurePcd) and not struct_pcd.StructuredPcdIncludeFile: +EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,struct_pcd.DefinitionPosition[0],struct_pcd.DefinitionPosition[1] )) return Pcds @property def
[edk2] [Patch] BaseTools: Detect structure pcd header file change.
Detect structure pcd header file change Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 188 +++--- 1 file changed, 134 insertions(+), 54 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 9c43daca5e..9a1ed1b6e4 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -93,10 +93,71 @@ LIBS = $(LIB_PATH)\Common.lib PcdGccMakefile = ''' MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C LIBS = -lCommon ''' +## Regular expression for finding header file inclusions +from AutoGen.GenMake import gIncludePattern + +## Find dependencies for one source file +# +# By searching recursively "#include" directive in file, find out all the +# files needed by given source file. The dependecies will be only searched +# in given search path list. +# +# @param SearchPathList The list of search path +# +# @retval listThe list of files the given source file depends on +# +def GetDependencyList(FileStack,SearchPathList): +DepDb = dict() +DependencySet = set(FileStack) +while len(FileStack) > 0: +F = FileStack.pop() +FullPathDependList = [] +CurrentFileDependencyList = [] +if F in DepDb: +CurrentFileDependencyList = DepDb[F] +else: +try: +Fd = open(F, 'r') +FileContent = Fd.read() +except BaseException, X: +EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F + "\n\t" + str(X)) +finally: +if "Fd" in dir(locals()): +Fd.close() + +if len(FileContent) == 0: +continue + +if FileContent[0] == 0xff or FileContent[0] == 0xfe: +FileContent = unicode(FileContent, "utf-16") +IncludedFileList = gIncludePattern.findall(FileContent) + +for Inc in IncludedFileList: +Inc = Inc.strip() +Inc = os.path.normpath(Inc) +CurrentFileDependencyList.append(Inc) +DepDb[F] = CurrentFileDependencyList + +CurrentFilePath = os.path.dirname(F) +PathList = [CurrentFilePath] + SearchPathList +for Inc in CurrentFileDependencyList: +for SearchPath in PathList: +FilePath = os.path.join(SearchPath, Inc) +if not os.path.exists(FilePath): +continue +if FilePath not in DependencySet: +FileStack.append(FilePath) +FullPathDependList.append(FilePath) +break +DependencySet.update(FullPathDependList) +DependencyList = list(DependencySet) # remove duplicate ones + +return DependencyList + class DscBuildData(PlatformBuildClassObject): # dict used to convert PCD type in database to string used by build tool _PCD_TYPE_STRING_ = { MODEL_PCD_FIXED_AT_BUILD: "FixedAtBuild", MODEL_PCD_PATCHABLE_IN_MODULE : "PatchableInModule", @@ -1916,15 +1977,17 @@ class DscBuildData(PlatformBuildClassObject): InitByteValue = "" CApp = PcdMainCHeader Includes = {} +IncludeFiles = set() for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] for IncludeFile in Pcd.StructuredPcdIncludeFile: if IncludeFile not in Includes: Includes[IncludeFile] = True +IncludeFiles.add((os.path.dirname(Pcd.PkgPath), IncludeFile)) CApp = CApp + '#include <%s>\n' % (IncludeFile) CApp = CApp + '\n' for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] CApp = CApp + self.GenerateSizeFunction(Pcd) @@ -1979,10 +2042,11 @@ class DscBuildData(PlatformBuildClassObject): else: MakeApp = MakeApp + PcdGccMakefile MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \ 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +=' +IncSearchList = [] PlatformInc = {} for Cache in self._Bdb._CACHE_.values(): if Cache.MetaFile.Ext.lower() != '.dec': continue if Cache.Includes: @@ -2001,10 +2065,11 @@ class DscBuildData(PlatformBuildClassObject): if PlatformInc and PcdDependDEC: for pkg in PcdDependDEC: if pkg in PlatformInc: for inc in PlatformInc[pkg]: MakeApp += '-I' + str(inc) + ' ' +IncSearchList.append(inc) MakeApp = MakeApp + '\n' CC_FLAGS = LinuxCFLAGS if sy
[edk2] [Patch] BaseTools: Detect structure pcd header file change.
Detect structure pcd header file change Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 190 -- 1 file changed, 136 insertions(+), 54 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 9c43daca5e..af2f3d39ea 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -93,10 +93,74 @@ LIBS = $(LIB_PATH)\Common.lib PcdGccMakefile = ''' MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C LIBS = -lCommon ''' +## Regular expression for finding header file inclusions +from AutoGen.GenMake import gIncludePattern +## Regular expression for matching macro used in header file inclusion +from AutoGen.GenMake import gMacroPattern +from AutoGen.GenMake import gIncludeMacroConversion + +## Find dependencies for one source file +# +# By searching recursively "#include" directive in file, find out all the +# files needed by given source file. The dependecies will be only searched +# in given search path list. +# +# @param SearchPathList The list of search path +# +# @retval listThe list of files the given source file depends on +# +def GetDependencyList(FileStack,SearchPathList): +DepDb = dict() +DependencySet = set(FileStack) +while len(FileStack) > 0: +F = FileStack.pop() +FullPathDependList = [] +CurrentFileDependencyList = [] +if F in DepDb: +CurrentFileDependencyList = DepDb[F] +else: +try: +Fd = open(F, 'r') +FileContent = Fd.read() +except BaseException, X: +EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F + "\n\t" + str(X)) +finally: +if "Fd" in dir(locals()): +Fd.close() + +if len(FileContent) == 0: +continue + +if FileContent[0] == 0xff or FileContent[0] == 0xfe: +FileContent = unicode(FileContent, "utf-16") +IncludedFileList = gIncludePattern.findall(FileContent) + +for Inc in IncludedFileList: +Inc = Inc.strip() +Inc = os.path.normpath(Inc) +CurrentFileDependencyList.append(Inc) +DepDb[F] = CurrentFileDependencyList + +CurrentFilePath = os.path.dirname(F) +PathList = [CurrentFilePath] + SearchPathList +for Inc in CurrentFileDependencyList: +for SearchPath in PathList: +FilePath = os.path.join(SearchPath, Inc) +if not os.path.exists(FilePath): +continue +if FilePath not in DependencySet: +FileStack.append(FilePath) +FullPathDependList.append(FilePath) +break +DependencySet.update(FullPathDependList) +DependencyList = list(DependencySet) # remove duplicate ones + +return DependencyList + class DscBuildData(PlatformBuildClassObject): # dict used to convert PCD type in database to string used by build tool _PCD_TYPE_STRING_ = { MODEL_PCD_FIXED_AT_BUILD: "FixedAtBuild", MODEL_PCD_PATCHABLE_IN_MODULE : "PatchableInModule", @@ -1916,15 +1980,17 @@ class DscBuildData(PlatformBuildClassObject): InitByteValue = "" CApp = PcdMainCHeader Includes = {} +IncludeFiles = set() for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] for IncludeFile in Pcd.StructuredPcdIncludeFile: if IncludeFile not in Includes: Includes[IncludeFile] = True +IncludeFiles.add((os.path.dirname(Pcd.PkgPath), IncludeFile)) CApp = CApp + '#include <%s>\n' % (IncludeFile) CApp = CApp + '\n' for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] CApp = CApp + self.GenerateSizeFunction(Pcd) @@ -1979,10 +2045,11 @@ class DscBuildData(PlatformBuildClassObject): else: MakeApp = MakeApp + PcdGccMakefile MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \ 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +=' +IncSearchList = [] PlatformInc = {} for Cache in self._Bdb._CACHE_.values(): if Cache.MetaFile.Ext.lower() != '.dec': continue if Cache.Includes: @@ -2001,10 +2068,11 @@ class DscBuildData(PlatformBuildClassObject): if PlatformInc and PcdDependDEC: for pkg in PcdDependDEC: if pkg in PlatformInc: for inc in PlatformInc[pkg]:
[edk2] [Patch] BaseTools: Fixed Pcd from command line issue.
Save the pcd command line value in Pcd object Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenC.py| 15 +++ BaseTools/Source/Python/AutoGen/GenMake.py | 28 +++ .../Source/Python/Workspace/BuildClassObject.py| 4 +-- BaseTools/Source/Python/Workspace/DscBuildData.py | 31 +++--- 4 files changed, 31 insertions(+), 47 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 3e98506cc8..481c4dda14 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -914,15 +914,12 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): PcdTokenName = '_PCD_TOKEN_' + TokenCName PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE' PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName -if GlobalData.BuildOptionPcd: -for PcdItem in GlobalData.BuildOptionPcd: -if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]): -Pcd.DefaultValue = PcdItem[2] -break +if Pcd.PcdValueFromComm: +Pcd.DefaultValue = Pcd.PcdValueFromComm if Pcd.Type in gDynamicExPcd: TokenNumber = int(Pcd.TokenValue, 0) # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with # different Guids but same TokenCName @@ -1213,16 +1210,12 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): PcdTokenName = '_PCD_TOKEN_' + TokenCName FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE' PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName -if GlobalData.BuildOptionPcd: -for PcdItem in GlobalData.BuildOptionPcd: -if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]): -Pcd.DefaultValue = PcdItem[2] -break - +if Pcd.PcdValueFromComm: +Pcd.DefaultValue = Pcd.PcdValueFromComm # # Write PCDs # if Pcd.Type in gDynamicExPcd: TokenNumber = int(Pcd.TokenValue, 0) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 1b0cf17e25..60bd625cd2 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1549,29 +1549,19 @@ class TopLevelMakefile(BuildFile): if GlobalData.gEnableGenfdsMultiThread: ExtraOption += " --genfds-multi-thread" if GlobalData.gIgnoreSource: ExtraOption += " --ignore-sources" -for index, option in enumerate(GlobalData.gCommand): -if "--pcd" == option and GlobalData.gCommand[index+1]: -pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') -for Item in GlobalData.BuildOptionPcd: -if '.'.join(Item[0:2]) == pcdName: -pcdValue = Item[2] -if pcdValue.startswith('L') or pcdValue.startswith('"'): -pcdValue, Size = ParseFieldValue(pcdValue) -NewVal = '{' -for S in range(Size): -NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff) -NewVal += ',' -pcdValue = NewVal[:-1] + '}' -break -if pcdValue.startswith('{'): -pcdValue = 'H' + '"' + pcdValue + '"' -ExtraOption += " --pcd " + pcdName + '=' + pcdValue -else: -ExtraOption += " --pcd " + GlobalData.gCommand[index+1] +for pcd in GlobalData.BuildOptionPcd: +if pcd[2]: +pcdname = '.'.join(pcd[0:3]) +else: +pcdname = '.'.join(pcd[0:2]) +if pcd[3].startswith('{'): +ExtraOption += " --pcd " + pcdname + '=' + 'H' + '"' + pcd[3] + '"' +else: +ExtraOption += " --pcd " + pcdname + '=' + pcd[3] MakefileName = self._FILE_NAME_[self._FileType] SubBuildCommandList = [] for A in PlatformInfo.ArchList: Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)} diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 711ba492ef..1352fa21c8 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -66,10 +66,11 @@ class PcdClassObject(object): self.expressions = expressions self.DscDefaultValue = None
[edk2] [Patch] BaseTools: Fixed Pcd from command line issue.
Save the pcd command line value in Pcd object Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenC.py| 15 +++ BaseTools/Source/Python/AutoGen/GenMake.py | 25 + .../Source/Python/Workspace/BuildClassObject.py| 4 +-- BaseTools/Source/Python/Workspace/DscBuildData.py | 31 +++--- 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 3e98506cc8..481c4dda14 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -914,15 +914,12 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): PcdTokenName = '_PCD_TOKEN_' + TokenCName PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE' PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName -if GlobalData.BuildOptionPcd: -for PcdItem in GlobalData.BuildOptionPcd: -if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]): -Pcd.DefaultValue = PcdItem[2] -break +if Pcd.PcdValueFromComm: +Pcd.DefaultValue = Pcd.PcdValueFromComm if Pcd.Type in gDynamicExPcd: TokenNumber = int(Pcd.TokenValue, 0) # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with # different Guids but same TokenCName @@ -1213,16 +1210,12 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): PcdTokenName = '_PCD_TOKEN_' + TokenCName FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE' PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName -if GlobalData.BuildOptionPcd: -for PcdItem in GlobalData.BuildOptionPcd: -if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]): -Pcd.DefaultValue = PcdItem[2] -break - +if Pcd.PcdValueFromComm: +Pcd.DefaultValue = Pcd.PcdValueFromComm # # Write PCDs # if Pcd.Type in gDynamicExPcd: TokenNumber = int(Pcd.TokenValue, 0) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 1b0cf17e25..0a3cc32155 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1549,29 +1549,16 @@ class TopLevelMakefile(BuildFile): if GlobalData.gEnableGenfdsMultiThread: ExtraOption += " --genfds-multi-thread" if GlobalData.gIgnoreSource: ExtraOption += " --ignore-sources" -for index, option in enumerate(GlobalData.gCommand): -if "--pcd" == option and GlobalData.gCommand[index+1]: -pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') -for Item in GlobalData.BuildOptionPcd: -if '.'.join(Item[0:2]) == pcdName: -pcdValue = Item[2] -if pcdValue.startswith('L') or pcdValue.startswith('"'): -pcdValue, Size = ParseFieldValue(pcdValue) -NewVal = '{' -for S in range(Size): -NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff) -NewVal += ',' -pcdValue = NewVal[:-1] + '}' -break -if pcdValue.startswith('{'): -pcdValue = 'H' + '"' + pcdValue + '"' -ExtraOption += " --pcd " + pcdName + '=' + pcdValue -else: -ExtraOption += " --pcd " + GlobalData.gCommand[index+1] +for pcd in GlobalData.BuildOptionPcd: +if pcd[2]: +pcdname = '.'.join(pcd[0:3]) +else: +pcdname = '.'.join(pcd[0:2]) +ExtraOption += " --pcd " + pcdname + '=' + pcd[3] MakefileName = self._FILE_NAME_[self._FileType] SubBuildCommandList = [] for A in PlatformInfo.ArchList: Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)} diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 711ba492ef..1352fa21c8 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -66,10 +66,11 @@ class PcdClassObject(object): self.expressions = expressions self.DscDefaultValue = None self.DscRawValue = None if IsDsc: self.DscDefaultValue = Value +self.PcdValueFromComm = "" ## Convert the c
[edk2] [Patch] BaseTool: Enhance error message.
Enhance the error message when the PCD from commandline can not be found. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 7b5c7ebc34..9838acb4ed 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1103,14 +1103,15 @@ class DscBuildData(PlatformBuildClassObject): AUTOGEN_ERROR, "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0]) ) GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName,NewValue,("build command options",1)) if not FoundFlag: -if HasTokenSpace: -EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName)) +if pcdname.count(".") > 1: +pcdnamefield = pcdname.split(".") +EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (pcdnamefield[0],pcdnamefield[1])) else: -EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (TokenCName)) +EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (pcdname)) for BuildData in self._Bdb._CACHE_.values(): if BuildData.MetaFile.Ext == '.dec' or BuildData.MetaFile.Ext == '.dsc': continue for key in BuildData.Pcds: PcdItem = BuildData.Pcds[key] -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Support H"{}" format for Sructure Pcd.
Support H"{}" format for Sructure Pcd from CommandLine Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 1 - 1 file changed, 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 9d787702c2..edf90dbd59 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -911,11 +911,10 @@ class DscBuildData(PlatformBuildClassObject): if not ValueStr[1]: EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"') ValueStr = ValueStr[0] + '"' + ValueStr[1:] + '"' PredictedFieldType = "VOID*" elif ValueStr.startswith('H') or ValueStr.startswith('{'): -EdkLogger.error("build", FORMAT_INVALID, 'Currently we do not support assign H"{...}" format for Pcd field.', ExtraData="%s.%s.%s from command line" % (TokenSpaceGuidCName, TokenCName, FieldName)) ValueStr = ValueStr[1:] PredictedFieldType = "VOID*" elif ValueStr.upper() in ['TRUE', '0X1', '0X01', '1', 'FALSE', '0X0', '0X00', '0']: PredictedFieldType = "BOOLEAN" elif ValueStr.isdigit() or ValueStr.upper().startswith('0X'): -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Error handling for PCD datumtype.
Report error if the Pcd DatumType is wrong. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 ++ BaseTools/Source/Python/Workspace/DecBuildData.py | 13 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 711ba492ef..ec7c704fa5 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -66,10 +66,11 @@ class PcdClassObject(object): self.expressions = expressions self.DscDefaultValue = None self.DscRawValue = None if IsDsc: self.DscDefaultValue = Value +self.DefinitionPosition = ("","") ## Convert the class to a string # # Convert each member of the class to string # Organize to a signle line format string @@ -175,10 +176,11 @@ class StructurePcd(PcdClassObject): self.IsFromDsc = PcdObject.IsFromDsc if PcdObject.IsFromDsc else self.IsFromDsc self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue +self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition if type(PcdObject) is StructurePcd: self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index ee00ec0719..4d6edadc8f 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -392,15 +392,11 @@ class DecBuildData(PackageBuildClassObject): struct_pcd.SetDecDefaultValue(item.DefaultValue) else: struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo) struct_pcd.PackageDecs = dep_pkgs -if not struct_pcd.StructuredPcdIncludeFile: -EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,self.MetaFile.File,LineNo )) - str_pcd_set.append(struct_pcd) - return str_pcd_set ## Retrieve PCD declarations for given type def _GetPcd(self, Type): Pcds = sdict() @@ -444,18 +440,27 @@ class DecBuildData(PackageBuildClassObject): None, list(validateranges), list(validlists), list(expressions) ) +PcdObj.DefinitionPosition = (self.MetaFile.File,LineNo) if "." in TokenSpaceGuid: StrPcdSet.append((PcdObj,LineNo)) else: Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdObj StructurePcds = self.ProcessStructurePcd(StrPcdSet) for pcd in StructurePcds: Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd +StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') +for pcd in Pcds.values(): +if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: +if StructPattern.match(pcd.DatumType) == None: +EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", pcd.DefinitionPosition[0],pcd.DefinitionPosition[1]) +for struct_pcd in Pcds.values(): +if isinstance(struct_pcd,StructurePcd) and not struct_pcd.StructuredPcdIncludeFile: +EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,struct_pcd.DefinitionPosition[0],struct_pcd.DefinitionPosition[1] )) return Pcds @property def CommonIncludes(self):
[edk2] [Patch] BaseTools: Pcd Value override issue.
For the case that the structure PCD has no value assignment in DSC, but has value assignment in command line. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index cd633e964d..9d787702c2 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1264,10 +1264,12 @@ class DscBuildData(PlatformBuildClassObject): else: MaxSize = max([len(Pcd.DefaultValue),MaxSize]) Pcd.MaxDatumSize = str(MaxSize) else: PcdInDec = self.DecPcds.get((Name,Guid)) +if isinstance(PcdInDec,StructurePcd): +PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][0] if PcdInDec: if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec) self.Pcds[Name, Guid].DefaultValue = NoFiledValues[( Guid,Name)][0] @@ -1667,30 +1669,30 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) if Pcd.PcdFieldValueFromComm: CApp = CApp + "// From Command Line \n" for FieldName in Pcd.PcdFieldValueFromComm: FieldName = "." + FieldName -IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) -if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): +IsArray = self.IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]) +if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')): try: -Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) +Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % -(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) +(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2])) Value, ValueSize = ParseFieldValue(Value) -CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); +CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]); else: NewFieldName = '' FieldName_ori = FieldName.strip('.') while '[' in FieldName: NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]' ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0]) FieldName = FieldName.split(']', 1)[1] FieldName = NewFieldName + FieldName while '[' in FieldName: FieldName = FieldName.rsplit('[', 1)[0] -CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[
[edk2] [Patch 2/2] BaseTools: Fixed build failed issue.
Case 1. A Pcd has no default sku setting in DSC. Case 2. Build as Single SKU. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 239531cd1c..cd633e964d 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1317,14 +1317,14 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_dec: str_pcd_obj_str = StructurePcd() str_pcd_obj_str.copy(str_pcd_dec) if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) -if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: -str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} -else: -str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} +if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} +else: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str else: @@ -1762,10 +1762,13 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD') inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName] if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'): pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue else: +if not Pcd.DscRawValue: +# handle the case that structure pcd is not appear in DSC +self.CopyDscRawValue(Pcd) pcddefaultvalue = Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName) for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(DefaultStoreName)]: if not FieldList: continue if pcddefaultvalue and FieldList == pcddefaultvalue: @@ -1958,12 +1961,12 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem) CApp = CApp + self.GenerateInitValueStatement(Pcd,skuname,defaultstorenameitem) if skuname == SkuName: break else: -CApp = CApp + "// SkuName: DEFAULT, DefaultStoreName: STANDARD \n" -CApp = CApp + self.GenerateInitValueStatement(Pcd,"DEFAULT","STANDARD") +CApp = CApp + "// SkuName: %s, DefaultStoreName: STANDARD \n" % self.SkuIdMgr.SystemSkuId +CApp = CApp + self.GenerateInitValueStatement(Pcd,self.SkuIdMgr.SystemSkuId,"STANDARD") CApp = CApp + self.GenerateCommandLineValueStatement(Pcd) # # Set new PCD value and size # CApp = CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) @@ -2325,10 +2328,14 @@ class DscBuildData(PlatformBuildClassObject):
[edk2] [Patch 1/2] BaseTools: Fixed Pcd value override issue.
1. Handle the Pcd maxsize issue for the case that the length of Pcd value from CommandLine bigger that its maxsize 2. The Pcd value override in commandline. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 26 --- BaseTools/Source/Python/AutoGen/GenPcdDb.py| 12 -- .../Source/Python/Workspace/BuildClassObject.py| 4 + BaseTools/Source/Python/Workspace/DscBuildData.py | 175 ++--- BaseTools/Source/Python/build/build.py | 2 +- 5 files changed, 157 insertions(+), 62 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index e2589cfbae..439e360955 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1366,31 +1366,10 @@ class PlatformAutoGen(AutoGen): # # Gather dynamic PCDs list from each module and their settings from platform # This interface should be invoked explicitly when platform action is created. # def CollectPlatformDynamicPcds(self): -# Override the platform Pcd's value by build option -if GlobalData.BuildOptionPcd: -for PcdItem in GlobalData.BuildOptionPcd: -PlatformPcd = self.Platform.Pcds.get((PcdItem[1],PcdItem[0])) -if PlatformPcd: -if PlatformPcd.DatumType in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']: -for sku in PlatformPcd.SkuInfoList: -PlatformPcd.SkuInfoList[sku].DefaultValue = PcdItem[2] -else: -PcdDefaultValue = StringToArray(PcdItem[2]) -for sku in PlatformPcd.SkuInfoList: -skuinfo = PlatformPcd.SkuInfoList[sku] -if skuinfo.VariableGuid: -skuinfo.HiiDefaultValue = PcdDefaultValue -else: -skuinfo.DefaultValue = PcdDefaultValue -PlatformPcd.DefaultValue = PcdDefaultValue -if PlatformPcd.MaxDatumSize: -PlatformPcd.MaxDatumSize = str(max([int(PlatformPcd.MaxDatumSize),len(PcdDefaultValue.split(","))])) -else: -PlatformPcd.MaxDatumSize = str(len(PcdDefaultValue.split(","))) for key in self.Platform.Pcds: for SinglePcd in GlobalData.MixedPcd: if (self.Platform.Pcds[key].TokenCName, self.Platform.Pcds[key].TokenSpaceGuidCName) == SinglePcd: for item in GlobalData.MixedPcd[SinglePcd]: @@ -2371,15 +2350,10 @@ class PlatformAutoGen(AutoGen): for PcdItem in GlobalData.MixedPcd: if (ToPcd.TokenCName, ToPcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: TokenCName = PcdItem[0] break if FromPcd != None: -if GlobalData.BuildOptionPcd: -for pcd in GlobalData.BuildOptionPcd: -if (FromPcd.TokenSpaceGuidCName, FromPcd.TokenCName) == (pcd[0], pcd[1]): -FromPcd.DefaultValue = pcd[2] -break if ToPcd.Pending and FromPcd.Type not in [None, '']: ToPcd.Type = FromPcd.Type elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\ and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type): if ToPcd.Type.strip() == "DynamicEx": diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 82360ae57d..e2848e7aaf 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -1182,16 +1182,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): for PcdItem in GlobalData.MixedPcd: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: CName = PcdItem[0] -if GlobalData.BuildOptionPcd: -for PcdItem in GlobalData.BuildOptionPcd: -if (Pcd.TokenSpaceGuidCName, CName) == (PcdItem[0], PcdItem[1]): -Pcd.DefaultValue = PcdItem[2] -break - EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase)) if Pcd.Phase == 'PEI': NumberOfPeiLocalTokens += 1 if Pcd.Phase == 'DXE': @@ -1503,16 +1497,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): for PcdItem in GlobalData.MixedPcd: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: CName = PcdItem[0] -if GlobalD
[edk2] [Patch] BaseTools: Fixed build failed issue.
Case 1. A Pcd has no default sku setting in DSC. Case 2. Build as Single SKU. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 06d2f2fbcd..9dcdcfcf1c 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1304,14 +1304,14 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_dec: str_pcd_obj_str = StructurePcd() str_pcd_obj_str.copy(str_pcd_dec) if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) -if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: -str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} -else: -str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} +if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} +else: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str else: @@ -1729,10 +1729,13 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD') inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName] if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'): pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue else: +if not Pcd.DscRawValue: +# handle the case that structure pcd is not appear in DSC +self.CopyDscRawValue(Pcd) pcddefaultvalue = Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName) for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(DefaultStoreName)]: if not FieldList: continue if pcddefaultvalue and FieldList == pcddefaultvalue: @@ -1925,12 +1928,12 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem) CApp = CApp + self.GenerateInitValueStatement(Pcd,skuname,defaultstorenameitem) if skuname == SkuName: break else: -CApp = CApp + "// SkuName: DEFAULT, DefaultStoreName: STANDARD \n" -CApp = CApp + self.GenerateInitValueStatement(Pcd,"DEFAULT","STANDARD") +CApp = CApp + "// SkuName: %s, DefaultStoreName: STANDARD \n" % self.SkuIdMgr.SystemSkuId +CApp = CApp + self.GenerateInitValueStatement(Pcd,self.SkuIdMgr.SystemSkuId,"STANDARD") CApp = CApp + self.GenerateCommandLineValueStatement(Pcd) # # Set new PCD value and size # CApp = CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) @@ -2292,10 +2295,14 @@ class DscBuildData(PlatformBuildClassObject):
[edk2] [Patch] BaseTools: Fixed Pcd value override issue.
The Pcd value override in commandline. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/BuildClassObject.py| 4 + BaseTools/Source/Python/Workspace/DscBuildData.py | 136 ++--- BaseTools/Source/Python/build/build.py | 2 +- 3 files changed, 121 insertions(+), 21 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index edf2bdf4b9..711ba492ef 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -127,10 +127,12 @@ class StructurePcd(PcdClassObject): self.StructName = None self.PcdDefineLineNo = 0 self.PkgPath = "" self.DefaultValueFromDec = "" self.ValueChain = dict() +self.PcdValueFromComm = "" +self.PcdFieldValueFromComm = collections.OrderedDict({}) def __repr__(self): return self.TypeName def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0): if FieldName in self.DefaultValues: @@ -186,10 +188,12 @@ class StructurePcd(PcdClassObject): self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain +self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm +self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm ## LibraryClassObject # # This Class defines LibraryClassObject used in BuildDatabase # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index a5089a900b..06d2f2fbcd 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1131,14 +1131,15 @@ class DscBuildData(PlatformBuildClassObject): self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_EX_DEFAULT)) self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_EX_HII)) self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_EX_VPD)) self._Pcds = self.CompletePcdValues(self._Pcds) +self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds) self._Pcds = self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, self._Pcds) self._Pcds = self.CompleteHiiPcdsDefaultStores(self._Pcds) self._Pcds = self._FilterPcdBySkuUsage(self._Pcds) -self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds) + self.RecoverCommandLinePcd() return self._Pcds def _dumpPcdInfo(self,Pcds): for pcd in Pcds: @@ -1201,24 +1202,28 @@ class DscBuildData(PlatformBuildClassObject): structure_pcd_data[(item[0],item[1])] = [] structure_pcd_data[(item[0],item[1])].append(item) return structure_pcd_data def OverrideByFdfComm(self,StruPcds): -StructurePcdInCom = {(item[0],item[1],item[2] ):(item[3],item[4]) for item in GlobalData.BuildOptionPcd if len(item) == 5 and (item[1],item[0]) in StruPcds } if GlobalData.BuildOptionPcd else {} +StructurePcdInCom = OrderedDict() +for item in GlobalData.BuildOptionPcd: +if len(item) == 5 and (item[1],item[0]) in StruPcds: +StructurePcdInCom[(item[0],item[1],item[2] )] = (item[3],item[4]) GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()]) for Pcd in StruPcds.values(): if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds: continue -FieldValues = {item[2]:StructurePcdInCom[item] for item in StructurePcdInCom if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]} -for sku in Pcd.SkuOverrideValues: -for defaultstore in Pcd.SkuOverrideValues[sku]: -for field in FieldValues: -if field not in Pcd.SkuOverrideValues[sku][defaultstore]: -Pcd.SkuOverrideValues[sku][defaultstore][field] = ["","",""] -Pcd.SkuOverrideValues[sku][defaultstore][field][0] = FieldValues[field][0] -Pcd.SkuOverrideValues[sku][defaultstore][field][1] = FieldValues[field][1][0] -Pcd.SkuOverrideValues[sku][defaultstore][field][2] = FieldValues[f
[edk2] [Patch 4/4] BaseTools: Improve build performance
Optimized the PcdValueInit.c size. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/BuildClassObject.py| 4 + BaseTools/Source/Python/Workspace/DscBuildData.py | 211 +++-- 2 files changed, 112 insertions(+), 103 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 05a83e84ac..edf2bdf4b9 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -63,10 +63,11 @@ class PcdClassObject(object): self.IsFromDsc = False self.validateranges = validateranges self.validlists = validlists self.expressions = expressions self.DscDefaultValue = None +self.DscRawValue = None if IsDsc: self.DscDefaultValue = Value ## Convert the class to a string # @@ -125,10 +126,11 @@ class StructurePcd(PcdClassObject): self.FlexibleFieldName = None self.StructName = None self.PcdDefineLineNo = 0 self.PkgPath = "" self.DefaultValueFromDec = "" +self.ValueChain = dict() def __repr__(self): return self.TypeName def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0): if FieldName in self.DefaultValues: @@ -170,10 +172,11 @@ class StructurePcd(PcdClassObject): self.IsFromBinaryInf = PcdObject.IsFromBinaryInf if PcdObject.IsFromBinaryInf else self.IsFromBinaryInf self.IsFromDsc = PcdObject.IsFromDsc if PcdObject.IsFromDsc else self.IsFromDsc self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions +self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue if type(PcdObject) is StructurePcd: self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode @@ -182,10 +185,11 @@ class StructurePcd(PcdClassObject): self.SkuOverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath +self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain ## LibraryClassObject # # This Class defines LibraryClassObject used in BuildDatabase # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 29c43e751f..580fcdefc2 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1329,16 +1329,19 @@ class DscBuildData(PlatformBuildClassObject): for skuid in SkuIds: if skuid in stru_pcd.SkuOverrideValues: continue nextskuid = self.SkuIdMgr.GetNextSkuId(skuid) NoDefault = False -while nextskuid not in stru_pcd.SkuOverrideValues: -if nextskuid == "DEFAULT": -NoDefault = True -break -nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) -stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {'STANDARD':stru_pcd.DefaultValues}) +if skuid not in stru_pcd.SkuOverrideValues: +while nextskuid not in stru_pcd.SkuOverrideValues: +if nextskuid == "DEFAULT": +NoDefault = True +break +nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid) +stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorenam
[edk2] [Patch 2/4] BaseTools: Improve build performance
Add cache for building PcdValueInit.c. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/GenFds/GenFds.py | 1 + BaseTools/Source/Python/Workspace/DecBuildData.py | 12 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 172 +++--- 3 files changed, 101 insertions(+), 84 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index dcba9f24cb..cd705630a3 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -324,10 +324,11 @@ def main(): EdkLogger.error("GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." %FvObj.UiFvName) else: FvObj.FvRegionInFD = RegionObj.Size RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, FvObj) +GlobalData.BuildOptionPcd = Options.OptionPcd if Options.OptionPcd else {} """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 61f15086d0..18101a0add 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -93,10 +93,11 @@ class DecBuildData(PackageBuildClassObject): self._PkgUniFile= None self._Protocols = None self._Ppis = None self._Guids = None self._Includes = None +self._CommonIncludes= None self._LibraryClasses= None self._Pcds = None self.__Macros = None self._PrivateProtocols = None self._PrivatePpis = None @@ -294,11 +295,12 @@ class DecBuildData(PackageBuildClassObject): self._PrivateGuids[Name] = PrivateGuidDict[self._Arch, Name] return self._Guids ## Retrieve public include paths declared in this package def _GetInclude(self): -if self._Includes == None: +if self._Includes == None or self._CommonIncludes is None: +self._CommonIncludes = [] self._Includes = [] self._PrivateIncludes = [] PublicInclues = [] RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch] Macros = self._Macros @@ -322,11 +324,12 @@ class DecBuildData(PackageBuildClassObject): else: if File not in PublicInclues: PublicInclues.append(File) if File in self._PrivateIncludes: EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo) - +if Record[3] == "COMMON": +self._CommonIncludes.append(File) return self._Includes ## Retrieve library class declarations (not used in build at present) def _GetLibraryClass(self): if self._LibraryClasses == None: @@ -450,10 +453,15 @@ class DecBuildData(PackageBuildClassObject): StructurePcds = self.ProcessStructurePcd(StrPcdSet) for pcd in StructurePcds: Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd return Pcds +@property +def CommonIncludes(self): +if self._CommonIncludes is None: +self.Includes +return self._CommonIncludes _Macros = property(_GetMacros) Arch = property(_GetArch, _SetArch) PackageName = property(_GetPackageName) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 393ad0265f..59bfd9c8e0 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -35,10 +35,11 @@ from Common.Misc import ProcessDuplicatedInf import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess +from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs # @@ -87,11 +88,10 @@ LIBS = $(LIB_PATH)\Common.lib !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app ''' PcdGccMakefile = ''' -ARCH ?= IA32 MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C LIBS = -lCom
[edk2] [Patch 3/4] BaseTool: GUID assignment fail.
Structure PCD GUID assignment fail. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DecBuildData.py | 3 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 289 ++ 2 files changed, 182 insertions(+), 110 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 18101a0add..ee00ec0719 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -13,10 +13,11 @@ # from Common.String import * from Common.DataType import * from Common.Misc import * from types import * +from collections import OrderedDict from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject ## Platform build information from DEC file # @@ -365,11 +366,11 @@ class DecBuildData(PackageBuildClassObject): self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX)) return self._Pcds def ProcessStructurePcd(self, StructurePcdRawDataSet): -s_pcd_set = dict() +s_pcd_set = OrderedDict() for s_pcd,LineNo in StructurePcdRawDataSet: if s_pcd.TokenSpaceGuidCName not in s_pcd_set: s_pcd_set[s_pcd.TokenSpaceGuidCName] = [] s_pcd_set[s_pcd.TokenSpaceGuidCName].append((s_pcd,LineNo)) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 59bfd9c8e0..29c43e751f 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -37,10 +37,11 @@ from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject +from collections import OrderedDict # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs # PcdValueInitName = 'PcdValueInit' @@ -1281,11 +1282,11 @@ class DscBuildData(PlatformBuildClassObject): if SkuName in SkuIds and "." in TokenSpaceGuid: S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]]) # handle pcd value override StrPcdSet = self.GetStructurePcdInfo(S_PcdSet) -S_pcd_set = {} +S_pcd_set = OrderedDict() for str_pcd in StrPcdSet: str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None) str_pcd_dec = self._DecPcds.get((str_pcd[1], str_pcd[0]), None) if not isinstance (str_pcd_dec, StructurePcd): EdkLogger.error('build', PARSER_ERROR, @@ -1559,10 +1560,181 @@ class DscBuildData(PlatformBuildClassObject): Result = Result + '\\x%02x' % (Value & 0xff) Value = Value >> 8 Result = Result + '"' return Result +def GenerateSizeFunction(self,Pcd): +CApp = "// Default Value in Dec \n" +CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) +for FieldList in [Pcd.DefaultValues]: +if not FieldList: +continue +for FieldName in FieldList: +FieldName = "." + FieldName +IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) +if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): +try: +Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) +except BadExpression: +EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % +(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) +Value, ValueSize = ParseFieldValue(Value) +CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); +else: +NewFieldName = '' +FieldName_ori = FieldName.strip('.') +while '[' in FieldName: +
[edk2] [Patch 1/4] BaseTools: Fixed the pcd value override issue.
1. the issue in the overriding value from command line. 2. dec fully value < dec field assign value < dsc fully value < dsc field assign value Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenMake.py | 39 +++--- .../Source/Python/Workspace/BuildClassObject.py| 4 +++ BaseTools/Source/Python/Workspace/DecBuildData.py | 1 + BaseTools/Source/Python/Workspace/DscBuildData.py | 24 ++--- 4 files changed, 44 insertions(+), 24 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 4b924d21e0..1b0cf17e25 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1549,30 +1549,29 @@ class TopLevelMakefile(BuildFile): if GlobalData.gEnableGenfdsMultiThread: ExtraOption += " --genfds-multi-thread" if GlobalData.gIgnoreSource: ExtraOption += " --ignore-sources" -if GlobalData.BuildOptionPcd: -for index, option in enumerate(GlobalData.gCommand): -if "--pcd" == option and GlobalData.gCommand[index+1]: -pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') -for Item in GlobalData.BuildOptionPcd: -if '.'.join(Item[0:2]) == pcdName: -pcdValue = Item[2] -if pcdValue.startswith('L') or pcdValue.startswith('"'): -pcdValue, Size = ParseFieldValue(pcdValue) -NewVal = '{' -for S in range(Size): -NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff) -NewVal += ',' -pcdValue = NewVal[:-1] + '}' -break -if pcdValue.startswith('{'): -pcdValue = 'H' + '"' + pcdValue + '"' -ExtraOption += " --pcd " + pcdName + '=' + pcdValue -else: -ExtraOption += " --pcd " + GlobalData.gCommand[index+1] +for index, option in enumerate(GlobalData.gCommand): +if "--pcd" == option and GlobalData.gCommand[index+1]: +pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') +for Item in GlobalData.BuildOptionPcd: +if '.'.join(Item[0:2]) == pcdName: +pcdValue = Item[2] +if pcdValue.startswith('L') or pcdValue.startswith('"'): +pcdValue, Size = ParseFieldValue(pcdValue) +NewVal = '{' +for S in range(Size): +NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff) +NewVal += ',' +pcdValue = NewVal[:-1] + '}' +break +if pcdValue.startswith('{'): +pcdValue = 'H' + '"' + pcdValue + '"' +ExtraOption += " --pcd " + pcdName + '=' + pcdValue +else: +ExtraOption += " --pcd " + GlobalData.gCommand[index+1] MakefileName = self._FILE_NAME_[self._FileType] SubBuildCommandList = [] for A in PlatformInfo.ArchList: Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)} diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index f499cbd58b..05a83e84ac 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -124,19 +124,22 @@ class StructurePcd(PcdClassObject): self.SkuOverrideValues = collections.OrderedDict({}) self.FlexibleFieldName = None self.StructName = None self.PcdDefineLineNo = 0 self.PkgPath = "" +self.DefaultValueFromDec = "" def __repr__(self): return self.TypeName def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0): if FieldName in self.DefaultValues: del self.DefaultValues[FieldName] self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo] return self.DefaultValues[FieldName] +def SetDecDefaultValue(self,DefaultValue): +self.DefaultValueFromDec = DefaultValue def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0): if SkuName not in self.SkuOverrideValues: self.SkuOverrideValues[SkuName] = collections.OrderedDict({}) if DefaultStoreName not in self.SkuOverrideValues[SkuName]: self.SkuOverri
[edk2] [Patch] BaseTool: GUID assignment fail.
Structure PCD GUID assignment fail. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DecBuildData.py | 3 ++- BaseTools/Source/Python/Workspace/DscBuildData.py | 11 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 18101a0add..ee00ec0719 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -13,10 +13,11 @@ # from Common.String import * from Common.DataType import * from Common.Misc import * from types import * +from collections import OrderedDict from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject ## Platform build information from DEC file # @@ -365,11 +366,11 @@ class DecBuildData(PackageBuildClassObject): self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX)) return self._Pcds def ProcessStructurePcd(self, StructurePcdRawDataSet): -s_pcd_set = dict() +s_pcd_set = OrderedDict() for s_pcd,LineNo in StructurePcdRawDataSet: if s_pcd.TokenSpaceGuidCName not in s_pcd_set: s_pcd_set[s_pcd.TokenSpaceGuidCName] = [] s_pcd_set[s_pcd.TokenSpaceGuidCName].append((s_pcd,LineNo)) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 3246a2afd8..ae937dee46 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -37,10 +37,11 @@ from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject +from collections import OrderedDict # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs # PcdValueInitName = 'PcdValueInit' @@ -1272,11 +1273,11 @@ class DscBuildData(PlatformBuildClassObject): if SkuName in SkuIds and "." in TokenSpaceGuid: S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]]) # handle pcd value override StrPcdSet = self.GetStructurePcdInfo(S_PcdSet) -S_pcd_set = {} +S_pcd_set = OrderedDict() for str_pcd in StrPcdSet: str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None) str_pcd_dec = self._DecPcds.get((str_pcd[1], str_pcd[0]), None) if not isinstance (str_pcd_dec, StructurePcd): EdkLogger.error('build', PARSER_ERROR, @@ -1597,11 +1598,11 @@ class DscBuildData(PlatformBuildClassObject): if not FieldList: continue for FieldName in FieldList: FieldName = "." + FieldName IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) -if IsArray: +if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) @@ -1627,11 +1628,11 @@ class DscBuildData(PlatformBuildClassObject): if not FieldList: continue for FieldName in FieldList: FieldName = "." + FieldName IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) -if IsArray: +if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCNa
[edk2] [Patch 2/2] BaseTools: Fixed the pcd value override issue.
1. the issue in the overriding value from command line. 2. dec fully value < dec field assign value < dsc fully value < dsc field assign value Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenMake.py | 27 +++--- .../Source/Python/Workspace/BuildClassObject.py| 4 BaseTools/Source/Python/Workspace/DecBuildData.py | 1 + BaseTools/Source/Python/Workspace/DscBuildData.py | 24 +++ 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index afe6f2f99c..110174fb17 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1549,24 +1549,23 @@ class TopLevelMakefile(BuildFile): if GlobalData.gEnableGenfdsMultiThread: ExtraOption += " --genfds-multi-thread" if GlobalData.gIgnoreSource: ExtraOption += " --ignore-sources" -if GlobalData.BuildOptionPcd: -for index, option in enumerate(GlobalData.gCommand): -if "--pcd" == option and GlobalData.gCommand[index+1]: -pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') -if pcdValue.startswith('H'): -pcdValue = 'H' + '"' + pcdValue[1:] + '"' -ExtraOption += " --pcd " + pcdName + '=' + pcdValue -elif pcdValue.startswith("L'"): -ExtraOption += "--pcd " + pcdName + '=' + pcdValue -elif pcdValue.startswith('L'): -pcdValue = 'L' + '"' + pcdValue[1:] + '"' -ExtraOption += " --pcd " + pcdName + '=' + pcdValue -else: -ExtraOption += " --pcd " + GlobalData.gCommand[index+1] +for index, option in enumerate(GlobalData.gCommand): +if "--pcd" == option and GlobalData.gCommand[index+1]: +pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') +if pcdValue.startswith('H'): +pcdValue = 'H' + '"' + pcdValue[1:] + '"' +ExtraOption += " --pcd " + pcdName + '=' + pcdValue +elif pcdValue.startswith("L'"): +ExtraOption += "--pcd " + pcdName + '=' + pcdValue +elif pcdValue.startswith('L'): +pcdValue = 'L' + '"' + pcdValue[1:] + '"' +ExtraOption += " --pcd " + pcdName + '=' + pcdValue +else: +ExtraOption += " --pcd " + GlobalData.gCommand[index+1] MakefileName = self._FILE_NAME_[self._FileType] SubBuildCommandList = [] for A in PlatformInfo.ArchList: Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)} diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index f499cbd58b..05a83e84ac 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -124,19 +124,22 @@ class StructurePcd(PcdClassObject): self.SkuOverrideValues = collections.OrderedDict({}) self.FlexibleFieldName = None self.StructName = None self.PcdDefineLineNo = 0 self.PkgPath = "" +self.DefaultValueFromDec = "" def __repr__(self): return self.TypeName def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0): if FieldName in self.DefaultValues: del self.DefaultValues[FieldName] self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo] return self.DefaultValues[FieldName] +def SetDecDefaultValue(self,DefaultValue): +self.DefaultValueFromDec = DefaultValue def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0): if SkuName not in self.SkuOverrideValues: self.SkuOverrideValues[SkuName] = collections.OrderedDict({}) if DefaultStoreName not in self.SkuOverrideValues[SkuName]: self.SkuOverrideValues[SkuName][DefaultStoreName] = collections.OrderedDict({}) @@ -173,10 +176,11 @@ class StructurePcd(PcdClassObject): self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode self.DefaultFromDSC=None +self.DefaultValueFromDec = PcdObject.Def
[edk2] [Patch 1/2] BaseTools: Improve build performance
Add cache for building PcdValueInit.c. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/GenFds/GenFds.py | 1 + BaseTools/Source/Python/Workspace/DecBuildData.py | 12 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 168 +++--- 3 files changed, 99 insertions(+), 82 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index dcba9f24cb..cd705630a3 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -324,10 +324,11 @@ def main(): EdkLogger.error("GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." %FvObj.UiFvName) else: FvObj.FvRegionInFD = RegionObj.Size RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, FvObj) +GlobalData.BuildOptionPcd = Options.OptionPcd if Options.OptionPcd else {} """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 99c3bf14f1..f029169489 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -93,10 +93,11 @@ class DecBuildData(PackageBuildClassObject): self._PkgUniFile= None self._Protocols = None self._Ppis = None self._Guids = None self._Includes = None +self._CommonIncludes= None self._LibraryClasses= None self._Pcds = None self.__Macros = None self._PrivateProtocols = None self._PrivatePpis = None @@ -294,11 +295,12 @@ class DecBuildData(PackageBuildClassObject): self._PrivateGuids[Name] = PrivateGuidDict[self._Arch, Name] return self._Guids ## Retrieve public include paths declared in this package def _GetInclude(self): -if self._Includes == None: +if self._Includes == None or self._CommonIncludes is None: +self._CommonIncludes = [] self._Includes = [] self._PrivateIncludes = [] PublicInclues = [] RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch] Macros = self._Macros @@ -322,11 +324,12 @@ class DecBuildData(PackageBuildClassObject): else: if File not in PublicInclues: PublicInclues.append(File) if File in self._PrivateIncludes: EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo) - +if Record[3] == "COMMON": +self._CommonIncludes.append(File) return self._Includes ## Retrieve library class declarations (not used in build at present) def _GetLibraryClass(self): if self._LibraryClasses == None: @@ -449,10 +452,15 @@ class DecBuildData(PackageBuildClassObject): StructurePcds = self.ProcessStructurePcd(StrPcdSet) for pcd in StructurePcds: Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd return Pcds +@property +def CommonIncludes(self): +if self._CommonIncludes is None: +self.Includes +return self._CommonIncludes _Macros = property(_GetMacros) Arch = property(_GetArch, _SetArch) PackageName = property(_GetPackageName) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 75b877a5aa..5d2922ba44 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -35,10 +35,11 @@ from Common.Misc import ProcessDuplicatedInf import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess +from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs # @@ -87,11 +88,10 @@ LIBS = $(LIB_PATH)\Common.lib !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app ''' PcdGccMakefile = ''' -ARCH ?= IA32 MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C LIBS = -lComm
[edk2] [Patch] BaseTools: Improve build performance
Add cache for building PcdValueInit.c. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/GenFds/GenFds.py | 1 + BaseTools/Source/Python/Workspace/DscBuildData.py | 150 +++--- 2 files changed, 78 insertions(+), 73 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index dcba9f24cb..cd705630a3 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -324,10 +324,11 @@ def main(): EdkLogger.error("GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." %FvObj.UiFvName) else: FvObj.FvRegionInFD = RegionObj.Size RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, FvObj) +GlobalData.BuildOptionPcd = Options.OptionPcd if Options.OptionPcd else {} """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 0da3efbb43..70dd83cfbc 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -35,10 +35,11 @@ from Common.Misc import ProcessDuplicatedInf import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess +from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs # @@ -154,12 +155,14 @@ class DscBuildData(PlatformBuildClassObject): self._Target = Target self._Toolchain = Toolchain self._ToolChainFamily = None self._Clear() self._HandleOverridePath() +self.WorkspaceDir = "" if os.getenv("WORKSPACE"): self.OutputPath = os.path.join(os.getenv("WORKSPACE"), 'Build', PcdValueInitName) +self.WorkspaceDir = os.getenv("WORKSPACE") else: self.OutputPath = os.path.dirname(self.DscFile) self.DefaultStores = None self.SkuIdMgr = SkuClass(self.SkuName, self.SkuIds) @@ -1289,11 +1292,11 @@ class DscBuildData(PlatformBuildClassObject): str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} else: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: -str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5]) +str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str else: EdkLogger.error('build', PARSER_ERROR, "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch), File=self.MetaFile,Line = StrPcdSet[str_pcd][0][5]) @@ -1781,14 +1784,14 @@ class DscBuildData(PlatformBuildClassObject): for IncludeFile in Pcd.StructuredPcdIncludeFile: if IncludeFile not in Includes: Includes[IncludeFile] = True CApp = CApp + '#include <%s>\n' % (IncludeFile) CApp = CApp + '\n' - for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] -if not Pcd.SkuOverrideValues: +if not Pcd.SkuOverrideValues or Pcd.Ty
[edk2] [Patch] BaseTools: Improve build performance
Add cache for building PcdValueInit.c. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 140 +++--- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 0da3efbb43..6d8486aa19 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -35,10 +35,11 @@ from Common.Misc import ProcessDuplicatedInf import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes import Common.GlobalData as GlobalData import subprocess +from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject # # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs # @@ -1815,13 +1816,11 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + PcdMainCEntry + '\n' if not os.path.exists(self.OutputPath): os.makedirs(self.OutputPath) CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName) -File = open (CAppBaseFileName + '.c', 'w') -File.write(CApp) -File.close() +SaveFileOnChange(CAppBaseFileName + '.c', CApp, False) MakeApp = PcdMakefileHeader if sys.platform == "win32": MakeApp = MakeApp + 'ARCH = IA32\nAPPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = ' else: @@ -1897,92 +1896,95 @@ class DscBuildData(PlatformBuildClassObject): MakeApp += CC_FLAGS if sys.platform == "win32": MakeApp = MakeApp + PcdMakefileEnd MakeFileName = os.path.join(self.OutputPath, 'Makefile') -File = open (MakeFileName, 'w') -File.write(MakeApp) -File.close() +SaveFileOnChange(MakeFileName, MakeApp, False) InputValueFile = os.path.join(self.OutputPath, 'Input.txt') OutputValueFile = os.path.join(self.OutputPath, 'Output.txt') -File = open (InputValueFile, 'w') -File.write(InitByteValue) -File.close() - -Messages = '' -if sys.platform == "win32": -MakeCommand = 'nmake clean & nmake -f %s' % (MakeFileName) -returncode, StdOut, StdErr = self.ExecuteCommand (MakeCommand) -Messages = StdOut -else: -MakeCommand = 'make clean & make -f %s' % (MakeFileName) -returncode, StdOut, StdErr = self.ExecuteCommand (MakeCommand) -Messages = StdErr -Messages = Messages.split('\n') -MessageGroup = [] -if returncode <>0: -CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName) -File = open (CAppBaseFileName + '.c', 'r') -FileData = File.readlines() -File.close() -for Message in Messages: -if " error" in Message or "warning" in Message: -FileInfo = Message.strip().split('(') -if len (FileInfo) > 1: -FileName = FileInfo [0] -FileLine = FileInfo [1].split (')')[0] -else: -FileInfo = Message.strip().split(':') -FileName = FileInfo [0] -FileLine = FileInfo [1] -if FileLine.isdigit(): -error_line = FileData[int (FileLine) - 1] -if r"//" in error_line: -c_line,dsc_line = error_line.split(r"//") -else: -dsc_line = error_line -message_itmes = Message.split(":") -Index = 0 -if "PcdValueInit.c" not in Message: -break -else: -for item in message_itmes: -if "PcdValueInit.c" in item: -Index = message_itmes.index(item) -message_itmes[Index] = dsc_line.strip() -break - MessageGroup.append(":".join(message_itmes[Index:]).strip()) -continue -else: -MessageGroup.append(Message) -if MessageGroup: -EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".join(MessageGroup) ) -else: -EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % MakeCommand) +SaveFileOnChange(InputValueFile, InitByteValue, False) PcdValueIn
[edk2] [Patch] BaseTools: Fixed incorrect Structure Pcd Value.
When structurePCD only has overall value assigned in Dsc under different SKU, the value under default sku is used. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 8833034a1e..0da3efbb43 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1283,11 +1283,14 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_dec: str_pcd_obj_str = StructurePcd() str_pcd_obj_str.copy(str_pcd_dec) if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) -str_pcd_obj_str.DefaultFromDSC = str_pcd_obj_str.DefaultValue +if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} +else: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str else: @@ -1301,12 +1304,14 @@ class DscBuildData(PlatformBuildClassObject): str_pcd_obj_str = StructurePcd() str_pcd_obj_str.copy(self._DecPcds[Pcd]) str_pcd_obj = Pcds.get(Pcd, None) if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) -if str_pcd_obj.DefaultValue: -str_pcd_obj_str.DefaultFromDSC = str_pcd_obj.DefaultValue +if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} +else: +str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} S_pcd_set[Pcd] = str_pcd_obj_str if S_pcd_set: GlobalData.gStructurePcd[self.Arch] = S_pcd_set for stru_pcd in S_pcd_set.values(): for skuid in SkuIds: @@ -1695,29 +1700,30 @@ class DscBuildData(PlatformBuildClassObject): for skuname in self.SkuIdMgr.GetSkuChain(SkuName): inherit_OverrideValues = Pcd.SkuOverrideValues[skuname] storeset = [DefaultStoreName] if DefaultStoreName == 'STANDARD' else ['STANDARD', DefaultStoreName] for defaultstorenameitem in storeset: CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem) -for FieldList in [Pcd.DefaultFromDSC,inherit_OverrideValues.get(defaultstorenameitem)]: +pcddefaultvalue = Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue +for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(defaultstorenameitem)]: if not FieldList: continue -if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC: +if pcddefaultvalue and FieldList == pcddefaultvalue: IsArray = self.IsFieldValueAnArray(FieldList) if IsArray: try: FieldList = ValueExpressionEx(FieldList, "VOID*")(True) except BadE
[edk2] [Patch] BaseTool: Fixed Pcd issues.
1. Check variable offset when merging Hii Pcds 2. Fixed the issue of Hii value inherit with default store. 3. Error handling for incorrect structure pcd declare. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenVar.py | 19 ++- .../Source/Python/Workspace/BuildClassObject.py| 1 + BaseTools/Source/Python/Workspace/DecBuildData.py | 7 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 152 +++-- 4 files changed, 100 insertions(+), 79 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 1389d7ff62..d222e6ed5e 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -102,14 +102,31 @@ class VariableMgr(object): data = value_list[0] value_list = [] for data_byte in pack(data_flag,int(data,16) if data.upper().startswith('0X') else int(data)): value_list += [hex(unpack("B",data_byte)[0])] newvalue[int(item.var_offset,16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list -newvaluestr = "{" + ",".join(reduce(lambda x,y: x+y, [newvalue[k] for k in sorted(newvalue.keys())] )) +"}" +try: +newvaluestr = "{" + ",".join(self.assemble_variable(newvalue)) +"}" +except: +EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join([item.pcdname for item in sku_var_info_offset_list]))) n = sku_var_info_offset_list[0] indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , "VOID*")] self.VarInfo = [item[0] for item in indexedvarinfo.values()] + +def assemble_variable(self, valuelist): +ordered_value = [valuelist[k] for k in sorted(valuelist.keys())] +ordered_offset = sorted(valuelist.keys()) +var_value = [] +num = 0 +for offset in ordered_offset: +if offset < len(var_value): +raise +for _ in xrange(offset - len(var_value)): +var_value.append('0x00') +var_value += ordered_value[num] +num +=1 +return var_value def process_variable_data(self): var_data = dict() indexedvarinfo = collections.OrderedDict() diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 0e1161c96f..f499cbd58b 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -112,10 +112,11 @@ class StructurePcd(PcdClassObject): def __init__(self, StructuredPcdIncludeFile=None, Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList=None, IsOverrided=False, GuidValue=None, validateranges=None, validlists=None, expressions=None,default_store = TAB_DEFAULT_STORES_DEFAULT): if SkuInfoList is None: SkuInfoList={} if validateranges is None: validateranges=[] if validlists is None: validlists=[] if expressions is None : expressions=[] +if Packages is None : Packages = [] super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, validlists, expressions) self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile self.PackageDecs = Packages self.DefaultStoreName = [default_store] self.DefaultValues = collections.OrderedDict({}) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 2266b0b7a6..99c3bf14f1 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -387,10 +387,12 @@ class DecBuildData(PackageBuildClassObject): struct_pcd.PkgPath = self.MetaFile.File else: struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo) struct_pcd.PackageDecs = dep_pkgs +if not struct_pcd.StructuredPcdIncludeFile: +EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,self.MetaFile.File,LineNo )) str_pcd_set.append(struct_pcd) return str_pcd_set @@ -421,15 +423,10 @@ class DecBuildData(PackageBuildClassObject): Setting,LineNo = PcdDict[self._Arch, Pcd
[edk2] [Patch] BaseTools: Fixed Build failed issue.
If the PCD is not used in DSC file and user set that PCD value from Command line, build will fail. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 1da4f03ab8..6e3cd0f3f1 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -896,11 +896,12 @@ class DscBuildData(PlatformBuildClassObject): else: pcdobj = self._Pcds.get((pcd[1],pcd[0])) if pcdobj: pcdset.append((pcd[0],pcd[1], pcdobj.DefaultValue)) else: -pcdset.append((pcd[0],pcd[1],pcd[3])) +pcdvalue = pcd[3] if len(pcd) == 4 else pcd[2] +pcdset.append((pcd[0],pcd[1],pcdvalue)) GlobalData.BuildOptionPcd = pcdset def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName): PredictedFieldType = "VOID*" if ValueStr.startswith('L'): if not ValueStr[1]: @@ -2163,14 +2164,18 @@ class DscBuildData(PlatformBuildClassObject): for pcd in Pcds.values(): SkuInfoObj = pcd.SkuInfoList.values()[0] pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName] +pcd.DatumType = pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue == None): sku.HiiDefaultValue = pcdDecObject.DefaultValue +for default_store in sku.DefaultStoreDict: + sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue +pcd.DefaultValue = pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys(): valuefromDec = pcdDecObject.DefaultValue SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec}) pcd.SkuInfoList['DEFAULT'] = SkuInfo elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys(): -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTool: Add comments in PcdValueInit.c.
Add Comments for __FLEXIBLE_SIZE () statement. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 012e16a488..214e4fd569 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1325,42 +1325,44 @@ class DscBuildData(PlatformBuildClassObject): for FieldName in FieldList: FieldName = "." + FieldName IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray: Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0]) -CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0));\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip(".")); +CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); else: NewFieldName = '' +FieldName_ori = FieldName.strip('.') while '[' in FieldName: NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]' ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0]) FieldName = FieldName.split(']', 1)[1] FieldName = NewFieldName + FieldName while '[' in FieldName: FieldName = FieldName.rsplit('[', 1)[0] -CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1) +CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) for skuname in self.SkuIdMgr.GetSkuChain(SkuName): inherit_OverrideValues = Pcd.SkuOverrideValues[skuname] for FieldList in [inherit_OverrideValues.get(DefaultStoreName)]: if not FieldList: continue for FieldName in FieldList: FieldName = "." + FieldName IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray: Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0]) -CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0));\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip(".")); +CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); else: NewFieldName = '' +FieldName_ori = FieldName.strip('.') while '[' in FieldName: NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]' ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0]) FieldName = FieldName.split(']', 1)[1] FieldName = NewFieldName + FieldName while '[' in FieldName: FieldName = FieldName.rsplit('[', 1)[0] -CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1) +CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.
[edk2] [Patch] BaseTool: Enhance error handling.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 116 - .../Source/Python/Workspace/MetaFileParser.py | 3 + 2 files changed, 70 insertions(+), 49 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index bc77d1a2b4..9d8da6ed85 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -856,11 +856,11 @@ class DscBuildData(PlatformBuildClassObject): if not Valid: EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo, ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName)) if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT): if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip() != ValueList[1].strip(): -EdkLogger.error('build', FORMAT_INVALID, ErrStr , File=self.MetaFile, Line=LineNo, +EdkLogger.error('build', FORMAT_INVALID, "Pcd datumtype used in DSC file is not the same as its declaration in DEC file." , File=self.MetaFile, Line=LineNo, ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting)) return ValueList def _FilterPcdBySkuUsage(self,Pcds): available_sku = self.SkuIdMgr.AvailableSkuIdSet @@ -1009,17 +1009,20 @@ class DscBuildData(PlatformBuildClassObject): StrPcdSet = self.GetStructurePcdInfo(S_PcdSet) S_pcd_set = {} for str_pcd in StrPcdSet: str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None) str_pcd_dec = self._DecPcds.get((str_pcd[1], str_pcd[0]), None) +if not isinstance (str_pcd_dec, StructurePcd): +EdkLogger.error('build', PARSER_ERROR, +"Pcd (%s.%s) is not declared as Structure PCD in DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch), +File=self.MetaFile,Line = StrPcdSet[str_pcd][0][5]) if str_pcd_dec: str_pcd_obj_str = StructurePcd() str_pcd_obj_str.copy(str_pcd_dec) if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) -if str_pcd_obj.DefaultValue: -str_pcd_obj_str.DefaultFromDSC = str_pcd_obj.DefaultValue +str_pcd_obj_str.DefaultFromDSC = str_pcd_obj_str.DefaultValue for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str else: @@ -1153,11 +1156,11 @@ class DscBuildData(PlatformBuildClassObject): if SkuName not in AvailableSkuIdSet: EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, File=self.MetaFile, Line=Dummy5) if SkuName in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'): if "." not in TokenSpaceGuid: -PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy4)) +PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy5)) PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] = Setting for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdSet: Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid, SkuName] if Setting == None: @@ -1262,16 +1265,13 @@ class DscBuildData(PlatformBuildClassObject): def ExecuteCommand (self, Command): try: Process = subprocess.Popen(Command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) except: -print 'ERROR: Can not execute command:', Command -sys.exit(1) +EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command) Result = Process.communicate() -if Process.returncode <> 0: -print 'ERROR: Can not collect output from command:', Command -return Result[0], Result[1] +return Process.returncode, Result[0], Result[1] def IntToCString(self, Value, ValueSize): Result = '"' if not isinstance (Value, str): for Index in range(0, ValueSize): @@ -1383,11 +1383,11 @@ class DscBuildData(PlatformBuildClassObject): for FieldName in FieldList: IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
[edk2] [Patch] BaseTools: Structure Pcd in CommandLine.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py| 110 +++- BaseTools/Source/Python/Common/Expression.py | 2 +- BaseTools/Source/Python/Common/Misc.py| 2 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 1 + BaseTools/Source/Python/GenFds/GenFds.py | 4 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 210 +- BaseTools/Source/Python/build/build.py| 2 +- 7 files changed, 233 insertions(+), 98 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 1cf50e872f..405bfa145a 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -396,100 +396,22 @@ class WorkspaceAutoGen(AutoGen): # apply SKU and inject PCDs from Flash Definition file for Arch in self.ArchList: Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] -DecPcds = {} -DecPcdsKey = set() -PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch) -if GlobalData.BuildOptionPcd: -for i, pcd in enumerate(GlobalData.BuildOptionPcd): -if type(pcd) is tuple: -continue -(pcdname, pcdvalue) = pcd.split('=') -if not pcdvalue: -EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname)) -if '.' in pcdname: -(TokenSpaceGuidCName, TokenCName) = pcdname.split('.') -HasTokenSpace = True -else: -TokenCName = pcdname -TokenSpaceGuidCName = '' -HasTokenSpace = False -TokenSpaceGuidCNameList = [] -FoundFlag = False -PcdDatumType = '' -NewValue = '' -for package in PGen.PackageList: -Guids = package.Guids -self._GuidDict.update(Guids) -for package in PGen.PackageList: -for key in package.Pcds: -PcdItem = package.Pcds[key] -if HasTokenSpace: -if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName): -PcdDatumType = PcdItem.DatumType -if pcdvalue.startswith('H'): -try: -pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) -except BadExpression, Value: -if Value.result > 1: -EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % - (TokenSpaceGuidCName, TokenCName, pcdvalue, Value)) -pcdvalue = 'H' + pcdvalue -NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) -FoundFlag = True -else: -if PcdItem.TokenCName == TokenCName: -if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList: -if len (TokenSpaceGuidCNameList) < 1: - TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName) -PcdDatumType = PcdItem.DatumType -TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName -if pcdvalue.startswith('H'): -try: -pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) -except BadExpression, Value: -EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % - (TokenSpaceGuidCName, TokenCName, pcdvalue, Value)) -pcdvalue = 'H' + pcdvalue -NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) -FoundFlag = True -
[edk2] [Patch] BaseTools: Support multiple .h file
for structure Pcd declaration in DEC file. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 +- BaseTools/Source/Python/Workspace/DecBuildData.py | 2 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 8 BaseTools/Source/Python/Workspace/MetaFileParser.py | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 3afb27a9c0..0e1161c96f 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -113,11 +113,11 @@ class StructurePcd(PcdClassObject): if SkuInfoList is None: SkuInfoList={} if validateranges is None: validateranges=[] if validlists is None: validlists=[] if expressions is None : expressions=[] super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, validlists, expressions) -self.StructuredPcdIncludeFile = StructuredPcdIncludeFile +self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile self.PackageDecs = Packages self.DefaultStoreName = [default_store] self.DefaultValues = collections.OrderedDict({}) self.PcdMode = None self.SkuOverrideValues = collections.OrderedDict({}) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index f6b908dee6..2fd3820dcc 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -374,11 +374,11 @@ class DecBuildData(PackageBuildClassObject): for pcdname in s_pcd_set: dep_pkgs = [] struct_pcd = StructurePcd() for item,LineNo in s_pcd_set[pcdname]: if "" in item.TokenCName: -struct_pcd.StructuredPcdIncludeFile = item.DefaultValue + struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue) elif "" in item.TokenCName: dep_pkgs.append(item.DefaultValue) elif item.DatumType == item.TokenCName: struct_pcd.copy(item) struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip() diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 256fdd6875..0384b96997 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1669,14 +1669,14 @@ class DscBuildData(PlatformBuildClassObject): CApp = PcdMainCHeader Includes = {} for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] -IncludeFile = Pcd.StructuredPcdIncludeFile -if IncludeFile not in Includes: -Includes[IncludeFile] = True -CApp = CApp + '#include <%s>\n' % (IncludeFile) +for IncludeFile in Pcd.StructuredPcdIncludeFile: +if IncludeFile not in Includes: +Includes[IncludeFile] = True +CApp = CApp + '#include <%s>\n' % (IncludeFile) CApp = CApp + '\n' for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] if not Pcd.SkuOverrideValues: diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 8f4b5e5cc1..4359ba4b33 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1889,26 +1889,28 @@ class DecParser(MetaFileParser): self._ValueList[0] = self._CurrentStructurePcdName if "|" not in self._CurrentLine: if "" == self._CurrentLine: self._include_flag = True +self._package_flag = False self._ValueList = None return if "" == self._CurrentLine: self._package_flag = True self._ValueList = None +self._include_flag = False return if self._include_flag: self._ValueList[1] = "_" + md5.new(self._CurrentLine).hexdigest() self._ValueList[2] = self._CurrentLine -self._include_flag = False if self._package_flag and "}" != self._CurrentLine: self._ValueList[1] = "_" + md5.new(self._CurrentLine).hexdigest() self._ValueList[2] = self._CurrentLine if self._CurrentLine == "}":
[edk2] [Patch] BaseTools: Structure Pcd in CommandLine.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py| 110 +++- BaseTools/Source/Python/Common/Expression.py | 2 +- BaseTools/Source/Python/Common/Misc.py| 2 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 1 + BaseTools/Source/Python/GenFds/GenFds.py | 4 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 210 +- 6 files changed, 232 insertions(+), 97 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index ab178c9a4a..0a253ff3bc 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -396,100 +396,22 @@ class WorkspaceAutoGen(AutoGen): # apply SKU and inject PCDs from Flash Definition file for Arch in self.ArchList: Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] -DecPcds = {} -DecPcdsKey = set() -PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch) -if GlobalData.BuildOptionPcd: -for i, pcd in enumerate(GlobalData.BuildOptionPcd): -if type(pcd) is tuple: -continue -(pcdname, pcdvalue) = pcd.split('=') -if not pcdvalue: -EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname)) -if '.' in pcdname: -(TokenSpaceGuidCName, TokenCName) = pcdname.split('.') -HasTokenSpace = True -else: -TokenCName = pcdname -TokenSpaceGuidCName = '' -HasTokenSpace = False -TokenSpaceGuidCNameList = [] -FoundFlag = False -PcdDatumType = '' -NewValue = '' -for package in PGen.PackageList: -Guids = package.Guids -self._GuidDict.update(Guids) -for package in PGen.PackageList: -for key in package.Pcds: -PcdItem = package.Pcds[key] -if HasTokenSpace: -if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName): -PcdDatumType = PcdItem.DatumType -if pcdvalue.startswith('H'): -try: -pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) -except BadExpression, Value: -if Value.result > 1: -EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % - (TokenSpaceGuidCName, TokenCName, pcdvalue, Value)) -pcdvalue = 'H' + pcdvalue -NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) -FoundFlag = True -else: -if PcdItem.TokenCName == TokenCName: -if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList: -if len (TokenSpaceGuidCNameList) < 1: - TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName) -PcdDatumType = PcdItem.DatumType -TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName -if pcdvalue.startswith('H'): -try: -pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) -except BadExpression, Value: -EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % - (TokenSpaceGuidCName, TokenCName, pcdvalue, Value)) -pcdvalue = 'H' + pcdvalue -NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) -FoundFlag = True -else: -
[edk2] [Patch] BaseTool: Enhance error handling.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 113 - .../Source/Python/Workspace/MetaFileParser.py | 3 + 2 files changed, 68 insertions(+), 48 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index bc77d1a2b4..bebd4feda0 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -856,11 +856,11 @@ class DscBuildData(PlatformBuildClassObject): if not Valid: EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo, ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName)) if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT): if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip() != ValueList[1].strip(): -EdkLogger.error('build', FORMAT_INVALID, ErrStr , File=self.MetaFile, Line=LineNo, +EdkLogger.error('build', FORMAT_INVALID, "Pcd datumtype used in DSC file is not the same as its declaration in DEC file." , File=self.MetaFile, Line=LineNo, ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting)) return ValueList def _FilterPcdBySkuUsage(self,Pcds): available_sku = self.SkuIdMgr.AvailableSkuIdSet @@ -1009,17 +1009,20 @@ class DscBuildData(PlatformBuildClassObject): StrPcdSet = self.GetStructurePcdInfo(S_PcdSet) S_pcd_set = {} for str_pcd in StrPcdSet: str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None) str_pcd_dec = self._DecPcds.get((str_pcd[1], str_pcd[0]), None) +if not isinstance (str_pcd_dec, StructurePcd): +EdkLogger.error('build', PARSER_ERROR, +"Pcd (%s.%s) is not declared as Structure PCD in DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch), +File=self.MetaFile,Line = StrPcdSet[str_pcd][0][5]) if str_pcd_dec: str_pcd_obj_str = StructurePcd() str_pcd_obj_str.copy(str_pcd_dec) if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) -if str_pcd_obj.DefaultValue: -str_pcd_obj_str.DefaultFromDSC = str_pcd_obj.DefaultValue +str_pcd_obj_str.DefaultFromDSC = str_pcd_obj_str.DefaultValue for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[3] in SkuIds: str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5]) S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str else: @@ -1153,11 +1156,11 @@ class DscBuildData(PlatformBuildClassObject): if SkuName not in AvailableSkuIdSet: EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName, File=self.MetaFile, Line=Dummy5) if SkuName in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'): if "." not in TokenSpaceGuid: -PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy4)) +PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy5)) PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] = Setting for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdSet: Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid, SkuName] if Setting == None: @@ -1262,16 +1265,13 @@ class DscBuildData(PlatformBuildClassObject): def ExecuteCommand (self, Command): try: Process = subprocess.Popen(Command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) except: -print 'ERROR: Can not execute command:', Command -sys.exit(1) +EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command) Result = Process.communicate() -if Process.returncode <> 0: -print 'ERROR: Can not collect output from command:', Command -return Result[0], Result[1] +return Process.returncode, Result[0], Result[1] def IntToCString(self, Value, ValueSize): Result = '"' if not isinstance (Value, str): for Index in range(0, ValueSize): @@ -1383,11 +1383,11 @@ class DscBuildData(PlatformBuildClassObject): for FieldName in FieldList: IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
[edk2] [Patch] BaseTool: Fixed the StructurePcd incorrect value.
If user not set Structure overall value in Dsc, Structure Pcd value would be incorrect. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index e5f1f01556..947ac1f466 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -65,11 +65,11 @@ class PcdClassObject(object): self.validlists = validlists self.expressions = expressions self.DscDefaultValue = None if IsDsc: self.DscDefaultValue = Value - + ## Convert the class to a string # # Convert each member of the class to string # Organize to a signle line format string # @@ -107,11 +107,15 @@ class PcdClassObject(object): # def __hash__(self): return hash((self.TokenCName, self.TokenSpaceGuidCName)) class StructurePcd(PcdClassObject): -def __init__(self, StructuredPcdIncludeFile="", Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList={}, IsOverrided=False, GuidValue=None, validateranges=[], validlists=[], expressions=[],default_store = TAB_DEFAULT_STORES_DEFAULT): +def __init__(self, StructuredPcdIncludeFile=None, Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList=None, IsOverrided=False, GuidValue=None, validateranges=None, validlists=None, expressions=None,default_store = TAB_DEFAULT_STORES_DEFAULT): +if SkuInfoList is None: SkuInfoList={} +if validateranges is None: validateranges=[] +if validlists is None: validlists=[] +if expressions is None : expressions=[] super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, validlists, expressions) self.StructuredPcdIncludeFile = StructuredPcdIncludeFile self.PackageDecs = Packages self.DefaultStoreName = [default_store] self.DefaultValues = collections.OrderedDict({}) @@ -435,6 +439,5 @@ class PlatformBuildClassObject(object): # # @retval string Key for hash table # def __hash__(self): return hash(self.MetaFile) - -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fixed incorrect VPD size.
The VPD size is incorrect if that VPD is not used in Module. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Feng Bob C Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index ce8bc64ca5..848378f3d4 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1744,18 +1744,16 @@ class PlatformAutoGen(AutoGen): # Not found, it should be signature if not FoundFlag : # just pick the a value to determine whether is unicode string type SkuValueMap = {} +SkuObjList = DscPcdEntry.SkuInfoList.items() DefaultSku = DscPcdEntry.SkuInfoList.get('DEFAULT') if DefaultSku: -PcdValue = DefaultSku.DefaultValue -if PcdValue not in SkuValueMap: -SkuValueMap[PcdValue] = [] -VpdFile.Add(DscPcdEntry, 'DEFAULT',DefaultSku.VpdOffset) -SkuValueMap[PcdValue].append(DefaultSku) -for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items(): +defaultindex = SkuObjList.index(('DEFAULT',DefaultSku)) +SkuObjList[0],SkuObjList[defaultindex] = SkuObjList[defaultindex],SkuObjList[0] +for (SkuName,Sku) in SkuObjList: Sku.VpdOffset = Sku.VpdOffset.strip() # Need to iterate DEC pcd information to get the value & datumtype for eachDec in self.PackageList: for DecPcd in eachDec.Pcds: -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Fixed some small issues 1. The structure pcd default value should use the default value under sku. 2. Incorrect VpdOffset value for those un-used in module Vpd 3. Add a check
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 4 ++-- BaseTools/Source/Python/Workspace/DscBuildData.py | 7 +-- BaseTools/Source/Python/Workspace/MetaFileParser.py | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 604d38a4d6..ce8bc64ca5 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1749,12 +1749,12 @@ class PlatformAutoGen(AutoGen): DefaultSku = DscPcdEntry.SkuInfoList.get('DEFAULT') if DefaultSku: PcdValue = DefaultSku.DefaultValue if PcdValue not in SkuValueMap: SkuValueMap[PcdValue] = [] -VpdFile.Add(DscPcdEntry, 'DEFAULT',Sku.VpdOffset) -SkuValueMap[PcdValue].append(Sku) +VpdFile.Add(DscPcdEntry, 'DEFAULT',DefaultSku.VpdOffset) +SkuValueMap[PcdValue].append(DefaultSku) for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items(): Sku.VpdOffset = Sku.VpdOffset.strip() # Need to iterate DEC pcd information to get the value & datumtype for eachDec in self.PackageList: diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 60aa4868ed..6e4f8ac390 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1287,12 +1287,15 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' UINT32 OriginalSize;\n' CApp = CApp + ' VOID*OriginalPcd;\n' CApp = CApp + ' %s *Pcd; // From %s Line %d \n' % (Pcd.DatumType, Pcd.PkgPath, Pcd.PcdDefineLineNo) CApp = CApp + '\n' -Pcd.DefaultValue = Pcd.DefaultValue.strip() -PcdDefaultValue = StringToArray(Pcd.DefaultValue) +if SkuName in Pcd.SkuInfoList: +DefaultValue = Pcd.SkuInfoList[SkuName].DefaultStoreDict.get(DefaultStoreName,Pcd.SkuInfoList[SkuName].HiiDefaultValue) if Pcd.SkuInfoList[SkuName].HiiDefaultValue else Pcd.SkuInfoList[SkuName].DefaultValue +else: +DefaultValue = Pcd.DefaultValue +PcdDefaultValue = StringToArray(DefaultValue.strip()) InitByteValue += '%s.%s.%s.%s|%s|%s\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumType, PcdDefaultValue) # # Get current PCD value and size diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 7469cd7ab7..f404db7b7a 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1915,10 +1915,13 @@ class DecParser(MetaFileParser): PcdTockens = self._CurrentLine.split(TAB_VALUE_SPLIT) PcdNames = PcdTockens[0].split(TAB_SPLIT) if len(PcdNames) == 2: self._CurrentStructurePcdName = "" else: +if self._CurrentStructurePcdName != TAB_SPLIT.join(PcdNames[:2]): +EdkLogger.error('Parser', FORMAT_INVALID, "Pcd Name does not match: %s and %s " % (self._CurrentStructurePcdName , TAB_SPLIT.join(PcdNames[:2])), +File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList[1] = TAB_SPLIT.join(PcdNames[2:]) self._ValueList[2] = PcdTockens[1] if not self._CurrentStructurePcdName: TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT) -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Add comments for the Structure Pcd definition in PcdValueInit.c file
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 4 BaseTools/Source/Python/Workspace/DecBuildData.py | 2 ++ BaseTools/Source/Python/Workspace/DscBuildData.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 0e3081cfc5..8d02e78b27 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -117,10 +117,12 @@ class StructurePcd(PcdClassObject): self.DefaultValues = collections.OrderedDict({}) self.PcdMode = None self.SkuOverrideValues = collections.OrderedDict({}) self.FlexibleFieldName = None self.StructName = None +self.PcdDefineLineNo = 0 +self.PkgPath = "" def __repr__(self): return self.TypeName def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0): if FieldName in self.DefaultValues: @@ -169,10 +171,12 @@ class StructurePcd(PcdClassObject): self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode self.DefaultFromDSC=None self.SkuOverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName +self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo +self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath ## LibraryClassObject # # This Class defines LibraryClassObject used in BuildDatabase # diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 13fb8686b6..2fd3820dcc 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -381,10 +381,12 @@ class DecBuildData(PackageBuildClassObject): dep_pkgs.append(item.DefaultValue) elif item.DatumType == item.TokenCName: struct_pcd.copy(item) struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip() struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".") +struct_pcd.PcdDefineLineNo = LineNo +struct_pcd.PkgPath = self.MetaFile.File else: struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo) struct_pcd.PackageDecs = dep_pkgs diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b042c4306a..60aa4868ed 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1284,11 +1284,11 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' UINT32 Size;\n' CApp = CApp + ' UINT32 FieldSize;\n' CApp = CApp + ' CHAR8 *Value;\n' CApp = CApp + ' UINT32 OriginalSize;\n' CApp = CApp + ' VOID*OriginalPcd;\n' -CApp = CApp + ' %s *Pcd;\n' % (Pcd.DatumType) +CApp = CApp + ' %s *Pcd; // From %s Line %d \n' % (Pcd.DatumType, Pcd.PkgPath, Pcd.PcdDefineLineNo) CApp = CApp + '\n' Pcd.DefaultValue = Pcd.DefaultValue.strip() PcdDefaultValue = StringToArray(Pcd.DefaultValue) -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [Patch] BaseTools: Support multiple .h file for structure Pcd declaration in DEC file.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 4 ++-- BaseTools/Source/Python/Workspace/DecBuildData.py | 2 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 8 BaseTools/Source/Python/Workspace/MetaFileParser.py | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index e5f1f01556..0e3081cfc5 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -107,13 +107,13 @@ class PcdClassObject(object): # def __hash__(self): return hash((self.TokenCName, self.TokenSpaceGuidCName)) class StructurePcd(PcdClassObject): -def __init__(self, StructuredPcdIncludeFile="", Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList={}, IsOverrided=False, GuidValue=None, validateranges=[], validlists=[], expressions=[],default_store = TAB_DEFAULT_STORES_DEFAULT): +def __init__(self, StructuredPcdIncludeFile=None, Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList={}, IsOverrided=False, GuidValue=None, validateranges=[], validlists=[], expressions=[],default_store = TAB_DEFAULT_STORES_DEFAULT): super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, validlists, expressions) -self.StructuredPcdIncludeFile = StructuredPcdIncludeFile +self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile self.PackageDecs = Packages self.DefaultStoreName = [default_store] self.DefaultValues = collections.OrderedDict({}) self.PcdMode = None self.SkuOverrideValues = collections.OrderedDict({}) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 01f716bfab..13fb8686b6 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -374,11 +374,11 @@ class DecBuildData(PackageBuildClassObject): for pcdname in s_pcd_set: dep_pkgs = [] struct_pcd = StructurePcd() for item,LineNo in s_pcd_set[pcdname]: if "" in item.TokenCName: -struct_pcd.StructuredPcdIncludeFile = item.DefaultValue + struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue) elif "" in item.TokenCName: dep_pkgs.append(item.DefaultValue) elif item.DatumType == item.TokenCName: struct_pcd.copy(item) struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip() diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 4a87fd1762..b042c4306a 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1455,14 +1455,14 @@ class DscBuildData(PlatformBuildClassObject): CApp = PcdMainCHeader Includes = {} for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] -IncludeFile = Pcd.StructuredPcdIncludeFile -if IncludeFile not in Includes: -Includes[IncludeFile] = True -CApp = CApp + '#include <%s>\n' % (IncludeFile) +for IncludeFile in Pcd.StructuredPcdIncludeFile: +if IncludeFile not in Includes: +Includes[IncludeFile] = True +CApp = CApp + '#include <%s>\n' % (IncludeFile) CApp = CApp + '\n' for PcdName in StructuredPcds: Pcd = StructuredPcds[PcdName] if not Pcd.SkuOverrideValues: diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index b2b0e282eb..7469cd7ab7 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1889,26 +1889,28 @@ class DecParser(MetaFileParser): self._ValueList[0] = self._CurrentStructurePcdName if "|" not in self._CurrentLine: if "" == self._CurrentLine: self._include_flag = True +self._package_flag = False self._ValueList = None return if "" == self._CurrentLine: self._package_flag = True self._ValueList = None +self._include_flag = False
[edk2] [Patch] BaseTool: Combine the HiiPcd value if they link to same Variable
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +- BaseTools/Source/Python/AutoGen/GenVar.py | 36 -- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 0f7454f55a..604d38a4d6 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1404,11 +1404,11 @@ class PlatformAutoGen(AutoGen): continue if len(Sku.VariableName) > 0: VariableGuidStructure = Sku.VariableGuidValue VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure) for StorageName in Sku.DefaultStoreDict: - VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType)) + VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableOffset, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType)) Index += 1 return VariableInfo def UpdateNVStoreMaxSize(self,OrgVpdFile): if self.VariableInfo: diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 65d0bea36c..1389d7ff62 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -19,11 +19,11 @@ import collections import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections -var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_attribute,pcd_default_value, default_value, data_type") +var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type") NvStorageHeaderSize = 28 VariableHeaderSize = 32 def StringArrayToList(StringArray): StringArray = StringArray[1:-1] @@ -74,11 +74,42 @@ class VariableMgr(object): value_str = "{" default_var_bin_strip = [ data.strip("""'""") for data in default_var_bin] value_str += ",".join(default_var_bin_strip) value_str += "}" return value_str - +def combine_variable(self): +indexedvarinfo = collections.OrderedDict() +for item in self.VarInfo: +if (item.skuname,item.defaultstoragename, item.var_name,item.var_guid) not in indexedvarinfo: +indexedvarinfo[(item.skuname,item.defaultstoragename, item.var_name,item.var_guid) ] = [] +indexedvarinfo[(item.skuname,item.defaultstoragename, item.var_name,item.var_guid)].append(item) +for key in indexedvarinfo: +sku_var_info_offset_list = indexedvarinfo[key] +if len(sku_var_info_offset_list) == 1: +continue +newvalue = {} +for item in sku_var_info_offset_list: +data_type = item.data_type +value_list = item.default_value.strip("{").strip("}").split(",") +if data_type in ["BOOLEAN","UINT8","UINT16","UINT32","UINT64"]: +if data_type == ["BOOLEAN","UINT8"]: +data_flag = "=B" +elif data_type == "UINT16": +data_flag = "=H" +elif data_type == "UINT32": +data_flag = "=L" +elif data_type == "UINT64": +data_flag = "=Q" +data = value_list[0] +value_list = [] +for data_byte in pack(data_flag,int(data,16) if data.upper().startswith('0X') else int(data)): +value_list += [hex(unpack("B",data_byte)[0])] +newvalue[int(item.var_offset,16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list +newvaluestr = "{" + ",".join(reduce(lambda x,y: x+y, [newvalue[k] for k in sorted(newvalue.keys())] )) +"}" +n = sku_var_info_offset_list[0] +indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , "VOID*")] +self.VarInfo = [item[0] for item in indexedvarinfo.values()] def process_variable_data(self): var_data = dict() indexedvarinfo = collections.OrderedDict() @@ -132,10 +163,11 @@ class VariableMgr(object): var_data[(skuid,defaultstoragename)] = collectio
[edk2] [Patch] BaseTools: Fixed build failure for the case that A pcd is initialized under one SKU but is uninitialized under another SKU.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 22283ef7fe..82360ae57d 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -1022,10 +1022,23 @@ def CreateAutoGen(PcdDriverAutoGenData): return (PcdDriverAutoGenData[(skuname,skuid)][0],autogenC) def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): def prune_sku(pcd,skuname): new_pcd = copy.deepcopy(pcd) new_pcd.SkuInfoList = {skuname:pcd.SkuInfoList[skuname]} +new_pcd.isinit = 'INIT' +if new_pcd.DatumType in ['UINT8','UINT16','UINT32','UINT64']: +for skuobj in pcd.SkuInfoList.values(): +if skuobj.DefaultValue: +defaultvalue = int(skuobj.DefaultValue,16) if skuobj.DefaultValue.upper().startswith("0X") else int(skuobj.DefaultValue,10) +if defaultvalue != 0: +new_pcd.isinit = "INIT" +break +elif skuobj.VariableName: +new_pcd.isinit = "INIT" +break +else: +new_pcd.isinit = "UNINIT" return new_pcd DynamicPcds = Platform.DynamicPcdList DynamicPcdSet_Sku = {(SkuName,skuobj.SkuId):[] for pcd in DynamicPcds for (SkuName,skuobj) in pcd.SkuInfoList.items() } for skuname,skuid in DynamicPcdSet_Sku: DynamicPcdSet_Sku[(skuname,skuid)] = [prune_sku(pcd,skuname) for pcd in DynamicPcds] @@ -1399,12 +1412,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): if "PCD_TYPE_HII" not in Pcd.TokenTypeList: Pcd.TokenTypeList += ['PCD_TYPE_DATA'] if Sku.DefaultValue == 'TRUE': Pcd.InitString = 'INIT' else: -if int(Sku.DefaultValue, 0) != 0: -Pcd.InitString = 'INIT' +Pcd.InitString = Pcd.isinit # # For UNIT64 type PCD's value, ULL should be append to avoid # warning under linux building environment. # if Pcd.DatumType == "UINT64": -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel