From 4afd3d042215afe68d00b9ab8c32f063a3a1c03f Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Fri, 23 Aug 2013 02:18:16 +0000 Subject: Sync BaseTool trunk (version r2599) into EDKII BaseTools. Signed-off-by: Liming Gao Reviewed-by: Heshen Chen git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14591 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/AutoGen/AutoGen.py | 19 +- BaseTools/Source/Python/AutoGen/GenC.py | 4 +- BaseTools/Source/Python/AutoGen/UniClassObject.py | 12 +- BaseTools/Source/Python/Common/BuildVersion.py | 2 +- BaseTools/Source/Python/Common/DataType.py | 73 +++- .../Source/Python/Common/EdkIIWorkspaceBuild.py | 2 +- BaseTools/Source/Python/Common/Expression.py | 10 +- BaseTools/Source/Python/Common/FdfParserLite.py | 6 +- .../Source/Python/Common/MigrationUtilities.py | 4 +- BaseTools/Source/Python/Common/Misc.py | 138 +++++++- BaseTools/Source/Python/Common/PyUtility.pyd | Bin 4608 -> 6144 bytes BaseTools/Source/Python/Common/String.py | 26 +- .../Source/Python/CommonDataClass/CommonClass.py | 4 +- .../Source/Python/CommonDataClass/ModuleClass.py | 2 +- .../Source/Python/CommonDataClass/PlatformClass.py | 2 +- BaseTools/Source/Python/Ecc/Check.py | 2 +- BaseTools/Source/Python/Eot/EfiCompressor.pyd | Bin 8192 -> 11264 bytes BaseTools/Source/Python/Eot/LzmaCompressor.pyd | Bin 53248 -> 14848 bytes BaseTools/Source/Python/GNUmakefile | 2 +- BaseTools/Source/Python/GenFds/Fd.py | 9 +- BaseTools/Source/Python/GenFds/FdfParser.py | 68 +++- BaseTools/Source/Python/GenFds/FfsFileStatement.py | 2 + BaseTools/Source/Python/GenFds/FfsInfStatement.py | 5 + BaseTools/Source/Python/GenFds/GenFds.py | 2 +- .../Source/Python/GenFds/GenFdsGlobalVariable.py | 22 +- BaseTools/Source/Python/GenFds/VerSection.py | 2 +- BaseTools/Source/Python/Makefile | 6 + BaseTools/Source/Python/TargetTool/TargetTool.py | 4 +- BaseTools/Source/Python/UPT/BuildVersion.py | 2 +- BaseTools/Source/Python/UPT/Library/DataType.py | 23 +- BaseTools/Source/Python/UPT/Library/GlobalData.py | 5 + BaseTools/Source/Python/UPT/Library/String.py | 4 +- .../UPT/Object/Parser/InfUserExtensionObject.py | 26 +- .../Source/Python/UPT/Parser/InfAsBuiltProcess.py | 143 ++++++-- .../Python/UPT/Parser/InfLibrarySectionParser.py | 21 +- .../Source/Python/Workspace/MetaFileParser.py | 391 +++++++++++---------- .../Source/Python/Workspace/WorkspaceCommon.py | 237 +++++++++++++ .../Source/Python/Workspace/WorkspaceDatabase.py | 93 +++-- BaseTools/Source/Python/build/BuildReport.py | 18 +- BaseTools/Source/Python/build/build.py | 68 ++-- 40 files changed, 1065 insertions(+), 394 deletions(-) create mode 100644 BaseTools/Source/Python/Workspace/WorkspaceCommon.py (limited to 'BaseTools/Source/Python') diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 3261892bc5..6711880f60 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -293,12 +293,13 @@ class WorkspaceAutoGen(AutoGen): Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] DecPcds = {} + DecPcdsKey = set() PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch) Pkgs = PGen.PackageList for Pkg in Pkgs: for Pcd in Pkg.Pcds: DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd] - Platform.IsPlatformPcdDeclared(DecPcds) + DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2])) Platform.SkuName = self.SkuId for Name, Guid in PcdSet: @@ -310,7 +311,21 @@ class WorkspaceAutoGen(AutoGen): File = self.FdfProfile.PcdFileLineDict[Name, Guid][0], Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1] ) - Platform.AddPcd(Name, Guid, PcdSet[Name, Guid]) + 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, + "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] + ) Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch) # diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index fafcd70b86..2eb920417e 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -2043,7 +2043,8 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH): if 'PcdLib' in Info.Module.LibraryClasses or Info.Module.Pcds: AutoGenH.Append("#include \n") - AutoGenH.Append('\nextern GUID gEfiCallerIdGuid;\n\n') + AutoGenH.Append('\nextern GUID gEfiCallerIdGuid;') + AutoGenH.Append('\nextern CHAR8 *gEfiCallerBaseName;\n\n') if Info.IsLibrary: return @@ -2066,6 +2067,7 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH): # Publish the CallerId Guid # AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = %s;\n' % GuidStringToGuidStructureString(Info.Guid)) + AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gEfiCallerBaseName = "%s";\n' % Info.Name) ## Create common code for header file # diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index ea27607fce..7b1ce72ea7 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -1,4 +1,4 @@ -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -38,6 +38,9 @@ LF = u'\u000A' NULL = u'\u0000' TAB = u'\t' BACK_SPLASH = u'\\' +DOBULE_QUOTED_SPLASH = u'\\"' +SIGLE_QUOTED_SPLASH = u"\\'" +TAB_BACK_SLASH = u"\\/" gIncludePattern = re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", re.MULTILINE | re.UNICODE) @@ -334,11 +337,11 @@ class UniFileClassObject(object): Line = Line.replace(u'/language', u'#language') Line = Line.replace(u'/include', u'#include') + Line = Line.replace(u'\\\\', u'\u0006') Line = Line.replace(UNICODE_WIDE_CHAR, WIDE_CHAR) Line = Line.replace(UNICODE_NARROW_CHAR, NARROW_CHAR) Line = Line.replace(UNICODE_NON_BREAKING_CHAR, NON_BREAKING_CHAR) - Line = Line.replace(u'\\\\', u'\u0006') Line = Line.replace(u'\\r\\n', CR + LF) Line = Line.replace(u'\\n', CR + LF) Line = Line.replace(u'\\r', CR) @@ -346,7 +349,10 @@ class UniFileClassObject(object): Line = Line.replace(u'''\"''', u'''"''') Line = Line.replace(u'\t', u' ') Line = Line.replace(u'\u0006', u'\\') - + Line = Line.replace(DOBULE_QUOTED_SPLASH, u'"') + Line = Line.replace(SIGLE_QUOTED_SPLASH, u"'") + Line = Line.replace(TAB_BACK_SLASH, u"/") + # if Line.find(u'\\x'): # hex = Line[Line.find(u'\\x') + 2 : Line.find(u'\\x') + 6] # hex = "u'\\u" + hex + "'" diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py index 0323fafa3c..7414d30f49 100644 --- a/BaseTools/Source/Python/Common/BuildVersion.py +++ b/BaseTools/Source/Python/Common/BuildVersion.py @@ -13,4 +13,4 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # -gBUILD_VERSION = "Build 2524" +gBUILD_VERSION = "" diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index e5e7eaeede..3a82362100 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -1,7 +1,8 @@ ## @file # This file is used to define common static strings used by INF/DEC/DSC files # -# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2012, 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 # which accompanies this distribution. The full text of the license may be found at @@ -18,6 +19,7 @@ TAB_COMMENT_EDK_START = '/*' TAB_COMMENT_EDK_END = '*/' TAB_COMMENT_EDK_SPLIT = '//' TAB_COMMENT_SPLIT = '#' +TAB_SPECIAL_COMMENT = '##' TAB_EQUAL_SPLIT = '=' TAB_VALUE_SPLIT = '|' TAB_COMMA_SPLIT = ',' @@ -26,10 +28,18 @@ TAB_SEMI_COLON_SPLIT = ';' TAB_SECTION_START = '[' TAB_SECTION_END = ']' TAB_OPTION_START = '<' -TAB_OPTION_END = '>' +TAB_OPTION_END = '>' TAB_SLASH = '\\' TAB_BACK_SLASH = '/' TAB_LINE_BREAK = '\n' +TAB_PRINTCHAR_VT = '\x0b' +TAB_PRINTCHAR_BS = '\b' +TAB_PRINTCHAR_NUL = '\0' +TAB_UINT8 = 'UINT8' +TAB_UINT16 = 'UINT16' +TAB_UINT32 = 'UINT32' +TAB_UINT64 = 'UINT64' +TAB_VOID = 'VOID*' TAB_EDK_SOURCE = '$(EDK_SOURCE)' TAB_EFI_SOURCE = '$(EFI_SOURCE)' @@ -42,8 +52,9 @@ TAB_ARCH_X64 = 'X64' TAB_ARCH_IPF = 'IPF' TAB_ARCH_ARM = 'ARM' TAB_ARCH_EBC = 'EBC' +TAB_ARCH_AARCH64 = 'AARCH64' -ARCH_LIST = [TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC] +ARCH_LIST = [TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64] ARCH_LIST_FULL = [TAB_ARCH_COMMON] + ARCH_LIST SUP_MODULE_BASE = 'BASE' @@ -75,7 +86,7 @@ EDK_COMPONENT_TYPE_BS_DRIVER = 'BS_DRIVER' EDK_COMPONENT_TYPE_RT_DRIVER = 'RT_DRIVER' EDK_COMPONENT_TYPE_SAL_RT_DRIVER = 'SAL_RT_DRIVER' EDK_COMPONENT_TYPE_APPLICATION = 'APPLICATION' -EDK_NAME = 'EDK' +EDK_NAME = 'EDK' EDKII_NAME = 'EDKII' BINARY_FILE_TYPE_FW = 'FW' @@ -109,6 +120,7 @@ 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 @@ -117,6 +129,7 @@ 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 @@ -125,6 +138,7 @@ 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 @@ -133,6 +147,7 @@ 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 @@ -141,6 +156,7 @@ 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 @@ -149,6 +165,7 @@ 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 @@ -157,6 +174,7 @@ TAB_LIBRARY_CLASSES_X64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_X64 TAB_LIBRARY_CLASSES_IPF = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_IPF TAB_LIBRARY_CLASSES_ARM = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_ARM TAB_LIBRARY_CLASSES_EBC = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_EBC +TAB_LIBRARY_CLASSES_AARCH64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PACKAGES = 'Packages' TAB_PACKAGES_COMMON = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_COMMON @@ -165,6 +183,7 @@ TAB_PACKAGES_X64 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_X64 TAB_PACKAGES_IPF = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_IPF TAB_PACKAGES_ARM = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_ARM TAB_PACKAGES_EBC = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_EBC +TAB_PACKAGES_AARCH64 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS = 'Pcds' TAB_PCDS_FIXED_AT_BUILD = 'FixedAtBuild' @@ -192,6 +211,7 @@ TAB_PCDS_FIXED_AT_BUILD_X64 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + T TAB_PCDS_FIXED_AT_BUILD_IPF = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_FIXED_AT_BUILD_ARM = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_FIXED_AT_BUILD_EBC = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_FIXED_AT_BUILD_AARCH64 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_PATCHABLE_IN_MODULE_NULL = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE TAB_PCDS_PATCHABLE_IN_MODULE_COMMON = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_COMMON @@ -200,6 +220,7 @@ TAB_PCDS_PATCHABLE_IN_MODULE_X64 = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB TAB_PCDS_PATCHABLE_IN_MODULE_IPF = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_PATCHABLE_IN_MODULE_ARM = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_PATCHABLE_IN_MODULE_EBC = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_PATCHABLE_IN_MODULE_AARCH64 = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_FEATURE_FLAG_NULL = TAB_PCDS + TAB_PCDS_FEATURE_FLAG TAB_PCDS_FEATURE_FLAG_COMMON = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_COMMON @@ -208,6 +229,7 @@ TAB_PCDS_FEATURE_FLAG_X64 = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_A TAB_PCDS_FEATURE_FLAG_IPF = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_FEATURE_FLAG_ARM = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_FEATURE_FLAG_EBC = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_FEATURE_FLAG_AARCH64 = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_DYNAMIC_EX_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_EX TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_EX_DEFAULT @@ -219,6 +241,7 @@ TAB_PCDS_DYNAMIC_EX_X64 = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_ TAB_PCDS_DYNAMIC_EX_IPF = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_DYNAMIC_EX_ARM = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_DYNAMIC_EX_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_DYNAMIC_EX_AARCH64 = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_DYNAMIC_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC TAB_PCDS_DYNAMIC_DEFAULT_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_DEFAULT @@ -230,6 +253,7 @@ TAB_PCDS_DYNAMIC_X64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_X64 TAB_PCDS_DYNAMIC_IPF = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_DYNAMIC_ARM = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_DYNAMIC_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_DYNAMIC_AARCH64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCD_DYNAMIC_TYPE_LIST = [TAB_PCDS_DYNAMIC_DEFAULT_NULL, TAB_PCDS_DYNAMIC_VPD_NULL, TAB_PCDS_DYNAMIC_HII_NULL] TAB_PCD_DYNAMIC_EX_TYPE_LIST = [TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, TAB_PCDS_DYNAMIC_EX_VPD_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL] @@ -254,6 +278,7 @@ TAB_DEPEX_X64 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_X64 TAB_DEPEX_IPF = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_IPF TAB_DEPEX_ARM = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_ARM TAB_DEPEX_EBC = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_EBC +TAB_DEPEX_AARCH64 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_SKUIDS = 'SkuIds' @@ -264,6 +289,7 @@ TAB_LIBRARIES_X64 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_X64 TAB_LIBRARIES_IPF = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_IPF TAB_LIBRARIES_ARM = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_ARM TAB_LIBRARIES_EBC = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_EBC +TAB_LIBRARIES_AARCH64 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_COMPONENTS = 'Components' TAB_COMPONENTS_COMMON = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_COMMON @@ -272,6 +298,7 @@ TAB_COMPONENTS_X64 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_X64 TAB_COMPONENTS_IPF = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_IPF TAB_COMPONENTS_ARM = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_ARM TAB_COMPONENTS_EBC = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_EBC +TAB_COMPONENTS_AARCH64 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_COMPONENTS_SOURCE_OVERRIDE_PATH = 'SOURCE_OVERRIDE_PATH' @@ -328,6 +355,25 @@ TAB_INF_FEATURE_PCD = 'FeaturePcd' TAB_INF_PATCH_PCD = 'PatchPcd' TAB_INF_PCD = 'Pcd' TAB_INF_PCD_EX = 'PcdEx' +TAB_INF_USAGE_PRO = 'PRODUCES' +TAB_INF_USAGE_SOME_PRO = 'SOMETIMES_PRODUCES' +TAB_INF_USAGE_CON = 'CONSUMES' +TAB_INF_USAGE_SOME_CON = 'SOMETIMES_CONSUMES' +TAB_INF_USAGE_NOTIFY = 'NOTIFY' +TAB_INF_USAGE_TO_START = 'TO_START' +TAB_INF_USAGE_BY_START = 'BY_START' +TAB_INF_GUIDTYPE_EVENT = 'Event' +TAB_INF_GUIDTYPE_FILE = 'File' +TAB_INF_GUIDTYPE_FV = 'FV' +TAB_INF_GUIDTYPE_GUID = 'GUID' +TAB_INF_GUIDTYPE_HII = 'HII' +TAB_INF_GUIDTYPE_HOB = 'HOB' +TAB_INF_GUIDTYPE_ST = 'SystemTable' +TAB_INF_GUIDTYPE_TSG = 'TokenSpaceGuid' +TAB_INF_GUIDTYPE_VAR = 'Variable' +TAB_INF_GUIDTYPE_PROTOCOL = 'PROTOCOL' +TAB_INF_GUIDTYPE_PPI = 'PPI' +TAB_INF_GUIDTYPE_UNDEFINED = 'UNDEFINED' # # Dec Definitions @@ -430,3 +476,22 @@ TAB_BRG_LIBRARY = 'Library' # Build Rule File Version Definition # TAB_BUILD_RULE_VERSION = "build_rule_version" + +# section name for PCDs +PCDS_DYNAMIC_DEFAULT = "PcdsDynamicDefault" +PCDS_DYNAMIC_VPD = "PcdsDynamicVpd" +PCDS_DYNAMIC_HII = "PcdsDynamicHii" +PCDS_DYNAMICEX_DEFAULT = "PcdsDynamicExDefault" +PCDS_DYNAMICEX_VPD = "PcdsDynamicExVpd" +PCDS_DYNAMICEX_HII = "PcdsDynamicExHii" + +# Section allowed to have items after arch +SECTIONS_HAVE_ITEM_AFTER_ARCH = [TAB_LIBRARY_CLASSES.upper(), TAB_DEPEX.upper(), TAB_USER_EXTENSIONS.upper(), + PCDS_DYNAMIC_DEFAULT.upper(), + PCDS_DYNAMIC_VPD.upper(), + PCDS_DYNAMIC_HII.upper(), + PCDS_DYNAMICEX_DEFAULT.upper(), + PCDS_DYNAMICEX_VPD.upper(), + PCDS_DYNAMICEX_HII.upper(), + TAB_BUILD_OPTIONS.upper(), + TAB_INCLUDES.upper()] diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py index 26a9b324e6..2b5990ebe7 100644 --- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py +++ b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py @@ -405,7 +405,7 @@ class ItemBuild(object): # # @var WorkspaceDir: To store value for WorkspaceDir # @var SupArchList: To store value for SupArchList, selection scope is in below list -# EBC | IA32 | X64 | IPF | ARM | PPC +# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64 # @var BuildTarget: To store value for WorkspaceDir, selection scope is in below list # RELEASE | DEBUG # @var SkuId: To store value for SkuId diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 80fad7563d..3c8d14e6ce 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -246,12 +246,14 @@ class ValueExpression(object): # @return: True or False if RealValue is False # Evaluated value of string format if RealValue is True # - def __call__(self, RealValue=False): + def __call__(self, RealValue=False, Depth=0): if self._NoProcess: return self._Expr + self._Depth = Depth + self._Expr = self._Expr.strip() - if RealValue: + if RealValue and Depth == 0: self._Token = self._Expr if self.__IsNumberToken(): return self._Expr @@ -471,7 +473,7 @@ class ValueExpression(object): Ex = BadExpression(ERR_PCD_RESOLVE % self._Token) Ex.Pcd = self._Token raise Ex - self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True) + self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True, self._Depth+1) if type(self._Token) != type(''): self._LiteralToken = hex(self._Token) return @@ -551,7 +553,7 @@ class ValueExpression(object): if Match and not Expr[Match.end():Match.end()+1].isalnum() \ and Expr[Match.end():Match.end()+1] != '_': self._Idx += Match.end() - self._Token = ValueExpression(GuidStringToGuidStructureString(Expr[0:Match.end()]))(True) + self._Token = ValueExpression(GuidStringToGuidStructureString(Expr[0:Match.end()]))(True, self._Depth+1) return self._Token elif self.__IsIdChar(Ch): return self.__GetIdToken() diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py index 87595df1e7..031dc15bc7 100644 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ b/BaseTools/Source/Python/Common/FdfParserLite.py @@ -2769,7 +2769,7 @@ class FdfParser(object): raise Warning("expected '.' At Line ", self.FileName, self.CurrentLineNumber) Arch = self.__SkippedChars.rstrip(".") - if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "COMMON"): + if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH64", "COMMON"): raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber) ModuleType = self.__GetModuleType() @@ -3356,7 +3356,7 @@ class FdfParser(object): raise Warning("expected '.' At Line ", self.FileName, self.CurrentLineNumber) Arch = self.__SkippedChars.rstrip(".").upper() - if Arch not in ("IA32", "X64", "IPF", "ARM"): + if Arch not in ("IA32", "X64", "IPF", "ARM", "AARCH64"): raise Warning("Unknown Arch At line ", self.FileName, self.CurrentLineNumber) if not self.__GetNextWord(): @@ -3370,7 +3370,7 @@ class FdfParser(object): if self.__IsToken(","): if not self.__GetNextWord(): raise Warning("expected Arch list At Line ", self.FileName, self.CurrentLineNumber) - if self.__Token.upper() not in ("IA32", "X64", "IPF", "ARM"): + if self.__Token.upper() not in ("IA32", "X64", "IPF", "ARM", "AARCH64"): raise Warning("Unknown Arch At line ", self.FileName, self.CurrentLineNumber) VtfObj.ArchList = self.__Token.upper() diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py index b15daa8448..7c69704596 100644 --- a/BaseTools/Source/Python/Common/MigrationUtilities.py +++ b/BaseTools/Source/Python/Common/MigrationUtilities.py @@ -360,7 +360,7 @@ def StoreTextFile(TextFile, Content): # The possible duplication is ensured to be removed. # # @param Section Section dictionary indexed by CPU architecture. -# @param Arch CPU architecture: Ia32, X64, Ipf, ARM, Ebc or Common. +# @param Arch CPU architecture: Ia32, X64, Ipf, ARM, AARCH64, Ebc or Common. # @param Item The Item to be added to section dictionary. # def AddToSection(Section, Arch, Item): @@ -382,7 +382,7 @@ def AddToSection(Section, Arch, Item): # @retval Section The string content of a section. # def GetSection(SectionName, Method, ObjectList): - SupportedArches = ["common", "Ia32", "X64", "Ipf", "Ebc", "ARM"] + SupportedArches = ["common", "Ia32", "X64", "Ipf", "Ebc", "ARM", "AARCH64"] SectionDict = {} for Object in ObjectList: Item = Method(Object) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 8b5598b5f0..afdfb93ad6 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -30,6 +30,7 @@ from Common import EdkLogger as EdkLogger from Common import GlobalData as GlobalData from DataType import * from BuildToolError import * +from CommonDataClass.DataClass import * ## Regular expression used to find out place holders in string template gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE|re.UNICODE) @@ -1176,6 +1177,113 @@ def ParseConsoleLog(Filename): Opr.close() Opw.close() +## AnalyzeDscPcd +# +# Analyze DSC PCD value, since there is no data type info in DSC +# This fuction is used to match functions (AnalyzePcdData, AnalyzeHiiPcdData, AnalyzeVpdPcdData) used for retrieving PCD value from database +# 1. Feature flag: TokenSpace.PcdCName|PcdValue +# 2. Fix and Patch:TokenSpace.PcdCName|PcdValue[|MaxSize] +# 3. Dynamic default: +# TokenSpace.PcdCName|PcdValue[|VOID*[|MaxSize]] +# TokenSpace.PcdCName|PcdValue +# 4. Dynamic VPD: +# TokenSpace.PcdCName|VpdOffset[|VpdValue] +# TokenSpace.PcdCName|VpdOffset[|MaxSize[|VpdValue]] +# 5. Dynamic HII: +# TokenSpace.PcdCName|HiiString|VaiableGuid|VariableOffset[|HiiValue] +# PCD value needs to be located in such kind of string, and the PCD value might be an expression in which +# there might have "|" operator, also in string value. +# +# @param Setting: String contain information described above with "TokenSpace.PcdCName|" stripped +# @param PcdType: PCD type: feature, fixed, dynamic default VPD HII +# @param DataType: The datum type of PCD: VOID*, UNIT, BOOL +# @retval: +# ValueList: A List contain fields described above +# IsValid: True if conforming EBNF, otherwise False +# Index: The index where PcdValue is in ValueList +# +def AnalyzeDscPcd(Setting, PcdType, DataType=''): + Setting = Setting.strip() + # There might be escaped quote in a string: \", \\\" + Data = Setting.replace('\\\\', '//').replace('\\\"', '\\\'') + # There might be '|' in string and in ( ... | ... ), replace it with '-' + NewStr = '' + InStr = False + Pair = 0 + for ch in Data: + if ch == '"': + InStr = not InStr + elif ch == '(' and not InStr: + Pair += 1 + elif ch == ')' and not InStr: + Pair -= 1 + + if (Pair > 0 or InStr) and ch == TAB_VALUE_SPLIT: + NewStr += '-' + else: + NewStr += ch + FieldList = [] + StartPos = 0 + while True: + Pos = NewStr.find(TAB_VALUE_SPLIT, StartPos) + if Pos < 0: + FieldList.append(Setting[StartPos:].strip()) + break + FieldList.append(Setting[StartPos:Pos].strip()) + StartPos = Pos + 1 + + IsValid = True + if PcdType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_FEATURE_FLAG): + Value = FieldList[0] + Size = '' + if len(FieldList) > 1: + Size = FieldList[1] + if DataType == 'VOID*': + IsValid = (len(FieldList) <= 2) + else: + IsValid = (len(FieldList) <= 1) + return [Value, '', Size], IsValid, 0 + elif PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT): + Value = FieldList[0] + Size = Type = '' + if len(FieldList) > 1: + Type = FieldList[1] + if len(FieldList) > 2: + Size = FieldList[2] + if DataType == 'VOID*': + IsValid = (len(FieldList) <= 3) + else: + IsValid = (len(FieldList) <= 1) + return [Value, Type, Size], IsValid, 0 + elif PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD): + VpdOffset = FieldList[0] + Value = Size = '' + if not DataType == 'VOID*': + if len(FieldList) > 1: + Value = FieldList[1] + else: + if len(FieldList) > 1: + Size = FieldList[1] + if len(FieldList) > 2: + Value = FieldList[2] + if DataType == 'VOID*': + IsValid = (len(FieldList) <= 3) + else: + IsValid = (len(FieldList) <= 2) + return [VpdOffset, Size, Value], IsValid, 2 + elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII): + HiiString = FieldList[0] + Guid = Offset = Value = '' + if len(FieldList) > 1: + Guid = FieldList[1] + if len(FieldList) > 2: + Offset = FieldList[2] + if len(FieldList) > 3: + Value = FieldList[3] + IsValid = (3 <= len(FieldList) <= 4) + return [HiiString, Guid, Offset, Value], IsValid, 3 + return [], False, 0 + ## AnalyzePcdData # # Analyze the pcd Value, Datum type and TokenNumber. @@ -1236,12 +1344,12 @@ def AnalyzeHiiPcdData(Setting): ## AnalyzeVpdPcdData # -# Analyze the vpd pcd Value, Datum type and TokenNumber. +# Analyze the vpd pcd VpdOffset, MaxDatumSize and InitialValue. # Used to avoid split issue while the value string contain "|" character # -# @param[in] Setting: A String contain value/datum type/token number information; +# @param[in] Setting: A String contain VpdOffset/MaxDatumSize/InitialValue information; # -# @retval ValueList: A List contain value, datum type and toke number. +# @retval ValueList: A List contain VpdOffset, MaxDatumSize and InitialValue. # def AnalyzeVpdPcdData(Setting): ValueList = ['', '', ''] @@ -1269,22 +1377,38 @@ def AnalyzeVpdPcdData(Setting): # def CheckPcdDatum(Type, Value): if Type == "VOID*": + ValueRe = re.compile(r'\s*L?\".*\"\s*$') if not (((Value.startswith('L"') or Value.startswith('"')) and Value.endswith('"')) or (Value.startswith('{') and Value.endswith('}')) ): return False, "Invalid value [%s] of type [%s]; must be in the form of {...} for array"\ - ", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type) + ", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type) + elif ValueRe.match(Value): + # Check the chars in UnicodeString or CString is printable + if Value.startswith("L"): + Value = Value[2:-1] + else: + Value = Value[1:-1] + Printset = set(string.printable) + Printset.remove(TAB_PRINTCHAR_VT) + Printset.add(TAB_PRINTCHAR_BS) + Printset.add(TAB_PRINTCHAR_NUL) + if not set(Value).issubset(Printset): + PrintList = list(Printset) + PrintList.sort() + return False, "Invalid PCD string value of type [%s]; must be printable chars %s." % (Type, PrintList) elif Type == 'BOOLEAN': if Value not in ['TRUE', 'True', 'true', '0x1', '0x01', '1', 'FALSE', 'False', 'false', '0x0', '0x00', '0']: return False, "Invalid value [%s] of type [%s]; must be one of TRUE, True, true, 0x1, 0x01, 1"\ ", FALSE, False, false, 0x0, 0x00, 0" % (Value, Type) - elif type(Value) == type(""): + elif Type in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64]: try: Value = long(Value, 0) except: return False, "Invalid value [%s] of type [%s];"\ - " must be a hexadecimal, decimal or octal in C language format."\ - % (Value, Type) + " must be a hexadecimal, decimal or octal in C language format." % (Value, Type) + else: + return False, "Invalid type [%s]; must be one of VOID*, BOOLEAN, UINT8, UINT16, UINT32, UINT64." % (Type) return True, "" diff --git a/BaseTools/Source/Python/Common/PyUtility.pyd b/BaseTools/Source/Python/Common/PyUtility.pyd index 5bb57d91e0..856b508e4e 100644 Binary files a/BaseTools/Source/Python/Common/PyUtility.pyd and b/BaseTools/Source/Python/Common/PyUtility.pyd differ diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index 068a63d1c1..c282326677 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -368,7 +368,7 @@ def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyle ## CleanString2 # -# Split comments in a string +# Split statement with comments in a string # Remove spaces # # @param Line: The string to be cleaned @@ -387,15 +387,21 @@ def CleanString2(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyl if AllowCppStyleComment: Line = Line.replace(DataType.TAB_COMMENT_EDK_SPLIT, CommentCharacter) # - # separate comments and statements + # separate comments and statements, but we should escape comment character in string # - LineParts = Line.split(CommentCharacter, 1); - # - # remove whitespace again - # - Line = LineParts[0].strip(); - if len(LineParts) > 1: - Comment = LineParts[1].strip() + InString = False + CommentInString = False + Comment = '' + for Index in range(0, len(Line)): + if Line[Index] == '"': + InString = not InString + elif Line[Index] == CommentCharacter and InString: + CommentInString = True + elif Line[Index] == CommentCharacter and not InString: + Comment = Line[Index:].strip() + Line = Line[0:Index].strip() + break + if Comment: # Remove prefixed and trailing comment characters Start = 0 End = len(Comment) @@ -405,8 +411,6 @@ def CleanString2(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyl End -= 1 Comment = Comment[Start:End] Comment = Comment.strip() - else: - Comment = '' return Line, Comment diff --git a/BaseTools/Source/Python/CommonDataClass/CommonClass.py b/BaseTools/Source/Python/CommonDataClass/CommonClass.py index 7a0123b1d9..bb4b434af8 100644 --- a/BaseTools/Source/Python/CommonDataClass/CommonClass.py +++ b/BaseTools/Source/Python/CommonDataClass/CommonClass.py @@ -38,7 +38,7 @@ def GenerateHelpText(Text, Lang): # ALWAYS_CONSUMED | SOMETIMES_CONSUMED | ALWAYS_PRODUCED | SOMETIMES_PRODUCED | TO_START | BY_START | PRIVATE # @var FeatureFlag: To store value for FeatureFlag # @var SupArchList: To store value for SupArchList, selection scope is in below list -# EBC | IA32 | X64 | IPF | ARM | PPC +# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64 # @var HelpText: To store value for HelpText # class CommonClass(object): @@ -400,7 +400,7 @@ class PcdClass(CommonClass): # @var TagName: To store value for TagName # @var ToolCode: To store value for ToolCode # @var SupArchList: To store value for SupArchList, selection scope is in below list -# EBC | IA32 | X64 | IPF | ARM | PPC +# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64 # class BuildOptionClass(IncludeStatementClass): def __init__(self, ToolChainFamily = '', ToolChain = '', Option = ''): diff --git a/BaseTools/Source/Python/CommonDataClass/ModuleClass.py b/BaseTools/Source/Python/CommonDataClass/ModuleClass.py index c0738b996c..c5ea15af5b 100644 --- a/BaseTools/Source/Python/CommonDataClass/ModuleClass.py +++ b/BaseTools/Source/Python/CommonDataClass/ModuleClass.py @@ -25,7 +25,7 @@ from CommonClass import * # # @var ModuleType: To store value for ModuleType # @var SupArchList: To store value for SupArchList, selection scope is in below list -# EBC | IA32 | X64 | IPF | ARM | PPC +# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64 # @var BinaryModule: To store value for BinaryModule # @var OutputFileBasename: To store value for OutputFileBasename # @var ClonedFrom: To store value for ClonedFrom, it is a set structure as diff --git a/BaseTools/Source/Python/CommonDataClass/PlatformClass.py b/BaseTools/Source/Python/CommonDataClass/PlatformClass.py index 46329ba1d7..a95ec068b1 100644 --- a/BaseTools/Source/Python/CommonDataClass/PlatformClass.py +++ b/BaseTools/Source/Python/CommonDataClass/PlatformClass.py @@ -39,7 +39,7 @@ class SkuInfoListClass(IncludeStatementClass): # # @var DscSpecification: To store value for DscSpecification # @var SupArchList: To store value for SupArchList, selection scope is in below list -# EBC | IA32 | X64 | IPF | ARM | PPC +# EBC | IA32 | X64 | IPF | ARM | PPC | AARCH64 # @var BuildTargets: To store value for BuildTargets, selection scope is in below list # RELEASE | DEBUG # @var IntermediateDirectories: To store value for IntermediateDirectories, selection scope is in below list diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index 73d7318de0..c1ac07e852 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -821,7 +821,7 @@ class Check(object): RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand) for Record in RecordSet: Path = Record[1] - Path = Path.upper().replace('\X64', '').replace('\IA32', '').replace('\EBC', '').replace('\IPF', '').replace('\ARM', '') + Path = Path.upper().replace('\X64', '').replace('\IA32', '').replace('\EBC', '').replace('\IPF', '').replace('\ARM', '').replace('\AARCH64', '') if Path in InfPathList: if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE, Record[2]): EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE, OtherMsg="The source file [%s] is existing in module directory but it is not described in INF file." % (Record[2]), BelongsToTable='File', BelongsToItem=Record[0]) diff --git a/BaseTools/Source/Python/Eot/EfiCompressor.pyd b/BaseTools/Source/Python/Eot/EfiCompressor.pyd index 0729100b99..9de9beb402 100644 Binary files a/BaseTools/Source/Python/Eot/EfiCompressor.pyd and b/BaseTools/Source/Python/Eot/EfiCompressor.pyd differ diff --git a/BaseTools/Source/Python/Eot/LzmaCompressor.pyd b/BaseTools/Source/Python/Eot/LzmaCompressor.pyd index d792a7e9fb..337c055e20 100644 Binary files a/BaseTools/Source/Python/Eot/LzmaCompressor.pyd and b/BaseTools/Source/Python/Eot/LzmaCompressor.pyd differ diff --git a/BaseTools/Source/Python/GNUmakefile b/BaseTools/Source/Python/GNUmakefile index 9fe46f6edf..ed00a7b178 100644 --- a/BaseTools/Source/Python/GNUmakefile +++ b/BaseTools/Source/Python/GNUmakefile @@ -1,5 +1,5 @@ ## @file -# Linux makefile for Python tools build. +# GNU/Linux makefile for Python tools build. # # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
# This program and the accompanying materials diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py index aa4d2e8262..3716549cba 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -113,10 +113,15 @@ class FD(FDClassObject): PreviousRegionStart = RegionObj.Offset PreviousRegionSize = RegionObj.Size # + # Verify current region fits within allocated FD section Size + # + if PreviousRegionStart + PreviousRegionSize > self.Size: + EdkLogger.error("GenFds", GENFDS_ERROR, + 'FD %s size too small to fit region with offset 0x%X and size 0x%X' + % (self.FdUiName, PreviousRegionStart, PreviousRegionSize)) + # # Call each region's AddToBuffer function # - if PreviousRegionSize > self.Size: - EdkLogger.error("GenFds", GENFDS_ERROR, 'FD %s size too small' % self.FdUiName) GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function') RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict) # diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index c9c620d853..a468a5ec99 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -1707,6 +1707,38 @@ class FdfParser: return False + ## __CalcRegionExpr(self) + # + # Calculate expression for offset or size of a region + # + # @return: None if invalid expression + # Calculated number if successfully + # + def __CalcRegionExpr(self): + StartPos = self.GetFileBufferPos() + Expr = '' + PairCount = 0 + while not self.__EndOfFile(): + CurCh = self.__CurrentChar() + if CurCh == '(': + PairCount += 1 + elif CurCh == ')': + PairCount -= 1 + + if CurCh in '|\r\n' and PairCount == 0: + break + Expr += CurCh + self.__GetOneChar() + try: + return long( + ValueExpression(Expr, + dict(['%s.%s' % (Pcd[1], Pcd[0]), Val] + for Pcd, Val in self.Profile.PcdDict.iteritems()) + )(True),0) + except Exception: + self.SetFileBufferPos(StartPos) + return None + ## __GetRegionLayout() method # # Get region layout for FD @@ -1717,19 +1749,21 @@ class FdfParser: # @retval False Not able to find # def __GetRegionLayout(self, Fd): - if not self.__GetNextHexNumber(): + Offset = self.__CalcRegionExpr() + if Offset == None: return False RegionObj = Region.Region() - RegionObj.Offset = long(self.__Token, 0) + RegionObj.Offset = Offset Fd.RegionList.append(RegionObj) if not self.__IsToken( "|"): raise Warning("expected '|'", self.FileName, self.CurrentLineNumber) - if not self.__GetNextHexNumber(): + Size = self.__CalcRegionExpr() + if Size == None: raise Warning("expected Region Size", self.FileName, self.CurrentLineNumber) - RegionObj.Size = long(self.__Token, 0) + RegionObj.Size = Size if not self.__GetNextWord(): return True @@ -2503,16 +2537,16 @@ class FdfParser: self.__GetFileOpts( FfsFileObj) if not self.__IsToken("{"): -# if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'): -# if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType): -# if self.__Token == 'RELOCS_STRIPPED': -# FfsFileObj.KeepReloc = False -# else: -# FfsFileObj.KeepReloc = True -# else: -# raise Warning("File type %s could not have reloc strip flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber) -# -# if not self.__IsToken("{"): + if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'): + if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType): + if self.__Token == 'RELOCS_STRIPPED': + FfsFileObj.KeepReloc = False + else: + FfsFileObj.KeepReloc = True + else: + raise Warning("File type %s could not have reloc strip flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber) + + if not self.__IsToken("{"): raise Warning("expected '{'", self.FileName, self.CurrentLineNumber) if not self.__GetNextToken(): @@ -3186,7 +3220,7 @@ class FdfParser: raise Warning("expected '.'", self.FileName, self.CurrentLineNumber) Arch = self.__SkippedChars.rstrip(".") - if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "COMMON"): + if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH64", "COMMON"): raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber) ModuleType = self.__GetModuleType() @@ -3764,7 +3798,7 @@ class FdfParser: raise Warning("expected '.'", self.FileName, self.CurrentLineNumber) Arch = self.__SkippedChars.rstrip(".").upper() - if Arch not in ("IA32", "X64", "IPF", "ARM"): + if Arch not in ("IA32", "X64", "IPF", "ARM", "AARCH64"): raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber) if not self.__GetNextWord(): @@ -3778,7 +3812,7 @@ class FdfParser: if self.__IsToken(","): if not self.__GetNextWord(): raise Warning("expected Arch list", self.FileName, self.CurrentLineNumber) - if self.__Token.upper() not in ("IA32", "X64", "IPF", "ARM"): + if self.__Token.upper() not in ("IA32", "X64", "IPF", "ARM", "AARCH64"): raise Warning("Unknown Arch '%s'" % self.__Token, self.FileName, self.CurrentLineNumber) VtfObj.ArchList = self.__Token.upper() diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py index 04527fe00f..d0dec380fb 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -110,6 +110,8 @@ class FileStatement (FileStatementClassObject) : if FvParentAddr != None and isinstance(section, GuidSection): section.FvParentAddr = FvParentAddr + if self.KeepReloc == False: + section.KeepReloc = False sectList, align = section.GenSection(OutputDir, self.NameGuid, SecIndex, self.KeyStringList, None, Dict) if sectList != []: for sect in sectList: diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 96e212cae7..71acd2992c 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -388,6 +388,11 @@ class FfsInfStatement(FfsInfStatementClassObject): if InfFileKey in (PlatformDataBase.Modules): DscArchList.append ('EBC') + PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'AARCH64', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + if PlatformDataBase != None: + if InfFileKey in (PlatformDataBase.Modules): + DscArchList.append ('AARCH64') + return DscArchList ## GetCurrentArch() method diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index fb86a152b6..400008e815 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -301,7 +301,7 @@ def myOptionParser(): usage = "%prog [options] -f input_file -a arch_list -b build_target -p active_platform -t tool_chain_tag -D \"MacroName [= MacroValue]\"" Parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber)) Parser.add_option("-f", "--file", dest="filename", type="string", help="Name of FDF file to convert", action="callback", callback=SingleCheckCallback) - Parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF, ARM or EBC which should be built, overrides target.txt?s TARGET_ARCH") + Parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF, ARM, AARCH64 or EBC which should be built, overrides target.txt?s TARGET_ARCH") Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.") Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed.") Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.") diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index b457937628..2fa4cb8c0d 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -345,7 +345,7 @@ class GenFdsGlobalVariable: @staticmethod def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None, - GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None): + GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None): Cmd = ["GenSec"] if Type not in [None, '']: Cmd += ["-s", Type] @@ -364,6 +364,7 @@ class GenFdsGlobalVariable: for SecAlign in InputAlign: Cmd += ["--sectionalign", SecAlign] + CommandFile = Output + '.txt' if Ui not in [None, '']: #Cmd += ["-n", '"' + Ui + '"'] SectionData = array.array('B', [0,0,0,0]) @@ -374,19 +375,20 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) SaveFileOnChange(Output, SectionData.tostring()) elif Ver not in [None, '']: - #Cmd += ["-j", Ver] - SectionData = array.array('B', [0,0,0,0]) - SectionData.fromstring(Ver.encode("utf_16_le")) - SectionData.append(0) - SectionData.append(0) - Len = len(SectionData) - GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x14) - SaveFileOnChange(Output, SectionData.tostring()) + Cmd += ["-n", Ver] + if BuildNumber: + Cmd += ["-j", BuildNumber] + Cmd += ["-o", Output] + + SaveFileOnChange(CommandFile, ' '.join(Cmd), False) + if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): + return + + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section") else: Cmd += ["-o", Output] Cmd += Input - CommandFile = Output + '.txt' SaveFileOnChange(CommandFile, ' '.join(Cmd), False) if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): return diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py index 3fca4064f0..8f6da9624f 100644 --- a/BaseTools/Source/Python/GenFds/VerSection.py +++ b/BaseTools/Source/Python/GenFds/VerSection.py @@ -76,7 +76,7 @@ class VerSection (VerSectionClassObject): StringData = '' GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_VERSION', - Ui=StringData, Ver=self.BuildNum) + Ver=StringData, BuildNumber=self.BuildNum) OutputFileList = [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/Makefile b/BaseTools/Source/Python/Makefile index fec8b43646..a3a537c352 100644 --- a/BaseTools/Source/Python/Makefile +++ b/BaseTools/Source/Python/Makefile @@ -15,7 +15,13 @@ !ERROR PYTHON_FREEZER_PATH must be defined! !ENDIF +!IF EXIST ($(PYTHON_FREEZER_PATH)\cxfreeze) +# Using cx_Freeze 4.2.3 with Python 2.7.2 +FREEZE=$(PYTHON_FREEZER_PATH)\cxfreeze +!ELSE +# Using cx_Freeze 3.0.3 with Python 2.5.4 FREEZE=$(PYTHON_FREEZER_PATH)\FreezePython.exe +!ENDIF MODULES=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_8,encodings.utf_16_le,encodings.latin_1,encodings.ascii diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/Source/Python/TargetTool/TargetTool.py index 476e927a88..8126aac59c 100644 --- a/BaseTools/Source/Python/TargetTool/TargetTool.py +++ b/BaseTools/Source/Python/TargetTool/TargetTool.py @@ -200,8 +200,8 @@ def RangeCheckCallback(option, opt_str, value, parser): def MyOptionParser(): parser = OptionParser(version=__version__,prog="TargetTool.exe",usage=__usage__,description=__copyright__) - parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32','X64','IPF','EBC', 'ARM','0'], dest="TARGET_ARCH", - help="ARCHS is one of list: IA32, X64, IPF, ARM or EBC, which replaces target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option. 0 will clear this setting in target.txt and can't combine with other value.") + parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32','X64','IPF','EBC', 'ARM', 'AARCH64','0'], dest="TARGET_ARCH", + help="ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC, which replaces target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option. 0 will clear this setting in target.txt and can't combine with other value.") parser.add_option("-p", "--platform", action="callback", type="string", dest="DSCFILE", callback=SingleCheckCallback, help="Specify a DSC file, which replace target.txt's ACTIVE_PLATFORM definition. 0 will clear this setting in target.txt and can't combine with other value.") parser.add_option("-c", "--tooldef", action="callback", type="string", dest="TOOL_DEFINITION_FILE", callback=SingleCheckCallback, diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source/Python/UPT/BuildVersion.py index e2dca6130f..edd4696753 100644 --- a/BaseTools/Source/Python/UPT/BuildVersion.py +++ b/BaseTools/Source/Python/UPT/BuildVersion.py @@ -17,4 +17,4 @@ Build version information ''' -gBUILD_VERSION = "Build 2524" +gBUILD_VERSION = "" diff --git a/BaseTools/Source/Python/UPT/Library/DataType.py b/BaseTools/Source/Python/UPT/Library/DataType.py index da6b69d82b..de3c7092ad 100644 --- a/BaseTools/Source/Python/UPT/Library/DataType.py +++ b/BaseTools/Source/Python/UPT/Library/DataType.py @@ -353,9 +353,10 @@ TAB_ARCH_X64 = 'X64' TAB_ARCH_IPF = 'IPF' TAB_ARCH_ARM = 'ARM' TAB_ARCH_EBC = 'EBC' +TAB_ARCH_AARCH64 = 'AARCH64' ARCH_LIST = \ -[TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC] +[TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64] SUP_MODULE_BASE = 'BASE' SUP_MODULE_SEC = 'SEC' @@ -440,6 +441,7 @@ 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 @@ -448,6 +450,7 @@ 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 @@ -456,6 +459,7 @@ 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 @@ -464,6 +468,7 @@ 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 @@ -472,6 +477,7 @@ 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 @@ -480,6 +486,7 @@ 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 @@ -488,6 +495,7 @@ TAB_LIBRARY_CLASSES_X64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_X64 TAB_LIBRARY_CLASSES_IPF = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_IPF TAB_LIBRARY_CLASSES_ARM = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_ARM TAB_LIBRARY_CLASSES_EBC = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_EBC +TAB_LIBRARY_CLASSES_AARCH64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PACKAGES = 'Packages' TAB_PACKAGES_COMMON = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_COMMON @@ -496,6 +504,7 @@ TAB_PACKAGES_X64 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_X64 TAB_PACKAGES_IPF = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_IPF TAB_PACKAGES_ARM = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_ARM TAB_PACKAGES_EBC = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_EBC +TAB_PACKAGES_AARCH64 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS = 'Pcds' TAB_PCDS_FIXED_AT_BUILD = 'FixedAtBuild' @@ -535,6 +544,8 @@ TAB_PCDS_FIXED_AT_BUILD_ARM = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_FIXED_AT_BUILD_EBC = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_FIXED_AT_BUILD_AARCH64 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ +TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_PATCHABLE_IN_MODULE_NULL = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE TAB_PCDS_PATCHABLE_IN_MODULE_COMMON = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE \ @@ -549,6 +560,8 @@ TAB_PCDS_PATCHABLE_IN_MODULE_ARM = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + \ TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_PATCHABLE_IN_MODULE_EBC = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + \ TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_PATCHABLE_IN_MODULE_AARCH64 = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + \ +TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCDS_FEATURE_FLAG_NULL = TAB_PCDS + TAB_PCDS_FEATURE_FLAG TAB_PCDS_FEATURE_FLAG_COMMON = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT \ @@ -563,6 +576,8 @@ TAB_PCDS_FEATURE_FLAG_ARM = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + \ TAB_ARCH_ARM TAB_PCDS_FEATURE_FLAG_EBC = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + \ TAB_ARCH_EBC +TAB_PCDS_FEATURE_FLAG_AARCH64 = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + \ +TAB_ARCH_AARCH64 TAB_PCDS_DYNAMIC_EX_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_EX TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_EX_DEFAULT @@ -580,6 +595,8 @@ TAB_PCDS_DYNAMIC_EX_ARM = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ TAB_ARCH_ARM TAB_PCDS_DYNAMIC_EX_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ TAB_ARCH_EBC +TAB_PCDS_DYNAMIC_EX_AARCH64 = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ +TAB_ARCH_AARCH64 TAB_PCDS_DYNAMIC_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC TAB_PCDS_DYNAMIC_DEFAULT_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_DEFAULT @@ -592,6 +609,7 @@ TAB_PCDS_DYNAMIC_X64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_X64 TAB_PCDS_DYNAMIC_IPF = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_DYNAMIC_ARM = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_DYNAMIC_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_DYNAMIC_AARCH64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_PCD_DYNAMIC_TYPE_LIST = [TAB_PCDS_DYNAMIC_DEFAULT_NULL, \ TAB_PCDS_DYNAMIC_VPD_NULL, \ @@ -632,6 +650,7 @@ TAB_DEPEX_X64 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_X64 TAB_DEPEX_IPF = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_IPF TAB_DEPEX_ARM = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_ARM TAB_DEPEX_EBC = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_EBC +TAB_DEPEX_AARCH64 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_SKUIDS = 'SkuIds' @@ -642,6 +661,7 @@ TAB_LIBRARIES_X64 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_X64 TAB_LIBRARIES_IPF = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_IPF TAB_LIBRARIES_ARM = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_ARM TAB_LIBRARIES_EBC = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_EBC +TAB_LIBRARIES_AARCH64 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_COMPONENTS = 'Components' TAB_COMPONENTS_COMMON = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_COMMON @@ -650,6 +670,7 @@ TAB_COMPONENTS_X64 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_X64 TAB_COMPONENTS_IPF = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_IPF TAB_COMPONENTS_ARM = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_ARM TAB_COMPONENTS_EBC = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_EBC +TAB_COMPONENTS_AARCH64 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_AARCH64 TAB_COMPONENTS_SOURCE_OVERRIDE_PATH = 'SOURCE_OVERRIDE_PATH' diff --git a/BaseTools/Source/Python/UPT/Library/GlobalData.py b/BaseTools/Source/Python/UPT/Library/GlobalData.py index fedd981529..3f72f22738 100644 --- a/BaseTools/Source/Python/UPT/Library/GlobalData.py +++ b/BaseTools/Source/Python/UPT/Library/GlobalData.py @@ -92,3 +92,8 @@ gUNPACK_DIR = None # Flag used to mark whether the INF file is Binary INF or not. # gIS_BINARY_INF = False +# +# Used by Library instance parser +# {FilePath: FileObj} +# +gLIBINSTANCEDICT = {} \ No newline at end of file diff --git a/BaseTools/Source/Python/UPT/Library/String.py b/BaseTools/Source/Python/UPT/Library/String.py index 2c5853ca93..0953e47cb1 100644 --- a/BaseTools/Source/Python/UPT/Library/String.py +++ b/BaseTools/Source/Python/UPT/Library/String.py @@ -2,7 +2,7 @@ # This file is used to define common string related functions used in parsing # process # -# Copyright (c) 2011, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.
# # This program and the accompanying materials are licensed and made available # under the terms and conditions of the BSD License which accompanies this @@ -737,7 +737,7 @@ def IsHexDigit(Str): return False return False -## Check if the string is HexDgit and its interger value within limit of UINT32 +## Check if the string is HexDgit and its integer value within limit of UINT32 # # Return true if all characters in the string are digits and there is at # least one character diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py index d576cffbd0..27a1c6ad25 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py @@ -89,19 +89,19 @@ class InfUserExtensionObject(): InfUserExtensionItemObj.SetContent(UserExtensionCont) InfUserExtensionItemObj.SetSupArchList(IdContentItem[2]) - for CheckItem in self.UserExtension: - if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]: - if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON': - # - # For COMMON ARCH type, do special check. - # - Logger.Error('InfParser', - ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\ - (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]), - File=GlobalData.gINF_MODULE_NAME, - Line=LineNo, - ExtraData=None) +# for CheckItem in self.UserExtension: +# if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]: +# if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON': +# # +# # For COMMON ARCH type, do special check. +# # +# Logger.Error('InfParser', +# ToolError.FORMAT_INVALID, +# ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\ +# (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]), +# File=GlobalData.gINF_MODULE_NAME, +# Line=LineNo, +# ExtraData=None) if self.UserExtension.has_key(IdContentItem): # diff --git a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py index 12c46f1954..6bf070be41 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py +++ b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py @@ -42,12 +42,12 @@ from Library import DataType as DT # @param WorkSpace. The WorkSpace directory used to combined with INF file path. # # @return GUID, Version -def GetLibInstanceInfo(String, WorkSpace, LineNo): - +def GetLibInstanceInfo(String, WorkSpace, LineNo, CurrentInfFileName): + FileGuidString = "" VerString = "" - - OrignalString = String + + OrignalString = String String = String.strip() if not String: return None, None @@ -56,28 +56,48 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): # String = GetHelpStringByRemoveHashKey(String) String = String.strip() - + + # + # To deal with library instance specified by GUID and version + # + RegFormatGuidPattern = re.compile("\s*([0-9a-fA-F]){8}-" + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){12}\s*") + VersionPattern = re.compile('[\t\s]*\d+(\.\d+)?[\t\s]*') + GuidMatchedObj = RegFormatGuidPattern.search(String) + + if String.upper().startswith('GUID') and GuidMatchedObj and 'Version' in String: + VersionStr = String[String.upper().find('VERSION') + 8:] + VersionMatchedObj = VersionPattern.search(VersionStr) + if VersionMatchedObj: + Guid = GuidMatchedObj.group().strip() + Version = VersionMatchedObj.group().strip() + return GetGuidVerFormLibInstance(Guid, Version, WorkSpace, CurrentInfFileName) + + # + # To deal with library instance specified by file name + # FileLinesList = GetFileLineContent(String, WorkSpace, LineNo, OrignalString) - + ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$") ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$") - - FileLinesList = ProcessLineExtender(FileLinesList) for Line in FileLinesList: if ReFindFileGuidPattern.match(Line): FileGuidString = Line if ReFindVerStringPattern.match(Line): VerString = Line - + if FileGuidString: FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1] if VerString: VerString = GetSplitValueList(VerString, '=', 1)[1] - + return FileGuidString, VerString - + ## GetPackageListInfo # # Get the package information from INF file. @@ -184,36 +204,97 @@ def GetFileLineContent(FileName, WorkSpace, LineNo, OriginalString): # # Validate file exist/format. # - if IsValidPath(FileName, WorkSpace): - IsValidFileFlag = True - else: + if not IsValidPath(FileName, WorkSpace): Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(FileName), File=GlobalData.gINF_MODULE_NAME, Line=LineNo, ExtraData=OriginalString) - return False FileLinesList = [] - if IsValidFileFlag: + try: + FullFileName = FullFileName.replace('\\', '/') + Inputfile = open(FullFileName, "rb", 0) try: - FullFileName = FullFileName.replace('\\', '/') - Inputfile = open(FullFileName, "rb", 0) - try: - FileLinesList = Inputfile.readlines() - except BaseException: - Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_FILE_OPEN_FAILURE, File=FullFileName) - finally: - Inputfile.close() + FileLinesList = Inputfile.readlines() except BaseException: - Logger.Error("InfParser", - ToolError.FILE_READ_FAILURE, - ST.ERR_FILE_OPEN_FAILURE, - File=FullFileName) - - FileLinesList = ProcessLineExtender(FileLinesList) + Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_FILE_OPEN_FAILURE, File=FullFileName) + finally: + Inputfile.close() + except BaseException: + Logger.Error("InfParser", + ToolError.FILE_READ_FAILURE, + ST.ERR_FILE_OPEN_FAILURE, + File=FullFileName) + + FileLinesList = ProcessLineExtender(FileLinesList) return FileLinesList - \ No newline at end of file + +## +# Get all INF files from current workspace +# +# +def GetInfsFromWorkSpace(WorkSpace): + InfFiles = [] + for top, dirs, files in os.walk(WorkSpace): + dirs = dirs # just for pylint + for File in files: + if File.upper().endswith(".INF"): + InfFiles.append(os.path.join(top, File)) + + return InfFiles + +## +# Get GUID and version from library instance file +# +# +def GetGuidVerFormLibInstance(Guid, Version, WorkSpace, CurrentInfFileName): + for InfFile in GetInfsFromWorkSpace(WorkSpace): + try: + if InfFile.strip().upper() == CurrentInfFileName.strip().upper(): + continue + InfFile = InfFile.replace('\\', '/') + if InfFile not in GlobalData.gLIBINSTANCEDICT: + InfFileObj = open(InfFile, "rb", 0) + GlobalData.gLIBINSTANCEDICT[InfFile] = InfFileObj + else: + InfFileObj = GlobalData.gLIBINSTANCEDICT[InfFile] + + except BaseException: + Logger.Error("InfParser", + ToolError.FILE_READ_FAILURE, + ST.ERR_FILE_OPEN_FAILURE, + File=InfFile) + try: + FileLinesList = InfFileObj.readlines() + FileLinesList = ProcessLineExtender(FileLinesList) + + ReFindFileGuidPattern = re.compile("^\s*FILE_GUID\s*=.*$") + ReFindVerStringPattern = re.compile("^\s*VERSION_STRING\s*=.*$") + + for Line in FileLinesList: + if ReFindFileGuidPattern.match(Line): + FileGuidString = Line + if ReFindVerStringPattern.match(Line): + VerString = Line + + if FileGuidString: + FileGuidString = GetSplitValueList(FileGuidString, '=', 1)[1] + if VerString: + VerString = GetSplitValueList(VerString, '=', 1)[1] + + if FileGuidString.strip().upper() == Guid.upper() and \ + VerString.strip().upper() == Version.upper(): + return Guid, Version + + except BaseException: + Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_FILE_OPEN_FAILURE, File=InfFile) + finally: + InfFileObj.close() + + return '', '' + + diff --git a/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py b/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py index 8f9427cf4f..4540fe2754 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py @@ -170,28 +170,29 @@ class InfLibrarySectionParser(InfParserSectionRoot): File=FileName, Line=LineNo, ExtraData=LineContent) - + if IsLibInstanceInfo(LineContent): LibInsFlag = True continue - + if LibInsFlag: - LibGuid, LibVer = GetLibInstanceInfo(LineContent, GlobalData.gWORKSPACE, LineNo) + LibGuid, LibVer = GetLibInstanceInfo(LineContent, GlobalData.gWORKSPACE, LineNo, FileName) # # If the VERSION_STRING is missing from the INF file, tool should default to "0". # if LibVer == '': LibVer = '0' if LibGuid != '': - LibraryList.append((LibGuid, LibVer)) + if (LibGuid, LibVer) not in LibraryList: + LibraryList.append((LibGuid, LibVer)) else: - Logger.Error('InfParser', + Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_LIB_INSTANCE_MISS_GUID, - File=FileName, - Line=LineNo, - ExtraData=LineContent) - + ST.ERR_LIB_INSTANCE_MISS_GUID, + File=FileName, + Line=LineNo, + ExtraData=LineContent) + # # Current section archs # diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index a6668774b5..b2e98633af 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1,7 +1,7 @@ ## @file # This file is used to parse meta files # -# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -25,7 +25,7 @@ import Common.GlobalData as GlobalData from CommonDataClass.DataClass import * from Common.DataType import * from Common.String import * -from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData +from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd from Common.Expression import * from CommonDataClass.Exceptions import * @@ -44,7 +44,7 @@ def ParseMacro(Parser): # Syntax check if not TokenList[0]: EdkLogger.error('Parser', FORMAT_INVALID, "No macro name given", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) if len(TokenList) < 2: TokenList.append('') @@ -53,11 +53,11 @@ def ParseMacro(Parser): # Global macros can be only defined via environment variable if Name in GlobalData.gGlobalDefines: EdkLogger.error('Parser', FORMAT_INVALID, "%s can only be defined via environment variable" % Name, - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) # Only upper case letters, digit and '_' are allowed if not gMacroNamePattern.match(Name): EdkLogger.error('Parser', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) Value = ReplaceMacro(Value, self._Macros) if Type in self.DataType: @@ -85,14 +85,14 @@ def ParseMacro(Parser): # EDK_GLOBAL defined macros elif type(self) != DscParser: EdkLogger.error('Parser', FORMAT_INVALID, "EDK_GLOBAL can only be used in .dsc file", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) elif self._SectionType != MODEL_META_DATA_HEADER: EdkLogger.error('Parser', FORMAT_INVALID, "EDK_GLOBAL can only be used under [Defines] section", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) elif (Name in self._FileLocalMacros) and (self._FileLocalMacros[Name] != Value): EdkLogger.error('Parser', FORMAT_INVALID, "EDK_GLOBAL defined a macro with the same name and different value as one defined by 'DEFINE'", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) - + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) + self._ValueList = [Type, Name, Value] return MacroParser @@ -146,7 +146,7 @@ class MetaFileParser(object): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INCLUDE directive) # - def __init__(self, FilePath, FileType, Table, Owner=-1, From=-1): + def __init__(self, FilePath, FileType, Table, Owner= -1, From= -1): self._Table = Table self._RawTable = Table self._FileType = FileType @@ -262,7 +262,7 @@ class MetaFileParser(object): ## Skip unsupported data def _Skip(self): EdkLogger.warn("Parser", "Unrecognized content", File=self.MetaFile, - Line=self._LineIndex+1, ExtraData=self._CurrentLine); + Line=self._LineIndex + 1, ExtraData=self._CurrentLine); self._ValueList[0:1] = [self._CurrentLine] ## Section header parser @@ -282,20 +282,27 @@ class MetaFileParser(object): # different section should not mix in one section if self._SectionName != '' and self._SectionName != ItemList[0].upper(): EdkLogger.error('Parser', FORMAT_INVALID, "Different section names in the same section", - File=self.MetaFile, Line=self._LineIndex+1, ExtraData=self._CurrentLine) + File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine) self._SectionName = ItemList[0].upper() if self._SectionName in self.DataType: self._SectionType = self.DataType[self._SectionName] + # Check if the section name is valid + if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH and len(ItemList) > 2: + EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item, + self.MetaFile, self._LineIndex + 1, self._CurrentLine) + elif self._Version >= 0x00010005: + EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item, + self.MetaFile, self._LineIndex + 1, self._CurrentLine) else: self._SectionType = MODEL_UNKNOWN - EdkLogger.warn("Parser", "Unrecognized section", File=self.MetaFile, - Line=self._LineIndex+1, ExtraData=self._CurrentLine) + # S1 is always Arch if len(ItemList) > 1: S1 = ItemList[1].upper() else: S1 = 'COMMON' ArchList.add(S1) + # S2 may be Platform or ModuleType if len(ItemList) > 2: S2 = ItemList[2].upper() @@ -306,7 +313,7 @@ class MetaFileParser(object): # 'COMMON' must not be used with specific ARCHs at the same section if 'COMMON' in ArchList and len(ArchList) > 1: EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs", - File=self.MetaFile, Line=self._LineIndex+1, ExtraData=self._CurrentLine) + File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine) # If the section information is needed later, it should be stored in database self._ValueList[0] = self._SectionName @@ -317,10 +324,10 @@ class MetaFileParser(object): self._ValueList[1:len(TokenList)] = TokenList if not self._ValueList[1]: EdkLogger.error('Parser', FORMAT_INVALID, "No name specified", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) if not self._ValueList[2]: EdkLogger.error('Parser', FORMAT_INVALID, "No value specified", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList = [ReplaceMacro(Value, self._Macros) for Value in self._ValueList] Name, Value = self._ValueList[1], self._ValueList[2] @@ -330,7 +337,7 @@ class MetaFileParser(object): self._Version = int(Value, 0) except: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) if type(self) == InfParser and self._Version < 0x00010005: # EDK module allows using defines as macros @@ -358,7 +365,7 @@ class MetaFileParser(object): "'%s' must be in format of ____FLAGS" % self._ValueList[1], ExtraData=self._CurrentLine, File=self.MetaFile, - Line=self._LineIndex+1 + Line=self._LineIndex + 1 ) def _GetMacros(self): @@ -391,11 +398,11 @@ class MetaFileParser(object): ComComMacroDict = {} ComSpeMacroDict = {} SpeSpeMacroDict = {} - + ActiveSectionType = self._SectionType if type(self) == DecParser: ActiveSectionType = self._SectionType[0] - + for (SectionType, Scope) in self._SectionsMacroDict: if SectionType != ActiveSectionType: continue @@ -406,7 +413,7 @@ class MetaFileParser(object): break else: SpeSpeMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)]) - + for ActiveScope in self._Scope: Scope0, Scope1 = ActiveScope[0], ActiveScope[1] if(Scope0, Scope1) not in Scope and (Scope0, "COMMON") not in Scope and ("COMMON", Scope1) not in Scope: @@ -423,9 +430,9 @@ class MetaFileParser(object): return Macros - _SectionParser = {} - Finished = property(_GetFinished, _SetFinished) - _Macros = property(_GetMacros) + _SectionParser = {} + Finished = property(_GetFinished, _SetFinished) + _Macros = property(_GetMacros) ## INF file parser class @@ -475,6 +482,7 @@ class InfParser(MetaFileParser): if hasattr(self, "_Table"): return MetaFileParser.__init__(self, FilePath, FileType, Table) + self.PcdsDict = {} ## Parser starter def Start(self): @@ -527,13 +535,13 @@ class InfParser(MetaFileParser): MODEL_META_DATA_USER_EXTENSION]: EdkLogger.error('Parser', FORMAT_INVALID, "Section [%s] is not allowed in inf file without version" % (self._SectionName), - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) elif self._SectionType in [MODEL_EFI_INCLUDE, MODEL_EFI_LIBRARY_INSTANCE, MODEL_META_DATA_NMAKE]: EdkLogger.error('Parser', FORMAT_INVALID, "Section [%s] is not allowed in inf file with version 0x%08x" % (self._SectionName, self._Version), - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) continue # merge two lines specified by '\' in section NMAKE elif self._SectionType == MODEL_META_DATA_NMAKE: @@ -553,7 +561,7 @@ class InfParser(MetaFileParser): NmakeLine = '' # section content - self._ValueList = ['','',''] + self._ValueList = ['', '', ''] # parse current line, result will be put in self._ValueList self._SectionParser[self._SectionType](self) if self._ValueList == None or self._ItemType == MODEL_META_DATA_DEFINE: @@ -571,14 +579,14 @@ class InfParser(MetaFileParser): Arch, Platform, self._Owner[-1], - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, 0 ) if IsFindBlockComment: - EdkLogger.error("Parser", FORMAT_INVALID, "Open block comments (starting with /*) are expected to end with */", + EdkLogger.error("Parser", FORMAT_INVALID, "Open block comments (starting with /*) are expected to end with */", File=self.MetaFile) self._Done() @@ -636,15 +644,15 @@ class InfParser(MetaFileParser): if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No file type or path specified", ExtraData=self._CurrentLine + " ( | [| ])", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if not TokenList[0]: EdkLogger.error('Parser', FORMAT_INVALID, "No file type specified", ExtraData=self._CurrentLine + " ( | [| ])", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if not TokenList[1]: EdkLogger.error('Parser', FORMAT_INVALID, "No file path specified", ExtraData=self._CurrentLine + " ( | [| ])", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList[0:len(TokenList)] = TokenList self._ValueList[1] = ReplaceMacro(self._ValueList[1], self._Macros) @@ -665,14 +673,14 @@ class InfParser(MetaFileParser): if len(ValueList) != 2: EdkLogger.error('Parser', FORMAT_INVALID, "Illegal token space GUID and PCD name format", ExtraData=self._CurrentLine + " (.)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList[0:1] = ValueList if len(TokenList) > 1: self._ValueList[2] = TokenList[1] if self._ValueList[0] == '' or self._ValueList[1] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified", ExtraData=self._CurrentLine + " (.)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) # if value are 'True', 'true', 'TRUE' or 'False', 'false', 'FALSE', replace with integer 1 or 0. if self._ValueList[2] != '': @@ -681,6 +689,12 @@ class InfParser(MetaFileParser): self._ValueList[2] = TokenList[1].replace(InfPcdValueList[0], '1', 1); elif InfPcdValueList[0] in ['False', 'false', 'FALSE']: self._ValueList[2] = TokenList[1].replace(InfPcdValueList[0], '0', 1); + if (self._ValueList[0], self._ValueList[1]) not in self.PcdsDict: + self.PcdsDict[self._ValueList[0], self._ValueList[1]] = self._SectionType + elif self.PcdsDict[self._ValueList[0], self._ValueList[1]] != self._SectionType: + EdkLogger.error('Parser', FORMAT_INVALID, "It is not permissible to list a specified PCD in different PCD type sections.", + ExtraData=self._CurrentLine + " (.)", + File=self.MetaFile, Line=self._LineIndex + 1) ## [depex] section parser @ParseMacro @@ -691,11 +705,11 @@ class InfParser(MetaFileParser): MODEL_UNKNOWN : MetaFileParser._Skip, MODEL_META_DATA_HEADER : MetaFileParser._DefineParser, MODEL_META_DATA_BUILD_OPTION : MetaFileParser._BuildOptionParser, - MODEL_EFI_INCLUDE : _IncludeParser, # for Edk.x modules - MODEL_EFI_LIBRARY_INSTANCE : MetaFileParser._CommonParser, # for Edk.x modules + MODEL_EFI_INCLUDE : _IncludeParser, # for Edk.x modules + MODEL_EFI_LIBRARY_INSTANCE : MetaFileParser._CommonParser, # for Edk.x modules MODEL_EFI_LIBRARY_CLASS : MetaFileParser._PathParser, MODEL_META_DATA_PACKAGE : MetaFileParser._PathParser, - MODEL_META_DATA_NMAKE : _NmakeParser, # for Edk.x modules + MODEL_META_DATA_NMAKE : _NmakeParser, # for Edk.x modules MODEL_PCD_FIXED_AT_BUILD : _PcdParser, MODEL_PCD_PATCHABLE_IN_MODULE : _PcdParser, MODEL_PCD_FEATURE_FLAG : _PcdParser, @@ -781,7 +795,7 @@ class DscParser(MetaFileParser): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INCLUDE directive) # - def __init__(self, FilePath, FileType, Table, Owner=-1, From=-1): + def __init__(self, FilePath, FileType, Table, Owner= -1, From= -1): # prevent re-initialization if hasattr(self, "_Table"): return @@ -791,12 +805,12 @@ class DscParser(MetaFileParser): self._DirectiveStack = [] self._DirectiveEvalStack = [] self._Enabled = 1 - + # # Specify whether current line is in uncertain condition # self._InDirective = -1 - + # Final valid replacable symbols self._Symbols = {} # @@ -823,7 +837,7 @@ class DscParser(MetaFileParser): self._LineIndex = Index if self._InSubsection and self._Owner[-1] == -1: self._Owner.append(self._LastItem) - + # section header if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END: self._SectionType = MODEL_META_DATA_SECTION_HEADER @@ -866,10 +880,10 @@ class DscParser(MetaFileParser): ModuleType, self._Owner[-1], self._From, - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, self._Enabled ) @@ -887,12 +901,12 @@ class DscParser(MetaFileParser): else: self._SubsectionType = MODEL_UNKNOWN EdkLogger.warn("Parser", "Unrecognized sub-section", File=self.MetaFile, - Line=self._LineIndex+1, ExtraData=self._CurrentLine) + Line=self._LineIndex + 1, ExtraData=self._CurrentLine) self._ValueList[0] = self._SubsectionName ## Directive statement parser def _DirectiveParser(self): - self._ValueList = ['','',''] + self._ValueList = ['', '', ''] TokenList = GetSplitValueList(self._CurrentLine, ' ', 1) self._ValueList[0:len(TokenList)] = TokenList @@ -900,7 +914,7 @@ class DscParser(MetaFileParser): DirectiveName = self._ValueList[0].upper() if DirectiveName not in self.DataType: EdkLogger.error("Parser", FORMAT_INVALID, "Unknown directive [%s]" % DirectiveName, - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if DirectiveName in ['!IF', '!IFDEF', '!IFNDEF']: self._InDirective += 1 @@ -910,7 +924,7 @@ class DscParser(MetaFileParser): if DirectiveName in ['!IF', '!IFDEF', '!INCLUDE', '!IFNDEF', '!ELSEIF'] and self._ValueList[1] == '': EdkLogger.error("Parser", FORMAT_INVALID, "Missing expression", - File=self.MetaFile, Line=self._LineIndex+1, + File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine) ItemType = self.DataType[DirectiveName] @@ -928,7 +942,7 @@ class DscParser(MetaFileParser): break else: EdkLogger.error("Parser", FORMAT_INVALID, "Redundant '!endif'", - File=self.MetaFile, Line=self._LineIndex+1, + File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine) elif ItemType != MODEL_META_DATA_INCLUDE: # Break if there's a !else is followed by a !elseif @@ -936,14 +950,14 @@ class DscParser(MetaFileParser): self._DirectiveStack and \ self._DirectiveStack[-1][0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE: EdkLogger.error("Parser", FORMAT_INVALID, "'!elseif' after '!else'", - File=self.MetaFile, Line=self._LineIndex+1, + File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine) - self._DirectiveStack.append((ItemType, self._LineIndex+1, self._CurrentLine)) + self._DirectiveStack.append((ItemType, self._LineIndex + 1, self._CurrentLine)) elif self._From > 0: EdkLogger.error('Parser', FORMAT_INVALID, "No '!include' allowed in included file", - ExtraData=self._CurrentLine, File=self.MetaFile, - Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, + Line=self._LineIndex + 1) # # Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1, @@ -959,10 +973,10 @@ class DscParser(MetaFileParser): ModuleType, self._Owner[-1], self._From, - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, 0 ) @@ -975,16 +989,16 @@ class DscParser(MetaFileParser): # Syntax check if not self._ValueList[1]: EdkLogger.error('Parser', FORMAT_INVALID, "No name specified", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) if not self._ValueList[2]: EdkLogger.error('Parser', FORMAT_INVALID, "No value specified", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) if not self._ValueList[1] in self.DefineKeywords: EdkLogger.error('Parser', FORMAT_INVALID, "Unknown keyword found: %s. " "If this is a macro you must " "add it as a DEFINE in the DSC" % self._ValueList[1], - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) self._Defines[self._ValueList[1]] = self._ValueList[2] self._ItemType = self.DataType[TAB_DSC_DEFINES.upper()] @@ -993,7 +1007,7 @@ class DscParser(MetaFileParser): TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT) if len(TokenList) != 2: EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '|'", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList[0:len(TokenList)] = TokenList ## Parse Edk style of library modules @@ -1024,11 +1038,19 @@ class DscParser(MetaFileParser): if self._ValueList[0] == '' or self._ValueList[1] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified", ExtraData=self._CurrentLine + " (.|)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if self._ValueList[2] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No PCD value given", ExtraData=self._CurrentLine + " (.|)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) + + # Validate the datum type of Dynamic Defaul PCD and DynamicEx Default PCD + ValueList = GetSplitValueList(self._ValueList[2]) + if len(ValueList) > 1 and ValueList[1] != TAB_VOID \ + and self._ItemType in [MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT]: + EdkLogger.error('Parser', FORMAT_INVALID, "The datum type '%s' of PCD is wrong" % ValueList[1], + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) + # if value are 'True', 'true', 'TRUE' or 'False', 'false', 'FALSE', replace with integer 1 or 0. DscPcdValueList = GetSplitValueList(TokenList[1], TAB_VALUE_SPLIT, 1) if DscPcdValueList[0] in ['True', 'true', 'TRUE']: @@ -1036,6 +1058,7 @@ class DscParser(MetaFileParser): elif DscPcdValueList[0] in ['False', 'false', 'FALSE']: self._ValueList[2] = TokenList[1].replace(DscPcdValueList[0], '0', 1); + ## [components] section parser @ParseMacro def _ComponentParser(self): @@ -1052,15 +1075,15 @@ class DscParser(MetaFileParser): if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No library class or instance specified", ExtraData=self._CurrentLine + " (|)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if TokenList[0] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No library class specified", ExtraData=self._CurrentLine + " (|)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if TokenList[1] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No library instance specified", ExtraData=self._CurrentLine + " (|)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList[0:len(TokenList)] = TokenList @@ -1088,7 +1111,7 @@ class DscParser(MetaFileParser): "'%s' must be in format of ____FLAGS" % self._ValueList[1], ExtraData=self._CurrentLine, File=self.MetaFile, - Line=self._LineIndex+1 + Line=self._LineIndex + 1 ) ## Override parent's method since we'll do all macro replacements in parser @@ -1192,23 +1215,23 @@ class DscParser(MetaFileParser): " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section" " of the DSC file, and it is currently defined in this section:" " %s, line #: %d." % (Excpt.Pcd, Info[0], Info[1]), - File=self._FileWithError, ExtraData=' '.join(self._ValueList), - Line=self._LineIndex+1) + File=self._FileWithError, ExtraData=' '.join(self._ValueList), + Line=self._LineIndex + 1) else: EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s) is not defined in DSC file" % Excpt.Pcd, - File=self._FileWithError, ExtraData=' '.join(self._ValueList), - Line=self._LineIndex+1) + File=self._FileWithError, ExtraData=' '.join(self._ValueList), + Line=self._LineIndex + 1) else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt), - File=self._FileWithError, ExtraData=' '.join(self._ValueList), - Line=self._LineIndex+1) + File=self._FileWithError, ExtraData=' '.join(self._ValueList), + Line=self._LineIndex + 1) except MacroException, Excpt: EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), - File=self._FileWithError, ExtraData=' '.join(self._ValueList), - Line=self._LineIndex+1) + File=self._FileWithError, ExtraData=' '.join(self._ValueList), + Line=self._LineIndex + 1) if self._ValueList == None: - continue + continue NewOwner = self._IdMapping.get(Owner, -1) self._Enabled = int((not self._DirectiveEvalStack) or (False not in self._DirectiveEvalStack)) @@ -1221,10 +1244,10 @@ class DscParser(MetaFileParser): S2, NewOwner, self._From, - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, self._Enabled ) self._IdMapping[Id] = self._LastItem @@ -1248,25 +1271,25 @@ class DscParser(MetaFileParser): self._SubsectionType = MODEL_UNKNOWN def __RetrievePcdValue(self): - Records = self._RawTable.Query(MODEL_PCD_FEATURE_FLAG, BelongsToItem=-1.0) - for TokenSpaceGuid,PcdName,Value,Dummy2,Dummy3,ID,Line in Records: - Value, DatumType, MaxDatumSize = AnalyzePcdData(Value) + Records = self._RawTable.Query(MODEL_PCD_FEATURE_FLAG, BelongsToItem= -1.0) + for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records: Name = TokenSpaceGuid + '.' + PcdName - self._Symbols[Name] = Value + ValList, Valid, Index = AnalyzeDscPcd(Value, MODEL_PCD_FEATURE_FLAG) + self._Symbols[Name] = ValList[Index] - Records = self._RawTable.Query(MODEL_PCD_FIXED_AT_BUILD, BelongsToItem=-1.0) - for TokenSpaceGuid,PcdName,Value,Dummy2,Dummy3,ID,Line in Records: - Value, DatumType, MaxDatumSize = AnalyzePcdData(Value) + Records = self._RawTable.Query(MODEL_PCD_FIXED_AT_BUILD, BelongsToItem= -1.0) + for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records: Name = TokenSpaceGuid + '.' + PcdName - self._Symbols[Name] = Value + ValList, Valid, Index = AnalyzeDscPcd(Value, MODEL_PCD_FIXED_AT_BUILD) + self._Symbols[Name] = ValList[Index] Content = open(str(self.MetaFile), 'r').readlines() GlobalData.gPlatformOtherPcds['DSCFILE'] = str(self.MetaFile) for PcdType in (MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII, MODEL_PCD_DYNAMIC_EX_VPD): - Records = self._RawTable.Query(PcdType, BelongsToItem=-1.0) - for TokenSpaceGuid,PcdName,Value,Dummy2,Dummy3,ID,Line in Records: + Records = self._RawTable.Query(PcdType, BelongsToItem= -1.0) + for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records: Name = TokenSpaceGuid + '.' + PcdName if Name not in GlobalData.gPlatformOtherPcds: PcdLine = Line @@ -1287,13 +1310,13 @@ class DscParser(MetaFileParser): self._ConstructSectionMacroDict(Name, Value) elif self._ItemType == MODEL_META_DATA_GLOBAL_DEFINE: GlobalData.gEdkGlobal[Name] = Value - + # # Keyword in [Defines] section can be used as Macros # if (self._ItemType == MODEL_META_DATA_HEADER) and (self._SectionType == MODEL_META_DATA_HEADER): self._FileLocalMacros[Name] = Value - + self._ValueList = [Type, Name, Value] def __ProcessDirective(self): @@ -1313,8 +1336,8 @@ class DscParser(MetaFileParser): # the precise number of line and return the evaluation result # EdkLogger.warn('Parser', "Suspicious expression: %s" % str(Excpt), - File=self._FileWithError, ExtraData=' '.join(self._ValueList), - Line=self._LineIndex+1) + File=self._FileWithError, ExtraData=' '.join(self._ValueList), + Line=self._LineIndex + 1) Result = Excpt.result if self._ItemType in [MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, @@ -1368,7 +1391,7 @@ class DscParser(MetaFileParser): # Allow using MACROs comes from [Defines] section to keep compatible. # __IncludeMacros.update(self._Macros) - + IncludedFile = NormPath(ReplaceMacro(self._ValueList[1], __IncludeMacros, RaiseError=True)) # # First search the include file under the same directory as DSC file @@ -1382,14 +1405,14 @@ class DscParser(MetaFileParser): IncludedFile1 = PathClass(IncludedFile, GlobalData.gWorkspace) ErrorCode, ErrorInfo2 = IncludedFile1.Validate() if ErrorCode != 0: - EdkLogger.error('parser', ErrorCode, File=self._FileWithError, - Line=self._LineIndex+1, ExtraData=ErrorInfo1 + "\n"+ ErrorInfo2) + EdkLogger.error('parser', ErrorCode, File=self._FileWithError, + Line=self._LineIndex + 1, ExtraData=ErrorInfo1 + "\n" + ErrorInfo2) self._FileWithError = IncludedFile1 IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False) - Owner = self._Content[self._ContentIndex-1][0] - Parser = DscParser(IncludedFile1, self._FileType, IncludedFileTable, + Owner = self._Content[self._ContentIndex - 1][0] + Parser = DscParser(IncludedFile1, self._FileType, IncludedFileTable, Owner=Owner, From=Owner) # set the parser status with current status @@ -1403,17 +1426,17 @@ class DscParser(MetaFileParser): # update current status with sub-parser's status self._SectionName = Parser._SectionName self._SectionType = Parser._SectionType - self._Scope = Parser._Scope - self._Enabled = Parser._Enabled + self._Scope = Parser._Scope + self._Enabled = Parser._Enabled # 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) + self._Content.pop(self._ContentIndex - 1) self._ValueList = None self._ContentIndex -= 1 - + def __ProcessSkuId(self): self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=True) for Value in self._ValueList] @@ -1425,48 +1448,28 @@ class DscParser(MetaFileParser): self._ValueList[1] = ReplaceMacro(self._ValueList[1], self._Macros, RaiseError=True) def __ProcessPcd(self): - PcdValue = None - ValueList = GetSplitValueList(self._ValueList[2]) - # - # PCD value can be an expression - # - if len(ValueList) > 1 and ValueList[1] == 'VOID*': - PcdValue = ValueList[0] + if self._ItemType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]: + self._ValueList[2] = ReplaceMacro(self._ValueList[2], self._Macros, RaiseError=True) + return + + 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: try: - ValueList[0] = ValueExpression(PcdValue, self._Macros)(True) + ValList[Index] = ValueExpression(PcdValue, self._Macros)(True) except WrnExpression, Value: - ValueList[0] = Value.result - PcdValue = ValueList[0] - else: - # - # Int*/Boolean VPD PCD - # TokenSpace | PcdCName | Offset | [Value] - # - # VOID* VPD PCD - # TokenSpace | PcdCName | Offset | [Size] | [Value] - # - if self._ItemType == MODEL_PCD_DYNAMIC_VPD: - if len(ValueList) >= 4: - PcdValue = ValueList[-1] - else: - PcdValue = ValueList[-1] - # - # For the VPD PCD, there may not have PcdValue data in DSC file - # - if PcdValue: - try: - ValueList[-1] = ValueExpression(PcdValue, self._Macros)(True) - except WrnExpression, Value: - ValueList[-1] = Value.result - - if ValueList[-1] == 'True': - ValueList[-1] = '1' - if ValueList[-1] == 'False': - ValueList[-1] = '0' - PcdValue = ValueList[-1] - if PcdValue and self._ItemType in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]: - GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue - self._ValueList[2] = '|'.join(ValueList) + ValList[Index] = Value.result + + if ValList[Index] == 'True': + ValList[Index] = '1' + if ValList[Index] == 'False': + ValList[Index] = '0' + + GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue + self._ValueList[2] = '|'.join(ValList) def __ProcessComponent(self): self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros) @@ -1501,7 +1504,7 @@ class DscParser(MetaFileParser): MODEL_META_DATA_SUBSECTION_HEADER : _SubsectionHeaderParser, } - _Macros = property(_GetMacros) + _Macros = property(_GetMacros) ## DEC file parser class # @@ -1543,6 +1546,7 @@ class DecParser(MetaFileParser): MetaFileParser.__init__(self, FilePath, FileType, Table, -1) self._Comments = [] self._Version = 0x00010005 # Only EDK2 dec file is supported + self._AllPCDs = [] # Only for check duplicate PCD ## Parser starter def Start(self): @@ -1559,7 +1563,7 @@ class DecParser(MetaFileParser): # save comment for later use if Comment: - self._Comments.append((Comment, self._LineIndex+1)) + self._Comments.append((Comment, self._LineIndex + 1)) # skip empty line if Line == '': continue @@ -1574,7 +1578,7 @@ class DecParser(MetaFileParser): continue # section content - self._ValueList = ['','',''] + self._ValueList = ['', '', ''] self._SectionParser[self._SectionType[0]](self) if self._ValueList == None or self._ItemType == MODEL_META_DATA_DEFINE: self._ItemType = -1 @@ -1594,10 +1598,10 @@ class DecParser(MetaFileParser): Arch, ModuleType, self._Owner[-1], - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, 0 ) for Comment, LineNo in self._Comments: @@ -1610,9 +1614,9 @@ class DecParser(MetaFileParser): ModuleType, self._LastItem, LineNo, - -1, + - 1, LineNo, - -1, + - 1, 0 ) self._Comments = [] @@ -1630,10 +1634,13 @@ class DecParser(MetaFileParser): self._SectionName = '' self._SectionType = [] ArchList = set() - for Item in GetSplitValueList(self._CurrentLine[1:-1], TAB_COMMA_SPLIT): + Line = self._CurrentLine.replace("%s%s" % (TAB_COMMA_SPLIT, TAB_SPACE_SPLIT), TAB_COMMA_SPLIT) + for Item in Line[1:-1].split(TAB_COMMA_SPLIT): if Item == '': - continue - ItemList = GetSplitValueList(Item, TAB_SPLIT) + EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, + "section name can NOT be empty or incorrectly use separator comma", + self.MetaFile, self._LineIndex + 1, self._CurrentLine) + ItemList = Item.split(TAB_SPLIT) # different types of PCD are permissible in one section self._SectionName = ItemList[0].upper() @@ -1641,9 +1648,8 @@ class DecParser(MetaFileParser): if self.DataType[self._SectionName] not in self._SectionType: self._SectionType.append(self.DataType[self._SectionName]) else: - EdkLogger.warn("Parser", "Unrecognized section", File=self.MetaFile, - Line=self._LineIndex+1, ExtraData=self._CurrentLine) - continue + EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item, + self.MetaFile, self._LineIndex + 1, self._CurrentLine) if MODEL_PCD_FEATURE_FLAG in self._SectionType and len(self._SectionType) > 1: EdkLogger.error( @@ -1651,7 +1657,7 @@ class DecParser(MetaFileParser): FORMAT_INVALID, "%s must not be in the same section of other types of PCD" % TAB_PCDS_FEATURE_FLAG_NULL, File=self.MetaFile, - Line=self._LineIndex+1, + Line=self._LineIndex + 1, ExtraData=self._CurrentLine ) # S1 is always Arch @@ -1671,7 +1677,7 @@ class DecParser(MetaFileParser): # 'COMMON' must not be used with specific ARCHs at the same section if 'COMMON' in ArchList and len(ArchList) > 1: EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs", - File=self.MetaFile, Line=self._LineIndex+1, ExtraData=self._CurrentLine) + File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine) ## [guids], [ppis] and [protocols] section parser @ParseMacro @@ -1680,20 +1686,20 @@ class DecParser(MetaFileParser): if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No GUID name or value specified", ExtraData=self._CurrentLine + " ( = )", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if TokenList[0] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No GUID name specified", ExtraData=self._CurrentLine + " ( = )", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if TokenList[1] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No GUID value specified", ExtraData=self._CurrentLine + " ( = )", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if TokenList[1][0] != '{' or TokenList[1][-1] != '}' or GuidStructureStringToGuidString(TokenList[1]) == '': EdkLogger.error('Parser', FORMAT_INVALID, "Invalid GUID value format", ExtraData=self._CurrentLine + \ " ( = )", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) self._ValueList[0] = TokenList[0] self._ValueList[1] = TokenList[1] @@ -1709,67 +1715,88 @@ class DecParser(MetaFileParser): def _PcdParser(self): TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT) + ValueRe = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*') # check PCD information if self._ValueList[0] == '' or self._ValueList[1] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified", ExtraData=self._CurrentLine + \ " (.|||)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) + # check format of token space GUID CName + if not ValueRe.match(self._ValueList[0]): + EdkLogger.error('Parser', FORMAT_INVALID, "The format of the token space GUID CName is invalid. The correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'", + ExtraData=self._CurrentLine + \ + " (.|||)", + File=self.MetaFile, Line=self._LineIndex + 1) + # check format of PCD CName + if not ValueRe.match(self._ValueList[1]): + EdkLogger.error('Parser', FORMAT_INVALID, "The format of the PCD CName is invalid. The correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'", + ExtraData=self._CurrentLine + \ + " (.|||)", + File=self.MetaFile, Line=self._LineIndex + 1) # check PCD datum information if len(TokenList) < 2 or TokenList[1] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum information given", ExtraData=self._CurrentLine + \ " (.|||)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) + - - ValueRe = re.compile(r'^\s*L?\".*\|.*\"') + ValueRe = re.compile(r'^\s*L?\".*\|.*\"') PtrValue = ValueRe.findall(TokenList[1]) - + # Has VOID* type string, may contain "|" character in the string. if len(PtrValue) != 0: ptrValueList = re.sub(ValueRe, '', TokenList[1]) - ValueList = GetSplitValueList(ptrValueList) + ValueList = GetSplitValueList(ptrValueList) ValueList[0] = PtrValue[0] else: ValueList = GetSplitValueList(TokenList[1]) - - + + # check if there's enough datum information given if len(ValueList) != 3: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid PCD Datum information given", ExtraData=self._CurrentLine + \ " (.|||)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) # check default value if ValueList[0] == '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing DefaultValue in PCD Datum information", ExtraData=self._CurrentLine + \ " (.|||)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) # check datum type if ValueList[1] == '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing DatumType in PCD Datum information", ExtraData=self._CurrentLine + \ " (.|||)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) # check token of the PCD if ValueList[2] == '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing Token in PCD Datum information", ExtraData=self._CurrentLine + \ " (.|||)", - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) # check format of default value against the datum type IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0]) if not IsValid: EdkLogger.error('Parser', FORMAT_INVALID, Cause, ExtraData=self._CurrentLine, - File=self.MetaFile, Line=self._LineIndex+1) + File=self.MetaFile, Line=self._LineIndex + 1) if ValueList[0] in ['True', 'true', 'TRUE']: ValueList[0] = '1' elif ValueList[0] in ['False', 'false', 'FALSE']: ValueList[0] = '0' + # check for duplicate PCD definition + if (self._Scope[0], self._ValueList[0], self._ValueList[1]) in self._AllPCDs: + EdkLogger.error('Parser', FORMAT_INVALID, + "The same PCD name and GUID have been already defined", + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) + else: + self._AllPCDs.append((self._Scope[0], self._ValueList[0], self._ValueList[1])) + self._ValueList[2] = ValueList[0].strip() + '|' + ValueList[1].strip() + '|' + ValueList[2].strip() _SectionParser = { diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py new file mode 100644 index 0000000000..60acc914e9 --- /dev/null +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -0,0 +1,237 @@ +## @file +# Common routines used by workspace +# +# Copyright (c) 2012, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +from Common.Misc import sdict +from Common.DataType import SUP_MODULE_USER_DEFINED +from BuildClassObject import LibraryClassObject + +## Get all packages from platform for specified arch, target and toolchain +# +# @param Platform: DscBuildData instance +# @param BuildDatabase: The database saves all data for all metafiles +# @param Arch: Current arch +# @param Target: Current target +# @param Toolchain: Current toolchain +# @retval: List of packages which are DecBuildData instances +# +def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain): + PkgSet = set() + for ModuleFile in Platform.Modules: + Data = BuildDatabase[ModuleFile, Arch, Target, Toolchain] + PkgSet.update(Data.Packages) + for Lib in GetLiabraryInstances(Data, Platform, BuildDatabase, Arch, Target, Toolchain): + PkgSet.update(Lib.Packages) + return list(PkgSet) + +## Get all declared PCD from platform for specified arch, target and toolchain +# +# @param Platform: DscBuildData instance +# @param BuildDatabase: The database saves all data for all metafiles +# @param Arch: Current arch +# @param Target: Current target +# @param Toolchain: Current toolchain +# @retval: A dictionary contains instances of PcdClassObject with key (PcdCName, TokenSpaceGuid) +# +def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain): + PkgList = GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain) + DecPcds = {} + for Pkg in PkgList: + for Pcd in Pkg.Pcds: + DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd] + return DecPcds + +## Get all dependent libraries for a module +# +# @param Module: InfBuildData instance +# @param Platform: DscBuildData instance +# @param BuildDatabase: The database saves all data for all metafiles +# @param Arch: Current arch +# @param Target: Current target +# @param Toolchain: Current toolchain +# @retval: List of dependent libraries which are InfBuildData instances +# +def GetLiabraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain): + if Module.AutoGenVersion >= 0x00010005: + return _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain) + else: + return _ResolveLibraryReference(Module, Platform) + +def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain): + ModuleType = Module.ModuleType + + # for overriding library instances with module specific setting + PlatformModule = Platform.Modules[str(Module)] + + # add forced library instances (specified under LibraryClasses sections) + # + # If a module has a MODULE_TYPE of USER_DEFINED, + # do not link in NULL library class instances from the global [LibraryClasses.*] sections. + # + if Module.ModuleType != SUP_MODULE_USER_DEFINED: + for LibraryClass in Platform.LibraryClasses.GetKeys(): + if LibraryClass.startswith("NULL") and Platform.LibraryClasses[LibraryClass, Module.ModuleType]: + Module.LibraryClasses[LibraryClass] = Platform.LibraryClasses[LibraryClass, Module.ModuleType] + + # add forced library instances (specified in module overrides) + for LibraryClass in PlatformModule.LibraryClasses: + if LibraryClass.startswith("NULL"): + Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass] + + # EdkII module + LibraryConsumerList = [Module] + Constructor = [] + ConsumedByList = sdict() + LibraryInstance = sdict() + + while len(LibraryConsumerList) > 0: + M = LibraryConsumerList.pop() + for LibraryClassName in M.LibraryClasses: + if LibraryClassName not in LibraryInstance: + # override library instance for this module + if LibraryClassName in PlatformModule.LibraryClasses: + LibraryPath = PlatformModule.LibraryClasses[LibraryClassName] + else: + LibraryPath = Platform.LibraryClasses[LibraryClassName, ModuleType] + if LibraryPath == None or LibraryPath == "": + LibraryPath = M.LibraryClasses[LibraryClassName] + if LibraryPath == None or LibraryPath == "": + return [] + + LibraryModule = BuildDatabase[LibraryPath, Arch, Target, Toolchain] + # for those forced library instance (NULL library), add a fake library class + if LibraryClassName.startswith("NULL"): + LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType])) + elif LibraryModule.LibraryClass == None \ + or len(LibraryModule.LibraryClass) == 0 \ + or (ModuleType != 'USER_DEFINED' + and ModuleType not in LibraryModule.LibraryClass[0].SupModList): + # only USER_DEFINED can link against any library instance despite of its SupModList + return [] + + LibraryInstance[LibraryClassName] = LibraryModule + LibraryConsumerList.append(LibraryModule) + else: + LibraryModule = LibraryInstance[LibraryClassName] + + if LibraryModule == None: + continue + + if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor: + Constructor.append(LibraryModule) + + if LibraryModule not in ConsumedByList: + ConsumedByList[LibraryModule] = [] + # don't add current module itself to consumer list + if M != Module: + if M in ConsumedByList[LibraryModule]: + continue + ConsumedByList[LibraryModule].append(M) + # + # Initialize the sorted output list to the empty set + # + SortedLibraryList = [] + # + # Q <- Set of all nodes with no incoming edges + # + LibraryList = [] #LibraryInstance.values() + Q = [] + for LibraryClassName in LibraryInstance: + M = LibraryInstance[LibraryClassName] + LibraryList.append(M) + if ConsumedByList[M] == []: + Q.append(M) + + # + # start the DAG algorithm + # + while True: + EdgeRemoved = True + while Q == [] and EdgeRemoved: + EdgeRemoved = False + # for each node Item with a Constructor + for Item in LibraryList: + if Item not in Constructor: + continue + # for each Node without a constructor with an edge e from Item to Node + for Node in ConsumedByList[Item]: + if Node in Constructor: + continue + # remove edge e from the graph if Node has no constructor + ConsumedByList[Item].remove(Node) + EdgeRemoved = True + if ConsumedByList[Item] == []: + # insert Item into Q + Q.insert(0, Item) + break + if Q != []: + break + # DAG is done if there's no more incoming edge for all nodes + if Q == []: + break + + # remove node from Q + Node = Q.pop() + # output Node + SortedLibraryList.append(Node) + + # for each node Item with an edge e from Node to Item do + for Item in LibraryList: + if Node not in ConsumedByList[Item]: + continue + # remove edge e from the graph + ConsumedByList[Item].remove(Node) + + if ConsumedByList[Item] != []: + continue + # insert Item into Q, if Item has no other incoming edges + Q.insert(0, Item) + + # + # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle + # + for Item in LibraryList: + if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1: + return [] + if Item not in SortedLibraryList: + SortedLibraryList.append(Item) + + # + # Build the list of constructor and destructir names + # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order + # + SortedLibraryList.reverse() + return SortedLibraryList + +def _ResolveLibraryReference(Module, Platform): + 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 = Platform.LibraryClasses[LibraryName, ':dummy:'] + if Library == None: + for Key in Platform.LibraryClasses.data.keys(): + if LibraryName.upper() == Key.upper(): + Library = Platform.LibraryClasses[Key, ':dummy:'] + break + if Library == None: + continue + + if Library not in LibraryList: + LibraryList.append(Library) + LibraryConsumerList.append(Library) + return LibraryList diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index e5fb41a8e0..19c00ca78d 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -34,6 +34,8 @@ from MetaDataTable import * from MetaFileTable import * from MetaFileParser import * from BuildClassObject import * +from WorkspaceCommon import GetDeclaredPcd +from Common.Misc import AnalyzeDscPcd ## Platform build information from DSC file # @@ -134,6 +136,7 @@ class DscBuildData(PlatformBuildClassObject): self._LibraryInstances = None self._LibraryClasses = None self._Pcds = None + self._DecPcds = None self._BuildOptions = None self._LoadFixAddress = None self._RFCLanguages = None @@ -613,6 +616,46 @@ class DscBuildData(PlatformBuildClassObject): self._LibraryClasses[Library.BaseName, ':dummy:'] = Library return self._LibraryClasses + def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo): + if self._DecPcds == None: + self._DecPcds = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain) + if (PcdCName, TokenSpaceGuid) not in self._DecPcds: + EdkLogger.error('build', PARSER_ERROR, + "Pcd (%s.%s) defined in DSC is not declared in DEC files." % (TokenSpaceGuid, PcdCName), + File=self.MetaFile, Line=LineNo) + ValueList, IsValid, Index = AnalyzeDscPcd(Setting, PcdType, self._DecPcds[PcdCName, TokenSpaceGuid].DatumType) + if not IsValid and PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]: + EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self.MetaFile, Line=LineNo, + ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting)) + if ValueList[Index] and PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]: + try: + ValueList[Index] = ValueExpression(ValueList[Index], GlobalData.gPlatformPcds)(True) + except WrnExpression, Value: + ValueList[Index] = Value.result + except EvaluationException, Excpt: + if hasattr(Excpt, 'Pcd'): + if Excpt.Pcd in GlobalData.gPlatformOtherPcds: + EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as" + " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section" + " of the DSC file" % Excpt.Pcd, + File=self.MetaFile, Line=LineNo) + else: + EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s) is not defined in DSC file" % Excpt.Pcd, + File=self.MetaFile, Line=LineNo) + else: + EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt), + File=self.MetaFile, Line=LineNo) + if ValueList[Index] == 'True': + ValueList[Index] = '1' + elif ValueList[Index] == 'False': + ValueList[Index] = '0' + if ValueList[Index]: + Valid, ErrStr = CheckPcdDatum(self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueList[Index]) + if not Valid: + EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo, + ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName)) + return ValueList + ## Retrieve all PCD settings in platform def _GetPcds(self): if self._Pcds == None: @@ -663,14 +706,14 @@ class DscBuildData(PlatformBuildClassObject): # Find out all possible PCD candidates for self._Arch RecordList = self._RawData[Type, self._Arch] for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList: - PcdSet.add((PcdCName, TokenSpaceGuid)) + PcdSet.add((PcdCName, TokenSpaceGuid, Dummy4)) PcdDict[Arch, PcdCName, TokenSpaceGuid] = Setting # Remove redundant PCD candidates - for PcdCName, TokenSpaceGuid in PcdSet: + for PcdCName, TokenSpaceGuid, Dummy4 in PcdSet: Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid] if Setting == None: continue - PcdValue, DatumType, MaxDatumSize = AnalyzePcdData(Setting) + PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject( PcdCName, TokenSpaceGuid, @@ -702,15 +745,15 @@ class DscBuildData(PlatformBuildClassObject): # Find out all possible PCD candidates for self._Arch RecordList = self._RawData[Type, self._Arch] for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList: - PcdList.append((PcdCName, TokenSpaceGuid)) + PcdList.append((PcdCName, TokenSpaceGuid, Dummy4)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting # Remove redundant PCD candidates, per the ARCH and SKU - for PcdCName, TokenSpaceGuid in PcdList: + for PcdCName, TokenSpaceGuid, Dummy4 in PcdList: Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid] if Setting == None: continue - PcdValue, DatumType, MaxDatumSize = AnalyzePcdData(Setting) + PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', '', PcdValue) Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject( @@ -744,14 +787,14 @@ class DscBuildData(PlatformBuildClassObject): RecordList = self._RawData[Type, self._Arch] # Find out all possible PCD candidates for self._Arch for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList: - PcdSet.add((PcdCName, TokenSpaceGuid)) + PcdSet.add((PcdCName, TokenSpaceGuid, Dummy4)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting # Remove redundant PCD candidates, per the ARCH and SKU - for PcdCName, TokenSpaceGuid in PcdSet: + for PcdCName, TokenSpaceGuid, Dummy4 in PcdSet: Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid] if Setting == None: continue - VariableName, VariableGuid, VariableOffset, DefaultValue = AnalyzeHiiPcdData(Setting) + VariableName, VariableGuid, VariableOffset, DefaultValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue) Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject( PcdCName, @@ -784,10 +827,10 @@ class DscBuildData(PlatformBuildClassObject): # Find out all possible PCD candidates for self._Arch RecordList = self._RawData[Type, self._Arch] for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList: - PcdList.append((PcdCName, TokenSpaceGuid)) + PcdList.append((PcdCName, TokenSpaceGuid, Dummy4)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting # Remove redundant PCD candidates, per the ARCH and SKU - for PcdCName, TokenSpaceGuid in PcdList: + for PcdCName, TokenSpaceGuid, Dummy4 in PcdList: Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid] if Setting == None: continue @@ -797,7 +840,7 @@ class DscBuildData(PlatformBuildClassObject): # At this point, we put all the data into the PcdClssObject for we don't know the PCD's datumtype # until the DEC parser has been called. # - VpdOffset, MaxDatumSize, InitialValue = AnalyzeVpdPcdData(Setting) + VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', VpdOffset, InitialValue) Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject( @@ -842,32 +885,6 @@ class DscBuildData(PlatformBuildClassObject): self.Pcds[Name, Guid] = PcdClassObject(Name, Guid, '', '', '', '', '', {}, False, None) self.Pcds[Name, Guid].DefaultValue = Value - def IsPlatformPcdDeclared(self, DecPcds): - for PcdType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_FEATURE_FLAG, - MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_VPD, - MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII, MODEL_PCD_DYNAMIC_EX_VPD): - RecordList = self._RawData[PcdType, self._Arch] - for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList: - if (PcdCName, TokenSpaceGuid) not in DecPcds: - EdkLogger.error('build', PARSER_ERROR, - "Pcd (%s.%s) defined in DSC is not declared in DEC files." % (TokenSpaceGuid, PcdCName), - File=self.MetaFile, Line=Dummy4) - PcdValue = '' - if PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD): - if DecPcds[PcdCName, TokenSpaceGuid].DatumType == "VOID*": - PcdValue = AnalyzeVpdPcdData(Setting)[2] - else: - PcdValue = AnalyzeVpdPcdData(Setting)[1] - elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII): - PcdValue = AnalyzeHiiPcdData(Setting)[3] - else: - PcdValue = AnalyzePcdData(Setting)[0] - if PcdValue: - Valid, ErrStr = CheckPcdDatum(DecPcds[PcdCName, TokenSpaceGuid].DatumType, PcdValue) - if not Valid: - EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=Dummy4, - ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName)) - _Macros = property(_GetMacros) Arch = property(_GetArch, _SetArch) Platform = property(_GetPlatformName) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index d5ea3bd3e5..2058a7bae7 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -4,7 +4,7 @@ # This module contains the functionality to generate build report after # build all target completes successfully. # -# Copyright (c) 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -72,6 +72,9 @@ gGlueLibEntryPoint = re.compile(r"__EDKII_GLUE_MODULE_ENTRY_POINT__\s*=\s*(\w+)" ## Tags for MaxLength of line in report gLineMaxLength = 120 +## Tags for end of line in report +gEndOfLine = "\r\n" + ## Tags for section start, end and separator gSectionStart = ">" + "=" * (gLineMaxLength-2) + "<" gSectionEnd = "<" + "=" * (gLineMaxLength-2) + ">" + "\n" @@ -91,9 +94,9 @@ gPcdTypeMap = { 'Dynamic' : ('DYN', 'Dynamic'), 'DynamicHii' : ('DYNHII', 'Dynamic'), 'DynamicVpd' : ('DYNVPD', 'Dynamic'), - 'DynamicEx' : ('DEX', 'Dynamic'), - 'DynamicExHii' : ('DEXHII', 'Dynamic'), - 'DynamicExVpd' : ('DEXVPD', 'Dynamic'), + 'DynamicEx' : ('DEX', 'DynamicEx'), + 'DynamicExHii' : ('DEXHII', 'DynamicEx'), + 'DynamicExVpd' : ('DEXVPD', 'DynamicEx'), } ## The look up table to map module type to driver type @@ -128,7 +131,7 @@ gOpCodeList = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "FALSE", " def FileWrite(File, String, Wrapper=False): if Wrapper: String = textwrap.fill(String, 120) - File.write(String + "\r\n") + File.write(String + gEndOfLine) ## # Find all the header file that the module source directly includes. @@ -203,6 +206,8 @@ def FileLinesSplit(Content=None, MaxLength=None): NewContentList.append(Line) for NewLine in NewContentList: NewContent += NewLine + TAB_LINE_BREAK + + NewContent = NewContent.replace(TAB_LINE_BREAK, gEndOfLine).replace('\r\r\n', gEndOfLine) return NewContent @@ -694,7 +699,8 @@ class PcdReport(object): # Collect PCDs defined in DSC common section # self.DscPcdDefault = {} - for Platform in Wa.BuildDatabase.WorkspaceDb.PlatformList: + for Arch in Wa.ArchList: + Platform = Wa.BuildDatabase[Wa.MetaFile, Arch, Wa.BuildTarget, Wa.ToolChain] for (TokenCName, TokenSpaceGuidCName) in Platform.Pcds: DscDefaultValue = Platform.Pcds[(TokenCName, TokenSpaceGuidCName)].DefaultValue if DscDefaultValue: diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index a463c527be..24a6ed8168 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -1,7 +1,7 @@ ## @file # build a platform or a module # -# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -23,7 +23,7 @@ import glob import time import platform import traceback -import encodings.ascii +import encodings.ascii from struct import * from threading import * @@ -47,9 +47,9 @@ import Common.EdkLogger import Common.GlobalData as GlobalData # Version and Copyright -VersionNumber = "0.5" + ' ' + gBUILD_VERSION +VersionNumber = "0.51" + ' ' + gBUILD_VERSION __version__ = "%prog Version " + VersionNumber -__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved." +__copyright__ = "Copyright (c) 2007 - 2013, Intel Corporation All rights reserved." ## standard targets of build command gSupportedTarget = ['all', 'genc', 'genmake', 'modules', 'libraries', 'fds', 'clean', 'cleanall', 'cleanlib', 'run'] @@ -119,12 +119,12 @@ def CheckEnvVariable(): EfiSourceDir = os.path.normcase(os.path.normpath(os.environ["EFI_SOURCE"])) EdkSourceDir = os.path.normcase(os.path.normpath(os.environ["EDK_SOURCE"])) EcpSourceDir = os.path.normcase(os.path.normpath(os.environ["ECP_SOURCE"])) - + os.environ["EFI_SOURCE"] = EfiSourceDir os.environ["EDK_SOURCE"] = EdkSourceDir os.environ["ECP_SOURCE"] = EcpSourceDir os.environ["EDK_TOOLS_PATH"] = os.path.normcase(os.environ["EDK_TOOLS_PATH"]) - + if not os.path.exists(EcpSourceDir): EdkLogger.verbose("ECP_SOURCE = %s doesn't exist. Edk modules could not be built." % EcpSourceDir) elif ' ' in EcpSourceDir: @@ -313,7 +313,7 @@ class BuildUnit: if not BuildCommand: EdkLogger.error("build", OPTION_MISSING, "No build command found for this module. " - "Please check your setting of %s_%s_%s_MAKE_PATH in Conf/tools_def.txt file." % + "Please check your setting of %s_%s_%s_MAKE_PATH in Conf/tools_def.txt file." % (Obj.BuildTarget, Obj.ToolChain, Obj.Arch), ExtraData=str(Obj)) @@ -669,7 +669,7 @@ class PeImageInfo(): # # Constructor will load all required image information. # - # @param BaseName The full file path of image. + # @param BaseName The full file path of image. # @param Guid The GUID for image. # @param Arch Arch of this image. # @param OutputDir The output directory for image. @@ -838,7 +838,7 @@ class Build(): # def InitBuild(self): # parse target.txt, tools_def.txt, and platform file - self.LoadConfiguration() + self.LoadConfiguration() # Allow case-insensitive for those from command line or configuration file ErrorCode, ErrorInfo = self.PlatformFile.Validate(".dsc", False) @@ -897,7 +897,7 @@ class Build(): if BuildCommand == None or len(BuildCommand) == 0: EdkLogger.error("build", OPTION_MISSING, "No build command found for this module. " - "Please check your setting of %s_%s_%s_MAKE_PATH in Conf/tools_def.txt file." % + "Please check your setting of %s_%s_%s_MAKE_PATH in Conf/tools_def.txt file." % (AutoGenObject.BuildTarget, AutoGenObject.ToolChain, AutoGenObject.Arch), ExtraData=str(AutoGenObject)) @@ -994,9 +994,9 @@ class Build(): elif SectionHeader[0] in ['.data', '.sdata']: DataSectionAddress = SectionHeader[1] if AddrIsOffset: - MapBuffer.write('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress))) + MapBuffer.write('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress))) else: - MapBuffer.write('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress)) + MapBuffer.write('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress)) # # Add debug image full path. # @@ -1076,7 +1076,7 @@ class Build(): for ModuleGuid in ModuleList: Module = ModuleList[ModuleGuid] GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (Module.MetaFile, Module.Arch, Module.ToolChain, Module.BuildTarget) - + OutputImageFile = '' for ResultFile in Module.CodaTargetList: if str(ResultFile.Target).endswith('.efi'): @@ -1127,15 +1127,15 @@ class Build(): if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE and Pcd.TokenCName in TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_LIST: ModuleIsPatch = True break - + if not ModuleIsPatch: continue # # Module includes the patchable load fix address PCDs. - # It will be fixed up later. + # It will be fixed up later. # PatchEfiImageList.append (OutputImageFile) - + # # Get Top Memory address # @@ -1155,14 +1155,14 @@ class Build(): # # Patch FixAddress related PCDs into EFI image # - for EfiImage in PatchEfiImageList: + for EfiImage in PatchEfiImageList: EfiImageMap = EfiImage.replace('.efi', '.map') if not os.path.exists(EfiImageMap): continue # # Get PCD offset in EFI image by GenPatchPcdTable function # - PcdTable = parsePcdInfoFromMapFile(EfiImageMap, EfiImage) + PcdTable = parsePcdInfoFromMapFile(EfiImageMap, EfiImage) # # Patch real PCD value by PatchPcdValue tool # @@ -1178,16 +1178,16 @@ class Build(): ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize/0x1000)) if ReturnValue != 0: EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD value failed", ExtraData=ErrorInfo) - + MapBuffer.write('PEI_CODE_PAGE_NUMBER = 0x%x\n' % (PeiSize/0x1000)) MapBuffer.write('BOOT_CODE_PAGE_NUMBER = 0x%x\n' % (BtSize/0x1000)) MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER = 0x%x\n' % (RtSize/0x1000)) if len (SmmModuleList) > 0: MapBuffer.write('SMM_CODE_PAGE_NUMBER = 0x%x\n' % (SmmSize/0x1000)) - - PeiBaseAddr = TopMemoryAddress - RtSize - BtSize + + PeiBaseAddr = TopMemoryAddress - RtSize - BtSize BtBaseAddr = TopMemoryAddress - RtSize - RtBaseAddr = TopMemoryAddress - ReservedRuntimeMemorySize + RtBaseAddr = TopMemoryAddress - ReservedRuntimeMemorySize self._RebaseModule (MapBuffer, PeiBaseAddr, PeiModuleList, TopMemoryAddress == 0) self._RebaseModule (MapBuffer, BtBaseAddr, BtModuleList, TopMemoryAddress == 0) @@ -1196,7 +1196,7 @@ class Build(): MapBuffer.write('\n\n') sys.stdout.write ("\n") sys.stdout.flush() - + ## Save platform Map file # def _SaveMapFile (self, MapBuffer, Wa): @@ -1243,7 +1243,7 @@ class Build(): self.BuildReport.AddPlatformReport(Wa) self.Progress.Stop("done!") self._Build(self.Target, Wa) - + # Create MAP file when Load Fix Address is enabled. if self.Target in ["", "all", "fds"]: for Arch in Wa.ArchList: @@ -1292,7 +1292,7 @@ class Build(): GlobalData.gGlobalDefines['TARGET'] = BuildTarget for ToolChain in self.ToolChainList: GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain - GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain + GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain # # module build needs platform build information, so get platform # AutoGen first @@ -1383,7 +1383,7 @@ class Build(): GlobalData.gGlobalDefines['TARGET'] = BuildTarget for ToolChain in self.ToolChainList: GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain - GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain + GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain Wa = WorkspaceAutoGen( self.WorkspaceDir, self.PlatformFile, @@ -1414,6 +1414,7 @@ class Build(): Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch) if Pa == None: continue + pModules = [] for Module in Pa.Platform.Modules: # Get ModuleAutoGen object to generate C code file and makefile Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile) @@ -1433,6 +1434,9 @@ class Build(): if self.Target == "genmake": continue self.Progress.Stop("done!") + pModules.append(Ma) + + for Ma in pModules: # Generate build task for the module Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target)) # Break build if any build thread has error @@ -1537,10 +1541,10 @@ class Build(): if not os.path.exists(FvDir): continue - for Arch in self.ArchList: + for Arch in self.ArchList: # Build up the list of supported architectures for this build prefix = '%s_%s_%s_' % (BuildTarget, ToolChain, Arch) - + # Look through the tool definitions for GUIDed tools guidAttribs = [] for (attrib, value) in self.ToolDef.ToolsDefTxtDictionary.iteritems(): @@ -1555,7 +1559,7 @@ class Build(): path = self.ToolDef.ToolsDefTxtDictionary[path] path = self.GetFullPathOfTool(path) guidAttribs.append((guid, toolName, path)) - + # Write out GuidedSecTools.txt toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt') toolsFile = open(toolsFile, 'wt') @@ -1632,7 +1636,7 @@ def ParseDefines(DefineList=[]): EdkLogger.error('build', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*", ExtraData=DefineTokenList[0]) - + if len(DefineTokenList) == 1: DefineDict[DefineTokenList[0]] = "TRUE" else: @@ -1656,8 +1660,8 @@ def SingleCheckCallback(option, opt_str, value, parser): # def MyOptionParser(): Parser = OptionParser(description=__copyright__,version=__version__,prog="build.exe",usage="%prog [options] [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]") - Parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32','X64','IPF','EBC','ARM'], dest="TargetArch", - help="ARCHS is one of list: IA32, X64, IPF, ARM or EBC, which overrides target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option.") + Parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32','X64','IPF','EBC','ARM', 'AARCH64'], dest="TargetArch", + help="ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC, which overrides target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option.") Parser.add_option("-p", "--platform", action="callback", type="string", dest="PlatformFile", callback=SingleCheckCallback, help="Build the platform specified by the DSC file name argument, overriding target.txt's ACTIVE_PLATFORM definition.") Parser.add_option("-m", "--module", action="callback", type="string", dest="ModuleFile", callback=SingleCheckCallback, -- cgit v1.2.3