From: lgao4 Date: Fri, 25 Nov 2011 06:21:03 +0000 (+0000) Subject: Sync BaseTool trunk (version r2423) into EDKII BaseTools. The change mainly includes: X-Git-Tag: edk2-stable201903~13834 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=2bcc713e74b944bb5aefb433ef33fb4002a62d76;hp=c32dcd284c19bbb0b1db3606a243d9d69d37d6ab;p=mirror_edk2.git Sync BaseTool trunk (version r2423) into EDKII BaseTools. The change mainly includes: 1. Fix !include issues 2. Fix Trim to skip the postfix 'U' for hexadecimal and decimal numbers 3. Fix building error C2733 when building C++ code. 4. Add GCC46 tool chain definition 5. Add new RVCT and RVCTLINUX tool chains Signed-off-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12782 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/BaseTools/Bin/Win32/BPDG.exe b/BaseTools/Bin/Win32/BPDG.exe index b198906dbc..d75855948c 100644 Binary files a/BaseTools/Bin/Win32/BPDG.exe and b/BaseTools/Bin/Win32/BPDG.exe differ diff --git a/BaseTools/Bin/Win32/BootSectImage.exe b/BaseTools/Bin/Win32/BootSectImage.exe index 7c0278dce7..a278b171b4 100755 Binary files a/BaseTools/Bin/Win32/BootSectImage.exe and b/BaseTools/Bin/Win32/BootSectImage.exe differ diff --git a/BaseTools/Bin/Win32/EfiLdrImage.exe b/BaseTools/Bin/Win32/EfiLdrImage.exe index a84e8c6be3..ccd168488d 100755 Binary files a/BaseTools/Bin/Win32/EfiLdrImage.exe and b/BaseTools/Bin/Win32/EfiLdrImage.exe differ diff --git a/BaseTools/Bin/Win32/EfiRom.exe b/BaseTools/Bin/Win32/EfiRom.exe index 8b5ff4b4bf..d7f3e71c27 100755 Binary files a/BaseTools/Bin/Win32/EfiRom.exe and b/BaseTools/Bin/Win32/EfiRom.exe differ diff --git a/BaseTools/Bin/Win32/Fpd2Dsc.exe b/BaseTools/Bin/Win32/Fpd2Dsc.exe index fdd78439c7..938a3820a0 100755 Binary files a/BaseTools/Bin/Win32/Fpd2Dsc.exe and b/BaseTools/Bin/Win32/Fpd2Dsc.exe differ diff --git a/BaseTools/Bin/Win32/GenBootSector.exe b/BaseTools/Bin/Win32/GenBootSector.exe index 7b640e9283..d5149510f9 100755 Binary files a/BaseTools/Bin/Win32/GenBootSector.exe and b/BaseTools/Bin/Win32/GenBootSector.exe differ diff --git a/BaseTools/Bin/Win32/GenCrc32.exe b/BaseTools/Bin/Win32/GenCrc32.exe index ee7237ad1e..4003ba8541 100755 Binary files a/BaseTools/Bin/Win32/GenCrc32.exe and b/BaseTools/Bin/Win32/GenCrc32.exe differ diff --git a/BaseTools/Bin/Win32/GenDepex.exe b/BaseTools/Bin/Win32/GenDepex.exe index 1143ee7355..8afed63010 100755 Binary files a/BaseTools/Bin/Win32/GenDepex.exe and b/BaseTools/Bin/Win32/GenDepex.exe differ diff --git a/BaseTools/Bin/Win32/GenFds.exe b/BaseTools/Bin/Win32/GenFds.exe index c6cdeb9049..470ed8aa98 100755 Binary files a/BaseTools/Bin/Win32/GenFds.exe and b/BaseTools/Bin/Win32/GenFds.exe differ diff --git a/BaseTools/Bin/Win32/GenFfs.exe b/BaseTools/Bin/Win32/GenFfs.exe index 21294a6d57..f0ab6d84f9 100755 Binary files a/BaseTools/Bin/Win32/GenFfs.exe and b/BaseTools/Bin/Win32/GenFfs.exe differ diff --git a/BaseTools/Bin/Win32/GenFv.exe b/BaseTools/Bin/Win32/GenFv.exe index a362959994..2b58bf51c0 100755 Binary files a/BaseTools/Bin/Win32/GenFv.exe and b/BaseTools/Bin/Win32/GenFv.exe differ diff --git a/BaseTools/Bin/Win32/GenFw.exe b/BaseTools/Bin/Win32/GenFw.exe index 5295d76d9c..6e509a87f4 100755 Binary files a/BaseTools/Bin/Win32/GenFw.exe and b/BaseTools/Bin/Win32/GenFw.exe differ diff --git a/BaseTools/Bin/Win32/GenPage.exe b/BaseTools/Bin/Win32/GenPage.exe index 24ba6770ac..a2a70f3454 100755 Binary files a/BaseTools/Bin/Win32/GenPage.exe and b/BaseTools/Bin/Win32/GenPage.exe differ diff --git a/BaseTools/Bin/Win32/GenPatchPcdTable.exe b/BaseTools/Bin/Win32/GenPatchPcdTable.exe index 82f6f56b24..7f3cb9c597 100755 Binary files a/BaseTools/Bin/Win32/GenPatchPcdTable.exe and b/BaseTools/Bin/Win32/GenPatchPcdTable.exe differ diff --git a/BaseTools/Bin/Win32/GenSec.exe b/BaseTools/Bin/Win32/GenSec.exe index 9bc9a68451..37b12443bb 100755 Binary files a/BaseTools/Bin/Win32/GenSec.exe and b/BaseTools/Bin/Win32/GenSec.exe differ diff --git a/BaseTools/Bin/Win32/GenVtf.exe b/BaseTools/Bin/Win32/GenVtf.exe index 5cf1a0a5d7..e93adbad75 100755 Binary files a/BaseTools/Bin/Win32/GenVtf.exe and b/BaseTools/Bin/Win32/GenVtf.exe differ diff --git a/BaseTools/Bin/Win32/LzmaCompress.exe b/BaseTools/Bin/Win32/LzmaCompress.exe index fc9db77b8e..62b472cb5a 100755 Binary files a/BaseTools/Bin/Win32/LzmaCompress.exe and b/BaseTools/Bin/Win32/LzmaCompress.exe differ diff --git a/BaseTools/Bin/Win32/MigrationMsa2Inf.exe b/BaseTools/Bin/Win32/MigrationMsa2Inf.exe index 78864940bb..e133108645 100755 Binary files a/BaseTools/Bin/Win32/MigrationMsa2Inf.exe and b/BaseTools/Bin/Win32/MigrationMsa2Inf.exe differ diff --git a/BaseTools/Bin/Win32/PatchPcdValue.exe b/BaseTools/Bin/Win32/PatchPcdValue.exe index 2cbd95fc63..339740a31f 100755 Binary files a/BaseTools/Bin/Win32/PatchPcdValue.exe and b/BaseTools/Bin/Win32/PatchPcdValue.exe differ diff --git a/BaseTools/Bin/Win32/Spd2Dec.exe b/BaseTools/Bin/Win32/Spd2Dec.exe index 59b28174c6..ab96d5a90a 100755 Binary files a/BaseTools/Bin/Win32/Spd2Dec.exe and b/BaseTools/Bin/Win32/Spd2Dec.exe differ diff --git a/BaseTools/Bin/Win32/Split.exe b/BaseTools/Bin/Win32/Split.exe index 8bd2ebc48a..9c1b0f6764 100755 Binary files a/BaseTools/Bin/Win32/Split.exe and b/BaseTools/Bin/Win32/Split.exe differ diff --git a/BaseTools/Bin/Win32/TargetTool.exe b/BaseTools/Bin/Win32/TargetTool.exe index 776feb5881..59f83aa3f1 100755 Binary files a/BaseTools/Bin/Win32/TargetTool.exe and b/BaseTools/Bin/Win32/TargetTool.exe differ diff --git a/BaseTools/Bin/Win32/TianoCompress.exe b/BaseTools/Bin/Win32/TianoCompress.exe index 66b559b58d..1a718ecf57 100755 Binary files a/BaseTools/Bin/Win32/TianoCompress.exe and b/BaseTools/Bin/Win32/TianoCompress.exe differ diff --git a/BaseTools/Bin/Win32/Trim.exe b/BaseTools/Bin/Win32/Trim.exe index 36e1e7ac61..71e8e352d0 100755 Binary files a/BaseTools/Bin/Win32/Trim.exe and b/BaseTools/Bin/Win32/Trim.exe differ diff --git a/BaseTools/Bin/Win32/UPT.exe b/BaseTools/Bin/Win32/UPT.exe index da4da6f8e1..ac13bfe6bb 100644 Binary files a/BaseTools/Bin/Win32/UPT.exe and b/BaseTools/Bin/Win32/UPT.exe differ diff --git a/BaseTools/Bin/Win32/VfrCompile.exe b/BaseTools/Bin/Win32/VfrCompile.exe index a5c25b554b..0b1c7bdaca 100755 Binary files a/BaseTools/Bin/Win32/VfrCompile.exe and b/BaseTools/Bin/Win32/VfrCompile.exe differ diff --git a/BaseTools/Bin/Win32/VolInfo.exe b/BaseTools/Bin/Win32/VolInfo.exe index 4dc1693ff3..0436a0c815 100755 Binary files a/BaseTools/Bin/Win32/VolInfo.exe and b/BaseTools/Bin/Win32/VolInfo.exe differ diff --git a/BaseTools/Bin/Win32/build.exe b/BaseTools/Bin/Win32/build.exe index 88069448c4..ef96aea362 100755 Binary files a/BaseTools/Bin/Win32/build.exe and b/BaseTools/Bin/Win32/build.exe differ diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template index 652c9f3ee7..257f732cd0 100644 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -129,7 +129,7 @@ "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src} "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst} - + "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src} @@ -195,10 +195,8 @@ $(DEBUG_DIR)(+)${s_dir}(+)${s_base}.c - -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1 - "$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i - -$(MD) ${d_path} > NUL 2>&1 - "$(VFR)" $(VFR_FLAGS) --string-db $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i + "$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_base}.i + "$(VFR)" $(VFR_FLAGS) --string-db $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_base}.i [Object-File] @@ -217,7 +215,7 @@ "$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST) - + # $(OBJECT_FILES_LIST) has wrong paths for cygwin "$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES) @@ -241,7 +239,7 @@ "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS) "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst} - + "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -\) $(DLINK2_FLAGS) @@ -271,7 +269,7 @@ "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS) - + "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -\) $(DLINK2_FLAGS) @@ -292,7 +290,7 @@ $(DEBUG_DIR)(+)$(MODULE_NAME).efi - + "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS) $(CP) ${dst} $(OUTPUT_DIR) $(CP) ${dst} $(BIN_DIR) @@ -513,9 +511,7 @@ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.hpk - -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1 "$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i - -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1 "$(VFR)" $(VFR_FLAGS) --create-ifr-package --string-db $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory $(OUTPUT_DIR)(+)${s_dir} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i [Hii-Binary-Package.UEFI_HII] @@ -536,7 +532,7 @@ "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS) "$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst} - + GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index 5b9cff464e..ee7e23eee8 100644 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -134,6 +134,9 @@ DEFINE GCC44_X64_PREFIX = /usr/bin/ DEFINE GCC45_IA32_PREFIX = /usr/bin/ DEFINE GCC45_X64_PREFIX = /usr/bin/ +DEFINE GCC46_IA32_PREFIX = /usr/bin/ +DEFINE GCC46_X64_PREFIX = /usr/bin/ + DEFINE UNIX_IASL_BIN = /usr/bin/iasl #DEFINE UNIX_IASL_BIN = $(HOME)/programs/iasl DEFINE WIN_ASL_BIN_DIR = C:\ASL @@ -243,6 +246,18 @@ DEFINE CLANG_BIN = /usr/bin/ # Required to build platforms or ACPI tables: # Intel(r) ACPI Compiler v20101013 from # http://www.acpica.org/downloads/previous_releases.php +# GCC45 -Linux- Requires: +# GCC 4.5 (Native) +# Optional: +# Required to build platforms or ACPI tables: +# Intel(r) ACPI Compiler v20101013 from +# http://www.acpica.org/downloads/previous_releases.php +# GCC46 -Linux- Requires: +# GCC 4.6 (Native) +# Optional: +# Required to build platforms or ACPI tables: +# Intel(r) ACPI Compiler v20101013 from +# http://www.acpica.org/downloads/previous_releases.php # ELFGCC -Linux- Requires: # GCC(this tool chain uses whatever version of gcc and binutils that is installed in /usr/bin) # Optional: @@ -467,6 +482,7 @@ DEFINE CLANG_BIN = /usr/bin/ # MSFT - Microsoft # GCC - GNU GCC # INTEL - INTEL +# RVCT - ARM RealView Toolchain #################################################################################### #################################################################################### # @@ -2011,6 +2027,14 @@ DEFINE GCC45_IA32_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_FLAGS) DEFINE GCC45_X64_DLINK_FLAGS = DEF(GCC44_X64_DLINK_FLAGS) DEFINE GCC45_ASM_FLAGS = DEF(GCC44_ASM_FLAGS) +DEFINE GCC46_IA32_CC_FLAGS = DEF(GCC45_IA32_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable +DEFINE GCC46_X64_CC_FLAGS = DEF(GCC45_X64_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable +DEFINE GCC46_IA32_X64_DLINK_COMMON = DEF(GCC45_IA32_X64_DLINK_COMMON) +DEFINE GCC46_IA32_X64_ASLDLINK_FLAGS = DEF(GCC45_IA32_X64_ASLDLINK_FLAGS) +DEFINE GCC46_IA32_X64_DLINK_FLAGS = DEF(GCC45_IA32_X64_DLINK_FLAGS) +DEFINE GCC46_X64_DLINK_FLAGS = DEF(GCC45_X64_DLINK_FLAGS) +DEFINE GCC46_ASM_FLAGS = DEF(GCC45_ASM_FLAGS) + #################################################################################### # # Unix GCC And Intel Linux ACPI Compiler @@ -2227,6 +2251,71 @@ DEFINE GCC45_ASM_FLAGS = DEF(GCC44_ASM_FLAGS) *_GCC45_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS) *_GCC45_X64_OBJCOPY_FLAGS = +#################################################################################### +# +# GCC 4.6 - This configuration is used to compile under Linux to produce +# PE/COFF binaries using GCC 4.6. +# +#################################################################################### +*_GCC46_*_*_FAMILY = GCC + +*_GCC46_*_MAKE_PATH = make +*_GCC46_*_ASL_PATH = DEF(UNIX_IASL_BIN) + +*_GCC46_*_PP_FLAGS = DEF(GCC_PP_FLAGS) +*_GCC46_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) +*_GCC46_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) +*_GCC46_*_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) +*_GCC46_*_APP_FLAGS = +*_GCC46_*_ASL_FLAGS = DEF(IASL_FLAGS) +*_GCC46_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS) + +################## +# GCC46 IA32 definitions +################## +*_GCC46_IA32_OBJCOPY_PATH = DEF(GCC46_IA32_PREFIX)objcopy +*_GCC46_IA32_CC_PATH = DEF(GCC46_IA32_PREFIX)gcc +*_GCC46_IA32_SLINK_PATH = DEF(GCC46_IA32_PREFIX)ar +*_GCC46_IA32_DLINK_PATH = DEF(GCC46_IA32_PREFIX)ld +*_GCC46_IA32_ASLDLINK_PATH = DEF(GCC46_IA32_PREFIX)ld +*_GCC46_IA32_ASM_PATH = DEF(GCC46_IA32_PREFIX)gcc +*_GCC46_IA32_PP_PATH = DEF(GCC46_IA32_PREFIX)gcc +*_GCC46_IA32_VFRPP_PATH = DEF(GCC46_IA32_PREFIX)gcc +*_GCC46_IA32_ASLCC_PATH = DEF(GCC46_IA32_PREFIX)gcc +*_GCC46_IA32_ASLPP_PATH = DEF(GCC46_IA32_PREFIX)gcc +*_GCC46_IA32_RC_PATH = DEF(GCC46_IA32_PREFIX)objcopy + +*_GCC46_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 +*_GCC46_IA32_ASLDLINK_FLAGS = DEF(GCC46_IA32_X64_ASLDLINK_FLAGS) -m elf_i386 +*_GCC46_IA32_ASM_FLAGS = DEF(GCC46_ASM_FLAGS) -m32 -march=i386 +*_GCC46_IA32_CC_FLAGS = DEF(GCC46_IA32_CC_FLAGS) -Os +*_GCC46_IA32_DLINK_FLAGS = DEF(GCC46_IA32_X64_DLINK_FLAGS) -m elf_i386 --oformat=elf32-i386 +*_GCC46_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS) +*_GCC46_IA32_OBJCOPY_FLAGS = + +################## +# GCC46 X64 definitions +################## +*_GCC46_X64_OBJCOPY_PATH = DEF(GCC46_X64_PREFIX)objcopy +*_GCC46_X64_CC_PATH = DEF(GCC46_X64_PREFIX)gcc +*_GCC46_X64_SLINK_PATH = DEF(GCC46_X64_PREFIX)ar +*_GCC46_X64_DLINK_PATH = DEF(GCC46_X64_PREFIX)ld +*_GCC46_X64_ASLDLINK_PATH = DEF(GCC46_X64_PREFIX)ld +*_GCC46_X64_ASM_PATH = DEF(GCC46_X64_PREFIX)gcc +*_GCC46_X64_PP_PATH = DEF(GCC46_X64_PREFIX)gcc +*_GCC46_X64_VFRPP_PATH = DEF(GCC46_X64_PREFIX)gcc +*_GCC46_X64_ASLCC_PATH = DEF(GCC46_X64_PREFIX)gcc +*_GCC46_X64_ASLPP_PATH = DEF(GCC46_X64_PREFIX)gcc +*_GCC46_X64_RC_PATH = DEF(GCC46_X64_PREFIX)objcopy + +*_GCC46_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 +*_GCC46_X64_ASLDLINK_FLAGS = DEF(GCC46_IA32_X64_ASLDLINK_FLAGS) -m elf_x86_64 +*_GCC46_X64_ASM_FLAGS = DEF(GCC46_ASM_FLAGS) -m64 -melf_x86_64 +*_GCC46_X64_CC_FLAGS = DEF(GCC46_X64_CC_FLAGS) +*_GCC46_X64_DLINK_FLAGS = DEF(GCC46_X64_DLINK_FLAGS) +*_GCC46_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS) +*_GCC46_X64_OBJCOPY_FLAGS = + #################################################################################### # # Cygwin GCC And Intel ACPI Compiler @@ -4173,11 +4262,69 @@ RELEASE_ARMGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -mlittle-end *_ARMGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h *_ARMGCC_ARM_SLINK_FLAGS = -rc -*_ARMGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map +*_ARMGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -Ttext=0x0 --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEBUG_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -combine -O0 RELEASE_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -combine -Wno-unused +#################################################################################### +# +# ARM GNU/Linux GCC +# +#################################################################################### +# ARMLINUXGCC - ARM version of the GCC cross compiler + +*_ARMLINUXGCC_*_*_FAMILY = GCC +*_ARMLINUXGCC_*_*_BUILDRULEFAMILY = ARMLINUXGCC + +*_ARMLINUXGCC_*_MAKE_PATH = make +*_ARMLINUXGCC_*_MAKE_FLAGS = --no-print-directory + +################## +# ASL definitions +################## +*_ARMLINUXGCC_*_ASL_PATH = DEF(UNIX_IASL_BIN) +*_ARMLINUXGCC_*_ASL_FLAGS = DEF(IASL_FLAGS) +*_ARMLINUXGCC_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS) +*_ARMLINUXGCC_*_ASLPP_FLAGS = -x c -E -P +*_ARMLINUXGCC_*_ASLCC_FLAGS = -x c +*_ARMLINUXGCC_*_ASLDLINK_FLAGS = DEF(GCC_DLINK_FLAGS_COMMON) --entry _ReferenceAcpiTable + +################## +# ARM definitions +################## + +*_ARMLINUXGCC_ARM_ASLCC_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc +*_ARMLINUXGCC_ARM_ASLDLINK_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-ld +*_ARMLINUXGCC_ARM_ASLPP_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc + +*_ARMLINUXGCC_ARM_CC_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc +*_ARMLINUXGCC_ARM_SLINK_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-ar +*_ARMLINUXGCC_ARM_DLINK_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-ld +*_ARMLINUXGCC_ARM_ASM_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-as +*_ARMLINUXGCC_ARM_PP_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc +*_ARMLINUXGCC_ARM_VFRPP_PATH = ENV(ARMLINUXGCC_TOOLS_PATH)arm-linux-gnueabi-gcc + +# +# Use default values, or override in DSC file +# +*_ARMLINUXGCC_ARM_ARCHCC_FLAGS = -mthumb +*_ARMLINUXGCC_ARM_ARCHASM_FLAGS = +*_ARMLINUXGCC_ARM_ARCHDLINK_FLAGS = +*_ARMLINUXGCC_ARM_PLATFORM_FLAGS = -march=armv7-a + + DEBUG_ARMLINUXGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -mlittle-endian -g +RELEASE_ARMLINUXGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -mlittle-endian + +*_ARMLINUXGCC_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h +*_ARMLINUXGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h + +*_ARMLINUXGCC_ARM_SLINK_FLAGS = -rc +*_ARMLINUXGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map + + DEBUG_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -O0 +RELEASE_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable + ################# # ASM 16 linker defintions ################# diff --git a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c index c8586b4078..92060e2ca1 100644 --- a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c +++ b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c @@ -553,7 +553,7 @@ Returns: EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv; EFI_FFS_FILE_HEADER *fhdr = NULL; - EFI_FVB_ATTRIBUTES FvbAttributes; + EFI_FVB_ATTRIBUTES_2 FvbAttributes; UINTN offset; UINTN fsize; UINTN newSize; @@ -869,7 +869,7 @@ Returns: EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv; EFI_FFS_FILE_HEADER *fhdr = NULL; - EFI_FVB_ATTRIBUTES FvbAttributes; + EFI_FVB_ATTRIBUTES_2 FvbAttributes; UINTN fsize; EFI_STATUS Status; diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c index 45a2c8022d..684933f64d 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -84,7 +84,7 @@ CHAR8 *mFvbAlignmentName[] = { EFI_FVB2_ALIGNMENT_64K_STRING, EFI_FVB2_ALIGNMENT_128K_STRING, EFI_FVB2_ALIGNMENT_256K_STRING, - EFI_FVB2_ALIGNMNET_512K_STRING, + EFI_FVB2_ALIGNMENT_512K_STRING, EFI_FVB2_ALIGNMENT_1M_STRING, EFI_FVB2_ALIGNMENT_2M_STRING, EFI_FVB2_ALIGNMENT_4M_STRING, @@ -1535,7 +1535,7 @@ Returns: // Status = FindApResetVectorPosition (FvImage, &BytePointer); if (EFI_ERROR (Status)) { - Error (NULL, 0, 3000, "Invalid", "Cannot find the appropriate location in FvImage to add Ap reset vector!"); + Error (NULL, 0, 3000, "Invalid", "FV image does not have enough space to place AP reset vector. The FV image needs to reserve at least 4KB of unused space."); return EFI_ABORTED; } } diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.h b/BaseTools/Source/C/GenFv/GenFvInternalLib.h index 2629b9aee8..40c23600ab 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.h +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.h @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2011, 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 @@ -130,7 +130,7 @@ Abstract: #define EFI_FVB2_ALIGNMENT_64K_STRING "EFI_FVB2_ALIGNMENT_64K" #define EFI_FVB2_ALIGNMENT_128K_STRING "EFI_FVB2_ALIGNMENT_128K" #define EFI_FVB2_ALIGNMENT_256K_STRING "EFI_FVB2_ALIGNMENT_256K" -#define EFI_FVB2_ALIGNMNET_512K_STRING "EFI_FVB2_ALIGNMENT_512K" +#define EFI_FVB2_ALIGNMENT_512K_STRING "EFI_FVB2_ALIGNMENT_512K" #define EFI_FVB2_ALIGNMENT_1M_STRING "EFI_FVB2_ALIGNMENT_1M" #define EFI_FVB2_ALIGNMENT_2M_STRING "EFI_FVB2_ALIGNMENT_2M" #define EFI_FVB2_ALIGNMENT_4M_STRING "EFI_FVB2_ALIGNMENT_4M" @@ -226,7 +226,7 @@ typedef struct { BOOLEAN FvNameGuidSet; CHAR8 FvExtHeaderFile[_MAX_PATH]; UINTN Size; - EFI_FVB_ATTRIBUTES FvAttributes; + EFI_FVB_ATTRIBUTES_2 FvAttributes; CHAR8 FvName[_MAX_PATH]; EFI_FV_BLOCK_MAP_ENTRY FvBlocks[MAX_NUMBER_OF_FV_BLOCKS]; CHAR8 FvFiles[MAX_NUMBER_OF_FILES_IN_FV][_MAX_PATH]; diff --git a/BaseTools/Source/C/Include/Common/BuildVersion.h b/BaseTools/Source/C/Include/Common/BuildVersion.h index f19e9007d9..bbcd09a918 100644 --- a/BaseTools/Source/C/Include/Common/BuildVersion.h +++ b/BaseTools/Source/C/Include/Common/BuildVersion.h @@ -1,3 +1,3 @@ //This file is for build version number auto generation // -#define __BUILD_VERSION "Build 2396" +#define __BUILD_VERSION "Build 2423" diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h b/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h index fde381537f..0c8e29e1ce 100644 --- a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h +++ b/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h @@ -1,7 +1,7 @@ /** @file The firmware volume related definitions in PI. - Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2011, 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 @@ -14,7 +14,7 @@ File Name: PiFirmwareVolume.h @par Revision Reference: - Version 1.0. + Version 1.2C **/ @@ -33,7 +33,7 @@ typedef UINT32 EFI_FV_FILE_ATTRIBUTES; #define EFI_FV_FILE_ATTRIB_FIXED 0x00000100 #define EFI_FV_FILE_ATTRIB_MEMORY_MAPPED 0x00000200 -typedef UINT32 EFI_FVB_ATTRIBUTES; +typedef UINT32 EFI_FVB_ATTRIBUTES_2; // // Attributes bit definitions @@ -73,7 +73,7 @@ typedef UINT32 EFI_FVB_ATTRIBUTES; #define EFI_FVB2_ALIGNMENT_64K 0x00100000 #define EFI_FVB2_ALIGNMENT_128K 0x00110000 #define EFI_FVB2_ALIGNMENT_256K 0x00120000 -#define EFI_FVB2_ALIGNMNET_512K 0x00130000 +#define EFI_FVB2_ALIGNMENT_512K 0x00130000 #define EFI_FVB2_ALIGNMENT_1M 0x00140000 #define EFI_FVB2_ALIGNMENT_2M 0x00150000 #define EFI_FVB2_ALIGNMENT_4M 0x00160000 @@ -101,7 +101,7 @@ typedef struct { EFI_GUID FileSystemGuid; UINT64 FvLength; UINT32 Signature; - EFI_FVB_ATTRIBUTES Attributes; + EFI_FVB_ATTRIBUTES_2 Attributes; UINT16 HeaderLength; UINT16 Checksum; UINT16 ExtHeaderOffset; @@ -139,8 +139,20 @@ typedef struct { // Array of GUIDs. // Each GUID represents an OEM file type. // - EFI_GUID Types[1]; + // EFI_GUID Types[1]; + // } EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE; +#define EFI_FV_EXT_TYPE_GUID_TYPE 0x0002 +typedef struct { + EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr; + EFI_GUID FormatType; + + // + // An arry of bytes of length Length. + // + // UINT8 Data[1]; + // +} EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE; #endif diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp index 94ad55b1bb..b4f9d8fd7f 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp @@ -670,6 +670,25 @@ CFormPkg::DeclarePendingQuestion ( Info.mVarType = EFI_IFR_TYPE_NUM_SIZE_8; } CNObj.SetFlags (0, Info.mVarType); + // + // Use maximum value not to limit the vaild value for the undefined question. + // + switch (Info.mVarType) { + case EFI_IFR_TYPE_NUM_SIZE_64: + CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0); + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0); + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0); + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0); + break; + default: + break; + } // // For undefined Efi VarStore type question diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index f27f05b689..d55a80672b 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -1989,6 +1989,7 @@ vfrStatementDate : Prompt "=" "STRING_TOKEN" "\(" DP:Number "\)" "," Help "=" "STRING_TOKEN" "\(" DH:Number "\)" "," minMaxDateStepDefault[Val.date, 2] + { G:FLAGS "=" vfrDateFlags[DObj, G->getLine()] "," } << mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId); DObj.SetQuestionId (QId); @@ -2449,6 +2450,7 @@ vfrStatementTime : Prompt "=" "STRING_TOKEN" "\(" SP:Number "\)" "," Help "=" "STRING_TOKEN" "\(" SH:Number "\)" "," minMaxTimeStepDefault[Val.time, 2] + { G:FLAGS "=" vfrTimeFlags[TObj, G->getLine()] "," } << mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId); TObj.SetQuestionId (QId); @@ -3216,7 +3218,7 @@ vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] : | ideqvalExp[$RootLevel, $ExpOpCount] | ideqidExp[$RootLevel, $ExpOpCount] | ideqvallistExp[$RootLevel, $ExpOpCount] - | questionref13Exp[$RootLevel, $ExpOpCount] + | questionref1Exp[$RootLevel, $ExpOpCount] | rulerefExp[$RootLevel, $ExpOpCount] | stringref1Exp[$RootLevel, $ExpOpCount] | pushthisExp[$RootLevel, $ExpOpCount] @@ -3451,50 +3453,26 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : >> ; -questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] : +questionref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << - UINT8 Type = 0x1; - EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID; - EFI_GUID Guid = {0,}; EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID; UINT32 BitMask; CHAR8 *QName = NULL; UINT32 LineNo = 0; >> L:QuestionRef - ( - ( - << Type = 0x3; >> - { - Path "=" "STRING_TOKEN" "\(" S:Number "\)" << Type = 0x4; DevPath = _STOSID(S->getText()); >> - } - { - Uuid "=" guidDefinition[Guid] << Type = 0x5; >> - } - ) - | - ( - "\(" - ( + "\(" + ( QN:StringIdentifier << QName = QN->getText(); - LineNo = QN->getLine(); + LineNo = QN->getLine(); mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask); >> | ID:Number << QId = _STOQID(ID->getText()); >> ) - "\)" - ) - ) + "\)" << - switch (Type) { - case 0x1: {CIfrQuestionRef1 QR1Obj(L->getLine()); _SAVE_OPHDR_COND (QR1Obj, ($ExpOpCount == 0), L->getLine()); QR1Obj.SetQuestionId (QId, QName, LineNo); break;} - case 0x3: {CIfrQuestionRef3 QR3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3Obj, ($ExpOpCount == 0), L->getLine()); break;} - case 0x4: {CIfrQuestionRef3_2 QR3_2Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_2Obj, ($ExpOpCount == 0), L->getLine()); QR3_2Obj.SetDevicePath (DevPath); break;} - case 0x5: {CIfrQuestionRef3_3 QR3_3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_3Obj, ($ExpOpCount == 0), L->getLine()); QR3_3Obj.SetDevicePath (DevPath); QR3_3Obj.SetGuid (&Guid); break;} - } - $ExpOpCount++; - >> + { CIfrQuestionRef1 QR1Obj(L->getLine()); _SAVE_OPHDR_COND (QR1Obj, ($ExpOpCount == 0), L->getLine()); QR1Obj.SetQuestionId (QId, QName, LineNo); } $ExpOpCount++; >> ; rulerefExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : @@ -3626,7 +3604,7 @@ vfrExpressionConstant[UINT32 & RootLevel, UINT32 & ExpOpCount] : vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] : lengthExp[$RootLevel, $ExpOpCount] | bitwisenotExp[$RootLevel, $ExpOpCount] - | question2refExp[$RootLevel, $ExpOpCount] + | question23refExp[$RootLevel, $ExpOpCount] | stringref2Exp[$RootLevel, $ExpOpCount] | toboolExp[$RootLevel, $ExpOpCount] | tostringExp[$RootLevel, $ExpOpCount] @@ -3648,10 +3626,30 @@ bitwisenotExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << { CIfrBitWiseNot BWNObj(L->getLine()); $ExpOpCount++; } >> ; -question2refExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : +question23refExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : + << + UINT8 Type = 0x1; + EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID; + EFI_GUID Guid = {0,}; + >> L:QuestionRefVal - "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)" - << { CIfrQuestionRef2 QR2Obj(L->getLine()); $ExpOpCount++; } >> + "\(" + { + DevicePath "=" "STRING_TOKEN" "\(" S:Number "\)" "," << Type = 0x2; DevPath = _STOSID(S->getText()); >> + } + { + Uuid "=" guidDefinition[Guid] "," << Type = 0x3; >> + } + vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] + "\)" + << + switch (Type) { + case 0x1: {CIfrQuestionRef2 QR2Obj(L->getLine()); _SAVE_OPHDR_COND (QR2Obj, ($ExpOpCount == 0), L->getLine()); break;} + case 0x2: {CIfrQuestionRef3_2 QR3_2Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_2Obj, ($ExpOpCount == 0), L->getLine()); QR3_2Obj.SetDevicePath (DevPath); break;} + case 0x3: {CIfrQuestionRef3_3 QR3_3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_3Obj, ($ExpOpCount == 0), L->getLine()); QR3_3Obj.SetDevicePath (DevPath); QR3_3Obj.SetGuid (&Guid); break;} + } + $ExpOpCount++; + >> ; stringref2Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] : diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c index f514ba8c38..7d127e1691 100644 --- a/BaseTools/Source/C/VolInfo/VolInfo.c +++ b/BaseTools/Source/C/VolInfo/VolInfo.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2011, 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 @@ -845,8 +845,8 @@ Returns: printf (" EFI_FVB2_ALIGNMENT_256K\n"); } - if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMNET_512K) { - printf (" EFI_FVB2_ALIGNMNET_512K\n"); + if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_512K) { + printf (" EFI_FVB2_ALIGNMENT_512K\n"); } if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_1M) { diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 561114d141..5638bfd043 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -310,11 +310,14 @@ gAutoGenHPrologueString = TemplateString(""" #ifndef _${File}_${Guid} #define _${File}_${Guid} +""") + +gAutoGenHCppPrologueString = """ #ifdef __cplusplus extern "C" { #endif -""") +""" gAutoGenHEpilogueString = """ @@ -1970,6 +1973,7 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH): AutoGenH.Append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.h'})) # header file Prologue AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-','_')})) + AutoGenH.Append(gAutoGenHCppPrologueString) if Info.AutoGenVersion >= 0x00010005: # header files includes AutoGenH.Append("#include <%s>\n" % gBasicHeaderFile) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index b34977d7a9..b2ebff324d 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -31,6 +31,8 @@ gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n ## Regular expression for matching macro used in header file inclusion gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE) +gIsFileMap = {} + ## pattern for include style in Edk.x code gProtocolDefinition = "Protocol/%(HeaderKey)s/%(HeaderKey)s.h" gGuidDefinition = "Guid/%(HeaderKey)s/%(HeaderKey)s.h" @@ -421,6 +423,7 @@ cleanlib: self.FileListMacros = {} self.ListFileMacros = {} + self.FileCache = {} self.FileDependency = [] self.LibraryBuildCommandList = [] self.LibraryFileList = [] @@ -722,24 +725,26 @@ cleanlib: EdkLogger.debug(EdkLogger.DEBUG_1, "Try to get dependency files for %s" % File) FileStack = [File] + ForceList DependencySet = set() - MacroUsedByIncludedFile = False if self._AutoGenObject.Arch not in gDependencyDatabase: gDependencyDatabase[self._AutoGenObject.Arch] = {} DepDb = gDependencyDatabase[self._AutoGenObject.Arch] - # add path of given source file into search path list. - if File.Dir not in SearchPathList: - SearchPathList.append(File.Dir) while len(FileStack) > 0: F = FileStack.pop() + FullPathDependList = [] + if F in self.FileCache: + for CacheFile in self.FileCache[F]: + FullPathDependList.append(CacheFile) + if CacheFile not in DependencySet: + FileStack.append(CacheFile) + DependencySet.update(FullPathDependList) + continue + CurrentFileDependencyList = [] if F in DepDb: CurrentFileDependencyList = DepDb[F] - for Dep in CurrentFileDependencyList: - if Dep not in FileStack and Dep not in DependencySet: - FileStack.append(Dep) else: try: Fd = open(F.Path, 'r') @@ -755,7 +760,6 @@ cleanlib: FileContent = unicode(FileContent, "utf-16") IncludedFileList = gIncludePattern.findall(FileContent) - CurrentFilePath = F.Dir for Inc in IncludedFileList: Inc = Inc.strip() # if there's macro used to reference header file, expand it @@ -766,41 +770,44 @@ cleanlib: if HeaderType in gIncludeMacroConversion: Inc = gIncludeMacroConversion[HeaderType] % {"HeaderKey" : HeaderKey} else: - # not known macro used in #include - MacroUsedByIncludedFile = True - continue + # not known macro used in #include, always build the file by + # returning a empty dependency + self.FileCache[File] = [] + return [] Inc = os.path.normpath(Inc) - for SearchPath in [CurrentFilePath] + SearchPathList: - FilePath = os.path.join(SearchPath, Inc) - if not os.path.isfile(FilePath) or FilePath in CurrentFileDependencyList: + CurrentFileDependencyList.append(Inc) + DepDb[F] = CurrentFileDependencyList + + CurrentFilePath = F.Dir + PathList = [CurrentFilePath] + SearchPathList + for Inc in CurrentFileDependencyList: + for SearchPath in PathList: + FilePath = os.path.join(SearchPath, Inc) + if FilePath in gIsFileMap: + if not gIsFileMap[FilePath]: continue - FilePath = PathClass(FilePath) - CurrentFileDependencyList.append(FilePath) - if FilePath not in FileStack and FilePath not in DependencySet: - FileStack.append(FilePath) - break + # If isfile is called too many times, the performance is slow down. + elif not os.path.isfile(FilePath): + gIsFileMap[FilePath] = False + continue else: - EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\ - "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList))) - - if not MacroUsedByIncludedFile: - if F == File: - CurrentFileDependencyList += ForceList - # - # Don't keep the file in cache if it uses macro in included file. - # So it will be scanned again if another file includes this file. - # - DepDb[F] = CurrentFileDependencyList - DependencySet.update(CurrentFileDependencyList) + gIsFileMap[FilePath] = True + FilePath = PathClass(FilePath) + FullPathDependList.append(FilePath) + if FilePath not in DependencySet: + FileStack.append(FilePath) + break + else: + EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\ + "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList))) - # - # If there's macro used in included file, always build the file by - # returning a empty dependency - # - if MacroUsedByIncludedFile: - DependencyList = [] - else: - DependencyList = list(DependencySet) # remove duplicate ones + self.FileCache[F] = FullPathDependList + DependencySet.update(FullPathDependList) + + DependencySet.update(ForceList) + if File in DependencySet: + DependencySet.remove(File) + DependencyList = list(DependencySet) # remove duplicate ones return DependencyList @@ -1314,16 +1321,16 @@ ${END}\t@cd $(BUILD_DIR)\n # macros passed to GenFds MacroList.append('"%s=%s"' % ("EFI_SOURCE", GlobalData.gEfiSource.replace('\\', '\\\\'))) MacroList.append('"%s=%s"' % ("EDK_SOURCE", GlobalData.gEdkSource.replace('\\', '\\\\'))) - for MacroName in GlobalData.gGlobalDefines: - if GlobalData.gGlobalDefines[MacroName] != "": - MacroList.append('"%s=%s"' % (MacroName, GlobalData.gGlobalDefines[MacroName].replace('\\', '\\\\'))) + MacroDict = {} + MacroDict.update(GlobalData.gGlobalDefines) + MacroDict.update(GlobalData.gCommandLineDefines) + MacroDict.pop("EFI_SOURCE", "dummy") + MacroDict.pop("EDK_SOURCE", "dummy") + for MacroName in MacroDict: + if MacroDict[MacroName] != "": + MacroList.append('"%s=%s"' % (MacroName, MacroDict[MacroName].replace('\\', '\\\\'))) else: MacroList.append('"%s"' % MacroName) - for MacroName in GlobalData.gCommandLineDefines: - if GlobalData.gCommandLineDefines[MacroName] != "": - MacroList.append('"%s=%s"' % (MacroName, GlobalData.gCommandLineDefines[MacroName].replace('\\', '\\\\'))) - else: - MacroList.append('"%s"' % MacroName) else: FdfFileList = [] diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index 7187f0a440..b84d9f90aa 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -62,7 +62,7 @@ OFFSET = 'offset' STRING = 'string' TO = 'to' STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) -COMPATIBLE_STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Za-z0-9_]+) *\)', re.MULTILINE | re.UNICODE) +COMPATIBLE_STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) EFI_HII_ARRAY_SIZE_LENGTH = 4 EFI_HII_PACKAGE_HEADER_LENGTH = 4 diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 54751bab4e..ea27607fce 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -260,7 +260,7 @@ class UniFileClassObject(object): Name = Item.split()[1] # Check the string name is the upper character - if not self.IsCompatibleMode and Name != '': + if Name != '': MatchString = re.match('[A-Z0-9_]+', Name, re.UNICODE) if MatchString == None or MatchString.end(0) != len(Name): EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid lower case character.' %(Name, self.File)) diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py index 97c1094205..4bb9a8b521 100644 --- a/BaseTools/Source/Python/Common/BuildVersion.py +++ b/BaseTools/Source/Python/Common/BuildVersion.py @@ -1,3 +1,3 @@ #This file is for build version number auto generation # -gBUILD_VERSION = "Build 2396" +gBUILD_VERSION = "Build 2423" diff --git a/BaseTools/Source/Python/Common/DecClassObjectLight.py b/BaseTools/Source/Python/Common/DecClassObjectLight.py deleted file mode 100644 index 7fb41a2359..0000000000 --- a/BaseTools/Source/Python/Common/DecClassObjectLight.py +++ /dev/null @@ -1,580 +0,0 @@ -## @file -# This file is used to define each component of DEC file in light mode -# -# Copyright (c) 2008, 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. -# - -## -# Import Modules -# -import os -from Misc import GetFiles -from String import * -from DataType import * -from CommonDataClass.PackageClass import * -from CommonDataClass import CommonClass -from BuildToolError import * -from Parsing import * - -# Global variable -Section = {TAB_UNKNOWN.upper() : MODEL_UNKNOWN, - TAB_DEC_DEFINES.upper() : MODEL_META_DATA_HEADER, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS, - TAB_COMPONENTS.upper() : MODEL_META_DATA_COMPONENT, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT_BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABLE_IN_MODULE, - TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_FLAG, - TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_EX, - TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION - } - -## DecObject -# -# This class defined basic Dec object which is used by inheriting -# -# @param object: Inherited from object class -# -class DecObject(object): - def __init__(self): - object.__init__() - -## Dec -# -# This class defined the structure used in Dec object -# -# @param DecObject: Inherited from DecObject class -# @param Filename: Input value for Filename of Dec file, default is None -# @param IsMergeAllArches: Input value for IsMergeAllArches -# True is to merge all arches -# Fales is not to merge all arches -# default is False -# @param IsToPackage: Input value for IsToPackage -# True is to transfer to PackageObject automatically -# False is not to transfer to PackageObject automatically -# default is False -# @param WorkspaceDir: Input value for current workspace directory, default is None -# -# @var Identification: To store value for Identification, it is a structure as Identification -# @var Defines: To store value for Defines, it is a structure as DecDefines -# @var UserExtensions: To store value for UserExtensions -# @var Package: To store value for Package, it is a structure as PackageClass -# @var WorkspaceDir: To store value for WorkspaceDir -# @var Contents: To store value for Contents, it is a structure as DecContents -# @var KeyList: To store value for KeyList, a list for all Keys used in Dec -# -class Dec(DecObject): - def __init__(self, Filename=None, IsToPackage=False, WorkspaceDir=None, AllGuidVersionDict=None, SupArchList=DataType.ARCH_LIST): - self.Identification = IdentificationClass() - self.Package = PackageClass() - self.UserExtensions = '' - self.WorkspaceDir = WorkspaceDir - self.SupArchList = SupArchList - self.AllGuidVersionDict = {} - if AllGuidVersionDict: - self.AllGuidVersionDict = AllGuidVersionDict - - self.KeyList = [ - TAB_INCLUDES, TAB_GUIDS, TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, \ - TAB_PCDS_FIXED_AT_BUILD_NULL, TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL, \ - TAB_PCDS_DYNAMIC_NULL, TAB_PCDS_DYNAMIC_EX_NULL, TAB_DEC_DEFINES - ] - # Upper all KEYs to ignore case sensitive when parsing - self.KeyList = map(lambda c: c.upper(), self.KeyList) - - # Init RecordSet - self.RecordSet = {} - for Key in self.KeyList: - self.RecordSet[Section[Key]] = [] - - # Init Comment - self.SectionHeaderCommentDict = {} - - # Load Dec file if filename is not None - if Filename != None: - self.LoadDecFile(Filename) - - # Transfer to Package Object if IsToPackage is True - if IsToPackage: - self.DecToPackage() - - ## Load Dec file - # - # Load the file if it exists - # - # @param Filename: Input value for filename of Dec file - # - def LoadDecFile(self, Filename): - # Insert a record for file - Filename = NormPath(Filename) - self.Identification.FullPath = Filename - (self.Identification.RelaPath, self.Identification.FileName) = os.path.split(Filename) - if self.Identification.FullPath.find(self.WorkspaceDir) > -1: - self.Identification.PackagePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:]) - - # Init common datas - IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \ - [], [], TAB_UNKNOWN, [], [], [] - LineNo = 0 - - # Parse file content - IsFindBlockComment = False - ReservedLine = '' - Comment = '' - for Line in open(Filename, 'r'): - LineNo = LineNo + 1 - # Remove comment block - if Line.find(TAB_COMMENT_EDK_START) > -1: - ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0] - if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT): - Comment = Comment + Line.strip() + '\n' - ReservedLine = '' - else: - Comment = Comment + Line[len(ReservedLine):] + '\n' - IsFindBlockComment = True - if not ReservedLine: - continue - if Line.find(TAB_COMMENT_EDK_END) > -1: - Comment = Comment + Line[:Line.find(TAB_COMMENT_EDK_END) + len(TAB_COMMENT_EDK_END)] + '\n' - Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1] - ReservedLine = '' - IsFindBlockComment = False - if IsFindBlockComment: - Comment = Comment + Line.strip() + '\n' - continue - - # Remove comments at tail and remove spaces again - if Line.strip().startswith(TAB_COMMENT_SPLIT) or Line.strip().startswith('--/'): - Comment = Comment + Line.strip() + '\n' - Line = CleanString(Line) - if Line == '': - continue - - ## Find a new section tab - # First insert previous section items - # And then parse the content of the new section - # - if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SECTION_END): - # Insert items data of previous section - Model = Section[CurrentSection.upper()] - InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet) - # Parse the new section - SectionItemList = [] - ArchList = [] - ThirdList = [] - - CurrentSection = '' - LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) - for Item in LineList: - ItemList = GetSplitValueList(Item, TAB_SPLIT) - if CurrentSection == '': - CurrentSection = ItemList[0] - else: - if CurrentSection != ItemList[0]: - EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) - if CurrentSection.upper() not in self.KeyList: - RaiseParserError(Line, CurrentSection, Filename, '', LineNo) - ItemList.append('') - ItemList.append('') - if len(ItemList) > 5: - RaiseParserError(Line, CurrentSection, Filename, '', LineNo) - else: - if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL: - EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) - ArchList.append(ItemList[1].upper()) - ThirdList.append(ItemList[2]) - - if Comment: - if Comment.endswith('\n'): - Comment = Comment[:len(Comment) - len('\n')] - self.SectionHeaderCommentDict[Section[CurrentSection.upper()]] = Comment - Comment = '' - continue - - # Not in any defined section - if CurrentSection == TAB_UNKNOWN: - ErrorMsg = "%s is not in any defined section" % Line - EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) - - # Add a section item - SectionItemList.append([Line, LineNo, Comment]) - Comment = '' - # End of parse - #End of For - - # - # Insert items data of last section - # - Model = Section[CurrentSection.upper()] - InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet) - if Comment != '': - self.SectionHeaderCommentDict[Model] = Comment - Comment = '' - - ## Package Object to DEC file - def PackageToDec(self, Package): - Dec = '' - DecList = sdict() - SectionHeaderCommentDict = {} - if Package == None: - return Dec - - PackageHeader = Package.PackageHeader - TmpList = [] - if PackageHeader.Name: - TmpList.append(TAB_DEC_DEFINES_PACKAGE_NAME + ' = ' + PackageHeader.Name) - if PackageHeader.Guid: - TmpList.append(TAB_DEC_DEFINES_PACKAGE_GUID + ' = ' + PackageHeader.Guid) - if PackageHeader.Version: - TmpList.append(TAB_DEC_DEFINES_PACKAGE_VERSION + ' = ' + PackageHeader.Version) - if PackageHeader.DecSpecification: - TmpList.append(TAB_DEC_DEFINES_DEC_SPECIFICATION + ' = ' + PackageHeader.DecSpecification) - if Package.UserExtensions != None: - for Item in Package.UserExtensions.Defines: - TmpList.append(Item) - DecList['Defines'] = TmpList - if PackageHeader.Description != '': - SectionHeaderCommentDict['Defines'] = PackageHeader.Description - - for Item in Package.Includes: - Key = 'Includes.' + Item.SupArchList - Value = Item.FilePath - GenMetaDatSectionItem(Key, Value, DecList) - - for Item in Package.GuidDeclarations: - Key = 'Guids.' + Item.SupArchList - Value = Item.CName + '=' + Item.Guid - GenMetaDatSectionItem(Key, Value, DecList) - - for Item in Package.ProtocolDeclarations: - Key = 'Protocols.' + Item.SupArchList - Value = Item.CName + '=' + Item.Guid - GenMetaDatSectionItem(Key, Value, DecList) - - for Item in Package.PpiDeclarations: - Key = 'Ppis.' + Item.SupArchList - Value = Item.CName + '=' + Item.Guid - GenMetaDatSectionItem(Key, Value, DecList) - - for Item in Package.LibraryClassDeclarations: - Key = 'LibraryClasses.' + Item.SupArchList - Value = Item.LibraryClass + '|' + Item.RecommendedInstance - GenMetaDatSectionItem(Key, Value, DecList) - - for Item in Package.PcdDeclarations: - Key = 'Pcds' + Item.ItemType + '.' + Item.SupArchList - Value = Item.TokenSpaceGuidCName + '.' + Item.CName - if Item.DefaultValue != '': - Value = Value + '|' + Item.DefaultValue - if Item.DatumType != '': - Value = Value + '|' + Item.DatumType - if Item.Token != '': - Value = Value + '|' + Item.Token - GenMetaDatSectionItem(Key, Value, DecList) - - # Transfer Package to Inf - for Key in DecList: - if Key in SectionHeaderCommentDict: - List = SectionHeaderCommentDict[Key].split('\r') - for Item in List: - Dec = Dec + Item + '\n' - Dec = Dec + '[' + Key + ']' + '\n' - for Value in DecList[Key]: - if type(Value) == type([]): - for SubValue in Value: - Dec = Dec + ' ' + SubValue + '\n' - else: - Dec = Dec + ' ' + Value + '\n' - Dec = Dec + '\n' - - return Dec - - ## Transfer to Package Object - # - # Transfer all contents of a Dec file to a standard Package Object - # - def DecToPackage(self): - # Init global information for the file - ContainerFile = self.Identification.FullPath - - # Generate Package Header - self.GenPackageHeader(ContainerFile) - - # Generate Includes - # Only for Edk - self.GenIncludes(ContainerFile) - - # Generate Guids - self.GenGuidProtocolPpis(DataType.TAB_GUIDS, ContainerFile) - - # Generate Protocols - self.GenGuidProtocolPpis(DataType.TAB_PROTOCOLS, ContainerFile) - - # Generate Ppis - self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile) - - # Generate LibraryClasses - self.GenLibraryClasses(ContainerFile) - - # Generate Pcds - self.GenPcds(ContainerFile) - - # Init MiscFiles - self.GenMiscFiles(ContainerFile) - - ## GenMiscFiles - # - def GenMiscFiles(self, ContainerFile): - MiscFiles = MiscFileClass() - MiscFiles.Name = 'ModuleFiles' - for Item in GetFiles(os.path.dirname(ContainerFile), ['CVS', '.svn'], False): - File = CommonClass.FileClass() - File.Filename = Item - MiscFiles.Files.append(File) - self.Package.MiscFiles = MiscFiles - - ## Get Package Header - # - # Gen Package Header of Dec as = - # - # @param ContainerFile: The Dec file full path - # - def GenPackageHeader(self, ContainerFile): - EdkLogger.debug(2, "Generate PackageHeader ...") - # - # Update all defines item in database - # - RecordSet = self.RecordSet[MODEL_META_DATA_HEADER] - PackageHeader = PackageHeaderClass() - OtherDefines = [] - for Record in RecordSet: - ValueList = GetSplitValueList(Record[0], TAB_EQUAL_SPLIT) - if len(ValueList) != 2: - OtherDefines.append(Record[0]) - else: - Name = ValueList[0] - Value = ValueList[1] - if Name == TAB_DEC_DEFINES_PACKAGE_NAME: - PackageHeader.Name = Value - elif Name == TAB_DEC_DEFINES_PACKAGE_GUID: - PackageHeader.Guid = Value - elif Name == TAB_DEC_DEFINES_PACKAGE_VERSION: - PackageHeader.Version = Value - elif Name == TAB_DEC_DEFINES_DEC_SPECIFICATION: - PackageHeader.DecSpecification = Value - else: - OtherDefines.append(Record[0]) - - PackageHeader.FileName = self.Identification.FileName - PackageHeader.FullPath = self.Identification.FullPath - PackageHeader.RelaPath = self.Identification.RelaPath - PackageHeader.PackagePath = self.Identification.PackagePath - PackageHeader.ModulePath = self.Identification.ModulePath - PackageHeader.CombinePath = os.path.normpath(os.path.join(PackageHeader.PackagePath, PackageHeader.ModulePath, PackageHeader.FileName)) - - if MODEL_META_DATA_HEADER in self.SectionHeaderCommentDict: - PackageHeader.Description = self.SectionHeaderCommentDict[MODEL_META_DATA_HEADER] - - self.Package.PackageHeader = PackageHeader - UE = UserExtensionsClass() - UE.Defines = OtherDefines - self.Package.UserExtensions = UE - - - ## GenIncludes - # - # Gen Includes of Dec - # - # @param ContainerFile: The Dec file full path - # - def GenIncludes(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_INCLUDES) - Includes = {} - # Get all Includes - RecordSet = self.RecordSet[MODEL_EFI_INCLUDE] - - # Go through each arch - for Record in RecordSet: - Arch = Record[1] - Key = Record[0] - Include = IncludeClass() - Include.FilePath = NormPath(Key) - Include.SupArchList = Arch - self.Package.Includes.append(Include) - - ## GenPpis - # - # Gen Ppis of Dec - # = - # - # @param ContainerFile: The Dec file full path - # - def GenGuidProtocolPpis(self, Type, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % Type) - Lists = {} - # Get all Items - RecordSet = self.RecordSet[Section[Type.upper()]] - - # Go through each arch - for Record in RecordSet: - Arch = Record[1] - (Name, Value) = GetGuidsProtocolsPpisOfDec(Record[0], Type, ContainerFile, Record[2]) - - ListMember = None - if Type == TAB_GUIDS: - ListMember = self.Package.GuidDeclarations - elif Type == TAB_PROTOCOLS: - ListMember = self.Package.ProtocolDeclarations - elif Type == TAB_PPIS: - ListMember = self.Package.PpiDeclarations - - ListClass = GuidProtocolPpiCommonClass() - ListClass.CName = Name - ListClass.Guid = Value - ListClass.SupArchList = Arch - ListMember.append(ListClass) - - ## GenLibraryClasses - # - # Gen LibraryClasses of Dec - # = - # - # @param ContainerFile: The Dec file full path - # - def GenLibraryClasses(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES) - LibraryClasses = {} - # Get all Guids - RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS] - - # Go through each arch - for Record in RecordSet: - Arch = Record[1] - List = GetSplitValueList(Record[0], DataType.TAB_VALUE_SPLIT) - if len(List) != 2: - continue - LibraryClass = LibraryClassClass() - LibraryClass.LibraryClass = List[0] - LibraryClass.RecommendedInstance = NormPath(List[1]) - LibraryClass.SupArchList = Arch - self.Package.LibraryClassDeclarations.append(LibraryClass) - - def AddPcd(self, CName, Token, TokenSpaceGuidCName, DatumType, DefaultValue, ItemType, Arch): - Pcd = CommonClass.PcdClass() - Pcd.CName = CName - Pcd.Token = Token - Pcd.TokenSpaceGuidCName = TokenSpaceGuidCName - Pcd.DatumType = DatumType - Pcd.DefaultValue = DefaultValue - Pcd.ItemType = ItemType - Pcd.SupArchList = Arch - self.Package.PcdDeclarations.append(Pcd) - - ## GenPcds - # - # Gen Pcds of Dec - # .||| - # - # @param ContainerFile: The Dec file full path - # - def GenPcds(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_PCDS) - Pcds = {} - PcdToken = {} - # Get all Pcds - RecordSet1 = self.RecordSet[MODEL_PCD_FIXED_AT_BUILD] - RecordSet2 = self.RecordSet[MODEL_PCD_PATCHABLE_IN_MODULE] - RecordSet3 = self.RecordSet[MODEL_PCD_FEATURE_FLAG] - RecordSet4 = self.RecordSet[MODEL_PCD_DYNAMIC_EX] - RecordSet5 = self.RecordSet[MODEL_PCD_DYNAMIC] - - # Go through each pcd - for Record in RecordSet1: - Arch = Record[1] - (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_FIXED_AT_BUILD, ContainerFile, Record[2]) - self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch) - for Record in RecordSet2: - Arch = Record[1] - (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile, Record[2]) - self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch) - for Record in RecordSet3: - Arch = Record[1] - (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_FEATURE_FLAG, ContainerFile, Record[2]) - self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch) - for Record in RecordSet4: - Arch = Record[1] - (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC_EX, ContainerFile, Record[2]) - self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch) - for Record in RecordSet5: - Arch = Record[1] - (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC, ContainerFile, Record[2]) - self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch) - - ## Show detailed information of Package - # - # Print all members and their values of Package class - # - def ShowPackage(self): - M = self.Package - print 'Filename =', M.PackageHeader.FileName - print 'FullPath =', M.PackageHeader.FullPath - print 'RelaPath =', M.PackageHeader.RelaPath - print 'PackagePath =', M.PackageHeader.PackagePath - print 'ModulePath =', M.PackageHeader.ModulePath - print 'CombinePath =', M.PackageHeader.CombinePath - - print 'BaseName =', M.PackageHeader.Name - print 'Guid =', M.PackageHeader.Guid - print 'Version =', M.PackageHeader.Version - print 'DecSpecification =', M.PackageHeader.DecSpecification - - print '\nIncludes ='#, M.Includes - for Item in M.Includes: - print Item.FilePath, Item.SupArchList - print '\nGuids ='#, M.GuidDeclarations - for Item in M.GuidDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nProtocols ='#, M.ProtocolDeclarations - for Item in M.ProtocolDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nPpis ='#, M.PpiDeclarations - for Item in M.PpiDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nLibraryClasses ='#, M.LibraryClassDeclarations - for Item in M.LibraryClassDeclarations: - print Item.LibraryClass, Item.RecommendedInstance, Item.SupModuleList, Item.SupArchList - print '\nPcds ='#, M.PcdDeclarations - for Item in M.PcdDeclarations: - print 'CName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, 'Token=', Item.Token, 'DatumType=', Item.DatumType, Item.SupArchList - print '\nUserExtensions =', M.UserExtensions.Defines - print '\n*** FileList ***' - for Item in M.MiscFiles.Files: - print Item.Filename - print '****************\n' - -## -# -# This acts like the main() function for the script, unless it is 'import'ed into another -# script. -# -if __name__ == '__main__': - EdkLogger.Initialize() - EdkLogger.SetLevel(EdkLogger.QUIET) - - W = os.getenv('WORKSPACE') - F = os.path.join(W, 'MdeModulePkg/MdeModulePkg.dec') - - P = Dec(os.path.normpath(F), True, W) - P.ShowPackage() - print P.PackageToDec(P.Package) diff --git a/BaseTools/Source/Python/Common/InfClassObjectLight.py b/BaseTools/Source/Python/Common/InfClassObjectLight.py deleted file mode 100644 index 44f922340b..0000000000 --- a/BaseTools/Source/Python/Common/InfClassObjectLight.py +++ /dev/null @@ -1,877 +0,0 @@ -## @file -# This file is used to define each component of INF file -# -# Copyright (c) 2007 - 2010, 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. -# - -## -# Import Modules -# -import os -import re -import EdkLogger - -from CommonDataClass.ModuleClass import * -from CommonDataClass import CommonClass -from String import * -from DataType import * -from BuildToolError import * -from Misc import sdict -from Misc import GetFiles -from Parsing import * - -# Global variable -Section = {TAB_UNKNOWN.upper() : MODEL_UNKNOWN, - TAB_INF_DEFINES.upper() : MODEL_META_DATA_HEADER, - TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BUILD_OPTION, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_INSTANCE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS, - TAB_PACKAGES.upper() : MODEL_META_DATA_PACKAGE, - TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE, - TAB_INF_FIXED_PCD.upper() : MODEL_PCD_FIXED_AT_BUILD, - TAB_INF_PATCH_PCD.upper() : MODEL_PCD_PATCHABLE_IN_MODULE, - TAB_INF_FEATURE_PCD.upper() : MODEL_PCD_FEATURE_FLAG, - TAB_INF_PCD_EX.upper() : MODEL_PCD_DYNAMIC_EX, - TAB_INF_PCD.upper() : MODEL_PCD_DYNAMIC, - TAB_SOURCES.upper() : MODEL_EFI_SOURCE_FILE, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_DEPEX.upper() : MODEL_EFI_DEPEX, - TAB_BINARIES.upper() : MODEL_EFI_BINARY_FILE, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION - } - -gComponentType2ModuleType = { - "LIBRARY" : "BASE", - "SECURITY_CORE" : "SEC", - "PEI_CORE" : "PEI_CORE", - "COMBINED_PEIM_DRIVER" : "PEIM", - "PIC_PEIM" : "PEIM", - "RELOCATABLE_PEIM" : "PEIM", - "PE32_PEIM" : "PEIM", - "BS_DRIVER" : "DXE_DRIVER", - "RT_DRIVER" : "DXE_RUNTIME_DRIVER", - "SAL_RT_DRIVER" : "DXE_SAL_DRIVER", - "APPLICATION" : "UEFI_APPLICATION", - "LOGO" : "BASE", -} - -class InfHeader(ModuleHeaderClass): - _Mapping_ = { - # Required Fields - TAB_INF_DEFINES_BASE_NAME : "Name", - TAB_INF_DEFINES_FILE_GUID : "Guid", - TAB_INF_DEFINES_MODULE_TYPE : "ModuleType", - TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION : "UefiSpecificationVersion", - TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : "UefiSpecificationVersion", - TAB_INF_DEFINES_EDK_RELEASE_VERSION : "EdkReleaseVersion", - - # Optional Fields - TAB_INF_DEFINES_INF_VERSION : "InfVersion", - TAB_INF_DEFINES_BINARY_MODULE : "BinaryModule", - TAB_INF_DEFINES_COMPONENT_TYPE : "ComponentType", - TAB_INF_DEFINES_MAKEFILE_NAME : "MakefileName", - TAB_INF_DEFINES_BUILD_NUMBER : "BuildNumber", - TAB_INF_DEFINES_BUILD_TYPE : "BuildType", - TAB_INF_DEFINES_FFS_EXT : "FfsExt", - TAB_INF_DEFINES_FV_EXT : "FvExt", - TAB_INF_DEFINES_SOURCE_FV : "SourceFv", - TAB_INF_DEFINES_VERSION_NUMBER : "VersionNumber", - TAB_INF_DEFINES_VERSION_STRING : "VersionString", - TAB_INF_DEFINES_VERSION : "Version", - TAB_INF_DEFINES_PCD_IS_DRIVER : "PcdIsDriver", - TAB_INF_DEFINES_TIANO_EDK_FLASHMAP_H : "TianoEdkFlashMap_h", - TAB_INF_DEFINES_SHADOW : "Shadow", - } - - def __init__(self): - ModuleHeaderClass.__init__(self) - self.VersionNumber = '' - self.VersionString = '' - #print self.__dict__ - def __setitem__(self, key, value): - self.__dict__[self._Mapping_[key]] = value - def __getitem__(self, key): - return self.__dict__[self._Mapping_[key]] - ## "in" test support - def __contains__(self, key): - return key in self._Mapping_ - -## InfObject -# -# This class defined basic Inf object which is used by inheriting -# -# @param object: Inherited from object class -# -class InfObject(object): - def __init__(self): - object.__init__() - -## Inf -# -# This class defined the structure used in Inf object -# -# @param InfObject: Inherited from InfObject class -# @param Ffilename: Input value for Ffilename of Inf file, default is None -# @param IsMergeAllArches: Input value for IsMergeAllArches -# True is to merge all arches -# Fales is not to merge all arches -# default is False -# @param IsToModule: Input value for IsToModule -# True is to transfer to ModuleObject automatically -# False is not to transfer to ModuleObject automatically -# default is False -# @param WorkspaceDir: Input value for current workspace directory, default is None -# -# @var Identification: To store value for Identification, it is a structure as Identification -# @var UserExtensions: To store value for UserExtensions -# @var Module: To store value for Module, it is a structure as ModuleClass -# @var WorkspaceDir: To store value for WorkspaceDir -# @var KeyList: To store value for KeyList, a list for all Keys used in Inf -# -class Inf(InfObject): - def __init__(self, Filename=None, IsToModule=False, WorkspaceDir=None, PackageDir=None, SupArchList=DataType.ARCH_LIST): - self.Identification = IdentificationClass() - self.Module = ModuleClass() - self.WorkspaceDir = WorkspaceDir - self.PackageDir = PackageDir - self.SupArchList = SupArchList - - self.KeyList = [ - TAB_SOURCES, TAB_BUILD_OPTIONS, TAB_BINARIES, TAB_INCLUDES, TAB_GUIDS, - TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, TAB_PACKAGES, TAB_INF_FIXED_PCD, - TAB_INF_PATCH_PCD, TAB_INF_FEATURE_PCD, TAB_INF_PCD, TAB_INF_PCD_EX, - TAB_DEPEX, TAB_INF_DEFINES - ] - # Upper all KEYs to ignore case sensitive when parsing - self.KeyList = map(lambda c: c.upper(), self.KeyList) - - # Init RecordSet - self.RecordSet = {} - for Key in self.KeyList: - self.RecordSet[Section[Key]] = [] - - # Init Comment - self.SectionHeaderCommentDict = {} - - # Load Inf file if filename is not None - if Filename != None: - self.LoadInfFile(Filename) - - # Transfer to Module Object if IsToModule is True - if IsToModule: - self.InfToModule() - - ## Module Object to INF file - def ModuleToInf(self, Module): - Inf = '' - InfList = sdict() - SectionHeaderCommentDict = {} - if Module == None: - return Inf - - ModuleHeader = Module.ModuleHeader - TmpList = [] - # Common define items - if ModuleHeader.Name: - TmpList.append(TAB_INF_DEFINES_BASE_NAME + ' = ' + ModuleHeader.Name) - if ModuleHeader.Guid: - TmpList.append(TAB_INF_DEFINES_FILE_GUID + ' = ' + ModuleHeader.Guid) - if ModuleHeader.Version: - TmpList.append(TAB_INF_DEFINES_VERSION_STRING + ' = ' + ModuleHeader.Version) - if ModuleHeader.ModuleType: - TmpList.append(TAB_INF_DEFINES_MODULE_TYPE + ' = ' + ModuleHeader.ModuleType) - if ModuleHeader.PcdIsDriver: - TmpList.append(TAB_INF_DEFINES_PCD_IS_DRIVER + ' = ' + ModuleHeader.PcdIsDriver) - # Externs - for Item in Module.Externs: - if Item.EntryPoint: - TmpList.append(TAB_INF_DEFINES_ENTRY_POINT + ' = ' + Item.EntryPoint) - if Item.UnloadImage: - TmpList.append(TAB_INF_DEFINES_UNLOAD_IMAGE + ' = ' + Item.UnloadImage) - if Item.Constructor: - TmpList.append(TAB_INF_DEFINES_CONSTRUCTOR + ' = ' + Item.Constructor) - if Item.Destructor: - TmpList.append(TAB_INF_DEFINES_DESTRUCTOR + ' = ' + Item.Destructor) - # Other define items - if Module.UserExtensions != None: - for Item in Module.UserExtensions.Defines: - TmpList.append(Item) - InfList['Defines'] = TmpList - if ModuleHeader.Description != '': - SectionHeaderCommentDict['Defines'] = ModuleHeader.Description - - if Module.UserExtensions != None: - InfList['BuildOptions'] = Module.UserExtensions.BuildOptions - - for Item in Module.Includes: - Key = 'Includes.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - Value.append(Item.FilePath) - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.LibraryClasses: - Key = 'LibraryClasses.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - NewValue = Item.LibraryClass - if Item.RecommendedInstance: - NewValue = NewValue + '|' + Item.RecommendedInstance - if Item.FeatureFlag: - NewValue = NewValue + '|' + Item.FeatureFlag - Value.append(NewValue) - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.PackageDependencies: - Key = 'Packages.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - Value.append(Item.FilePath) - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.PcdCodes: - Key = 'Pcds' + Item.ItemType + '.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - NewValue = Item.TokenSpaceGuidCName + '.' + Item.CName - if Item.DefaultValue != '': - NewValue = NewValue + '|' + Item.DefaultValue - Value.append(NewValue) - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.Sources: - Key = 'Sources.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - NewValue = Item.SourceFile - if Item.ToolChainFamily != '': - NewValue = NewValue + '|' + Item.ToolChainFamily - if Item.TagName != '': - NewValue = NewValue + '|' + Item.TagName - if Item.ToolCode != '': - NewValue = NewValue + '|' + Item.ToolCode - if Item.FeatureFlag != '': - NewValue = NewValue + '|' + Item.FeatureFlag - Value.append(NewValue) - if Item.HelpText != '': - SectionHeaderCommentDict[Key] = Item.HelpText - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.Guids: - Key = 'Guids.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - Value.append(Item.CName) - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.Protocols: - Key = 'Protocols.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - Value.append(Item.CName) - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.Ppis: - Key = 'Ppis.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - Value.append(Item.CName) - GenMetaDatSectionItem(Key, Value, InfList) - - if Module.PeiDepex: - Key = 'Depex' - Value = Module.PeiDepex.Depex - GenMetaDatSectionItem(Key, Value, InfList) - - if Module.DxeDepex: - Key = 'Depex' - Value = Module.DxeDepex.Depex - GenMetaDatSectionItem(Key, Value, InfList) - - if Module.SmmDepex: - Key = 'Depex' - Value = Module.SmmDepex.Depex - GenMetaDatSectionItem(Key, Value, InfList) - - for Item in Module.Binaries: - Key = 'Binaries.' + GetStringOfList(Item.SupArchList) - Value = GetHelpTextList(Item.HelpTextList) - NewValue = Item.FileType + '|' + Item.BinaryFile + '|' + Item.Target - if Item.FeatureFlag != '': - NewValue = NewValue + '|' + Item.FeatureFlag - Value.append(NewValue) - GenMetaDatSectionItem(Key, Value, InfList) - - # Transfer Module to Inf - for Key in InfList: - if Key in SectionHeaderCommentDict: - List = SectionHeaderCommentDict[Key].split('\r') - for Item in List: - Inf = Inf + Item + '\n' - Inf = Inf + '[' + Key + ']' + '\n' - for Value in InfList[Key]: - if type(Value) == type([]): - for SubValue in Value: - Inf = Inf + ' ' + SubValue + '\n' - else: - Inf = Inf + ' ' + Value + '\n' - Inf = Inf + '\n' - - return Inf - - - ## Transfer to Module Object - # - # Transfer all contents of an Inf file to a standard Module Object - # - def InfToModule(self): - # Init global information for the file - ContainerFile = self.Identification.FullPath - - # Generate Module Header - self.GenModuleHeader(ContainerFile) - - # Generate BuildOptions - self.GenBuildOptions(ContainerFile) - - # Generate Includes - self.GenIncludes(ContainerFile) - - # Generate LibraryClasses - self.GenLibraryClasses(ContainerFile) - - # Generate Packages - self.GenPackages(ContainerFile) - - # Generate Pcds - self.GenPcds(ContainerFile) - - # Generate Sources - self.GenSources(ContainerFile) - - # Generate Guids - self.GenGuidProtocolPpis(DataType.TAB_GUIDS, ContainerFile) - - # Generate Protocols - self.GenGuidProtocolPpis(DataType.TAB_PROTOCOLS, ContainerFile) - - # Generate Ppis - self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile) - - # Generate Depexes - self.GenDepexes(ContainerFile) - - # Generate Binaries - self.GenBinaries(ContainerFile) - - # Init MiscFiles - self.GenMiscFiles(ContainerFile) - - ## GenMiscFiles - # - def GenMiscFiles(self, ContainerFile): - MiscFiles = MiscFileClass() - MiscFiles.Name = 'ModuleFiles' - for Item in GetFiles(os.path.dirname(ContainerFile), ['CVS', '.svn'], False): - File = CommonClass.FileClass() - File.Filename = Item - MiscFiles.Files.append(File) - self.Module.MiscFiles = MiscFiles - - ## Load Inf file - # - # Load the file if it exists - # - # @param Filename: Input value for filename of Inf file - # - def LoadInfFile(self, Filename): - # Insert a record for file - Filename = NormPath(Filename) - - self.Identification.FullPath = Filename - (self.Identification.RelaPath, self.Identification.FileName) = os.path.split(Filename) - if self.Identification.FullPath.find(self.WorkspaceDir) > -1: - self.Identification.ModulePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:]) - if self.PackageDir: - self.Identification.PackagePath = self.PackageDir - if self.Identification.ModulePath.find(self.PackageDir) == 0: - self.Identification.ModulePath = self.Identification.ModulePath[len(self.PackageDir) + 1:] - - # Init common datas - IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \ - [], [], TAB_UNKNOWN, [], [], [] - LineNo = 0 - - # Parse file content - IsFindBlockComment = False - ReservedLine = '' - Comment = '' - for Line in open(Filename, 'r'): - LineNo = LineNo + 1 - # Remove comment block - if Line.find(TAB_COMMENT_EDK_START) > -1: - ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0] - if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT): - Comment = Comment + Line.strip() + '\n' - ReservedLine = '' - else: - Comment = Comment + Line[len(ReservedLine):] + '\n' - IsFindBlockComment = True - if not ReservedLine: - continue - if Line.find(TAB_COMMENT_EDK_END) > -1: - Comment = Comment + Line[:Line.find(TAB_COMMENT_EDK_END) + len(TAB_COMMENT_EDK_END)] + '\n' - Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1] - ReservedLine = '' - IsFindBlockComment = False - if IsFindBlockComment: - Comment = Comment + Line.strip() + '\n' - continue - - # Remove comments at tail and remove spaces again - if Line.strip().startswith(TAB_COMMENT_SPLIT) or Line.strip().startswith('--/'): - Comment = Comment + Line.strip() + '\n' - Line = CleanString(Line) - if Line == '': - continue - - ## Find a new section tab - # First insert previous section items - # And then parse the content of the new section - if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SECTION_END): - if Line[1:3] == "--": - continue - Model = Section[CurrentSection.upper()] - # Insert items data of previous section - InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet) - - # Parse the new section - SectionItemList = [] - ArchList = [] - ThirdList = [] - - CurrentSection = '' - LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) - for Item in LineList: - ItemList = GetSplitValueList(Item, TAB_SPLIT) - if CurrentSection == '': - CurrentSection = ItemList[0] - else: - if CurrentSection != ItemList[0]: - EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) - if CurrentSection.upper() not in self.KeyList: - RaiseParserError(Line, CurrentSection, Filename, '', LineNo) - ItemList.append('') - ItemList.append('') - if len(ItemList) > 5: - RaiseParserError(Line, CurrentSection, Filename, '', LineNo) - else: - if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL: - EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) - ArchList.append(ItemList[1].upper()) - ThirdList.append(ItemList[2]) - - if Comment: - if Comment.endswith('\n'): - Comment = Comment[:len(Comment) - len('\n')] - self.SectionHeaderCommentDict[Section[CurrentSection.upper()]] = Comment - Comment = '' - continue - - # Not in any defined section - if CurrentSection == TAB_UNKNOWN: - ErrorMsg = "%s is not in any defined section" % Line - EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError) - - # Add a section item - SectionItemList.append([Line, LineNo, Comment]) - Comment = '' - # End of parse - #End of For - - # Insert items data of last section - Model = Section[CurrentSection.upper()] - InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet) - if Comment != '': - self.SectionHeaderCommentDict[Model] = Comment - Comment = '' - - ## Show detailed information of Module - # - # Print all members and their values of Module class - # - def ShowModule(self): - M = self.Module - print 'Filename =', M.ModuleHeader.FileName - print 'FullPath =', M.ModuleHeader.FullPath - print 'RelaPath =', M.ModuleHeader.RelaPath - print 'PackagePath =', M.ModuleHeader.PackagePath - print 'ModulePath =', M.ModuleHeader.ModulePath - print 'CombinePath =', M.ModuleHeader.CombinePath - - print 'BaseName =', M.ModuleHeader.Name - print 'Guid =', M.ModuleHeader.Guid - print 'Version =', M.ModuleHeader.Version - - print '\nIncludes =' - for Item in M.Includes: - print Item.FilePath, Item.SupArchList - print '\nLibraryClasses =' - for Item in M.LibraryClasses: - print Item.LibraryClass, Item.RecommendedInstance, Item.RecommendedInstanceGuid, Item.RecommendedInstanceVersion, Item.FeatureFlag, Item.SupModuleList, Item.SupArchList, Item.Define - print '\nPackageDependencies =' - for Item in M.PackageDependencies: - print Item.FilePath, Item.SupArchList, Item.FeatureFlag - print '\nPcds =' - for Item in M.PcdCodes: - print '\tCName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, Item.SupArchList - print '\nSources =' - for Source in M.Sources: - print Source.SourceFile, 'Fam=', Source.ToolChainFamily, 'Pcd=', Source.FeatureFlag, 'Tag=', Source.TagName, 'ToolCode=', Source.ToolCode, Source.SupArchList - print '\nGuids =' - for Item in M.Guids: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nProtocols =' - for Item in M.Protocols: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nPpis =' - for Item in M.Ppis: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nDepex =' - for Item in M.Depex: - print Item.Depex, Item.SupArchList, Item.Define - print '\nBinaries =' - for Binary in M.Binaries: - print 'Type=', Binary.FileType, 'Target=', Binary.Target, 'Name=', Binary.BinaryFile, 'FeatureFlag=', Binary.FeatureFlag, 'SupArchList=', Binary.SupArchList - print '\n*** FileList ***' - for Item in M.MiscFiles.Files: - print Item.Filename - print '****************\n' - - ## Convert [Defines] section content to ModuleHeaderClass - # - # Convert [Defines] section content to ModuleHeaderClass - # - # @param Defines The content under [Defines] section - # @param ModuleHeader An object of ModuleHeaderClass - # @param Arch The supported ARCH - # - def GenModuleHeader(self, ContainerFile): - EdkLogger.debug(2, "Generate ModuleHeader ...") - # Update all defines item in database - RecordSet = self.RecordSet[MODEL_META_DATA_HEADER] - - ModuleHeader = ModuleHeaderClass() - ModuleExtern = ModuleExternClass() - OtherDefines = [] - for Record in RecordSet: - ValueList = GetSplitValueList(Record[0], TAB_EQUAL_SPLIT) - if len(ValueList) != 2: - OtherDefines.append(Record[0]) - else: - Name = ValueList[0] - Value = ValueList[1] - if Name == TAB_INF_DEFINES_BASE_NAME: - ModuleHeader.Name = Value - ModuleHeader.BaseName = Value - elif Name == TAB_INF_DEFINES_FILE_GUID: - ModuleHeader.Guid = Value - elif Name == TAB_INF_DEFINES_VERSION_STRING: - ModuleHeader.Version = Value - elif Name == TAB_INF_DEFINES_PCD_IS_DRIVER: - ModuleHeader.PcdIsDriver = Value - elif Name == TAB_INF_DEFINES_MODULE_TYPE: - ModuleHeader.ModuleType = Value - elif Name in (TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION, TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION): - ModuleHeader.UefiSpecificationVersion = Value - elif Name == TAB_INF_DEFINES_PI_SPECIFICATION_VERSION: - ModuleHeader.PiSpecificationVersion = Value - elif Name == TAB_INF_DEFINES_ENTRY_POINT: - ModuleExtern.EntryPoint = Value - elif Name == TAB_INF_DEFINES_UNLOAD_IMAGE: - ModuleExtern.UnloadImage = Value - elif Name == TAB_INF_DEFINES_CONSTRUCTOR: - ModuleExtern.Constructor = Value - elif Name == TAB_INF_DEFINES_DESTRUCTOR: - ModuleExtern.Destructor = Value - else: - OtherDefines.append(Record[0]) - ModuleHeader.FileName = self.Identification.FileName - ModuleHeader.FullPath = self.Identification.FullPath - ModuleHeader.RelaPath = self.Identification.RelaPath - ModuleHeader.PackagePath = self.Identification.PackagePath - ModuleHeader.ModulePath = self.Identification.ModulePath - ModuleHeader.CombinePath = os.path.normpath(os.path.join(ModuleHeader.PackagePath, ModuleHeader.ModulePath, ModuleHeader.FileName)) - - if MODEL_META_DATA_HEADER in self.SectionHeaderCommentDict: - ModuleHeader.Description = self.SectionHeaderCommentDict[MODEL_META_DATA_HEADER] - self.Module.ModuleHeader = ModuleHeader - self.Module.Externs.append(ModuleExtern) - UE = self.Module.UserExtensions - if UE == None: - UE = UserExtensionsClass() - UE.Defines = OtherDefines - self.Module.UserExtensions = UE - - ## GenBuildOptions - # - # Gen BuildOptions of Inf - # [:]=Flag - # - # @param ContainerFile: The Inf file full path - # - def GenBuildOptions(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_BUILD_OPTIONS) - BuildOptions = {} - # Get all BuildOptions - RecordSet = self.RecordSet[MODEL_META_DATA_BUILD_OPTION] - UE = self.Module.UserExtensions - if UE == None: - UE = UserExtensionsClass() - for Record in RecordSet: - UE.BuildOptions.append(Record[0]) - self.Module.UserExtensions = UE - - ## GenIncludes - # - # Gen Includes of Inf - # - # @param ContainerFile: The Inf file full path - # - def GenIncludes(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_INCLUDES) - Includes = sdict() - # Get all Includes - RecordSet = self.RecordSet[MODEL_EFI_INCLUDE] - for Record in RecordSet: - Include = IncludeClass() - Include.FilePath = Record[0] - Include.SupArchList = Record[1] - if GenerateHelpText(Record[5], ''): - Include.HelpTextList.append(GenerateHelpText(Record[5], '')) - self.Module.Includes.append(Include) - #self.Module.FileList.extend(GetFiles(os.path.normpath(os.path.join(self.Identification.FileRelativePath, Include.FilePath)), ['CVS', '.svn'])) - - ## GenLibraryClasses - # - # Get LibraryClass of Inf - # | - # - # @param ContainerFile: The Inf file full path - # - def GenLibraryClasses(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES) - LibraryClasses = {} - # Get all LibraryClasses - RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS] - for Record in RecordSet: - (LibClassName, LibClassIns, Pcd, SupModelList) = GetLibraryClassOfInf([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2]) - LibraryClass = CommonClass.LibraryClassClass() - LibraryClass.LibraryClass = LibClassName - LibraryClass.RecommendedInstance = LibClassIns - LibraryClass.FeatureFlag = Pcd - LibraryClass.SupArchList = Record[1] - LibraryClass.SupModuleList = Record[4] - if GenerateHelpText(Record[5], ''): - LibraryClass.HelpTextList.append(GenerateHelpText(Record[5], '')) - self.Module.LibraryClasses.append(LibraryClass) - - ## GenPackages - # - # Gen Packages of Inf - # - # @param ContainerFile: The Inf file full path - # - def GenPackages(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_PACKAGES) - Packages = {} - # Get all Packages - RecordSet = self.RecordSet[MODEL_META_DATA_PACKAGE] - for Record in RecordSet: - (PackagePath, Pcd) = GetPackage(Record[0], ContainerFile, self.WorkspaceDir, Record[2]) - Package = ModulePackageDependencyClass() - Package.FilePath = NormPath(PackagePath) - Package.SupArchList = Record[1] - Package.FeatureFlag = Pcd - if GenerateHelpText(Record[5], ''): - Package.HelpTextList.append(GenerateHelpText(Record[5], '')) - self.Module.PackageDependencies.append(Package) - - def AddPcd(self, CName, TokenSpaceGuidCName, DefaultValue, ItemType, Arch, HelpTextList): - Pcd = PcdClass() - Pcd.CName = CName - Pcd.TokenSpaceGuidCName = TokenSpaceGuidCName - Pcd.DefaultValue = DefaultValue - Pcd.ItemType = ItemType - Pcd.SupArchList = Arch - if GenerateHelpText(HelpTextList, ''): - Pcd.HelpTextList.append(GenerateHelpText(HelpTextList, '')) - self.Module.PcdCodes.append(Pcd) - - ## GenPcds - # - # Gen Pcds of Inf - # .[|] - # - # @param ContainerFile: The Dec file full path - # - def GenPcds(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_PCDS) - Pcds = {} - PcdToken = {} - - # Get all Pcds - RecordSet1 = self.RecordSet[MODEL_PCD_FIXED_AT_BUILD] - RecordSet2 = self.RecordSet[MODEL_PCD_PATCHABLE_IN_MODULE] - RecordSet3 = self.RecordSet[MODEL_PCD_FEATURE_FLAG] - RecordSet4 = self.RecordSet[MODEL_PCD_DYNAMIC_EX] - RecordSet5 = self.RecordSet[MODEL_PCD_DYNAMIC] - - # Go through each arch - for Record in RecordSet1: - (TokenSpaceGuidCName, TokenName, Value, Type) = GetPcdOfInf(Record[0], TAB_PCDS_FIXED_AT_BUILD, ContainerFile, Record[2]) - self.AddPcd(TokenName, TokenSpaceGuidCName, Value, Type, Record[1], Record[5]) - for Record in RecordSet2: - (TokenSpaceGuidCName, TokenName, Value, Type) = GetPcdOfInf(Record[0], TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile, Record[2]) - self.AddPcd(TokenName, TokenSpaceGuidCName, Value, Type, Record[1], Record[5]) - for Record in RecordSet3: - (TokenSpaceGuidCName, TokenName, Value, Type) = GetPcdOfInf(Record[0], TAB_PCDS_FEATURE_FLAG, ContainerFile, Record[2]) - self.AddPcd(TokenName, TokenSpaceGuidCName, Value, Type, Record[1], Record[5]) - for Record in RecordSet4: - (TokenSpaceGuidCName, TokenName, Value, Type) = GetPcdOfInf(Record[0], TAB_PCDS_DYNAMIC_EX, ContainerFile, Record[2]) - self.AddPcd(TokenName, TokenSpaceGuidCName, Value, Type, Record[1], Record[5]) - for Record in RecordSet5: - (TokenSpaceGuidCName, TokenName, Value, Type) = GetPcdOfInf(Record[0], '', ContainerFile, Record[2]) - self.AddPcd(TokenName, TokenSpaceGuidCName, Value, Type, Record[1], Record[5]) - - ## GenSources - # - # Gen Sources of Inf - # [|[|[|[|]]]] - # - # @param ContainerFile: The Dec file full path - # - def GenSources(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_SOURCES) - Sources = {} - - # Get all Sources - RecordSet = self.RecordSet[MODEL_EFI_SOURCE_FILE] - for Record in RecordSet: - (Filename, Family, TagName, ToolCode, Pcd) = GetSource(Record[0], ContainerFile, self.Identification.RelaPath, Record[2]) - Source = ModuleSourceFileClass(Filename, TagName, ToolCode, Family, Pcd, Record[1]) - if GenerateHelpText(Record[5], ''): - Source.HelpTextList.append(GenerateHelpText(Record[5], '')) - if MODEL_EFI_SOURCE_FILE in self.SectionHeaderCommentDict: - Source.HelpText = self.SectionHeaderCommentDict[MODEL_EFI_SOURCE_FILE] - self.Module.Sources.append(Source) - #self.Module.FileList.append(os.path.normpath(os.path.join(self.Identification.RelaPath, Filename))) - - ## GenDepexes - # - # Gen Depex of Inf - # - # @param ContainerFile: The Inf file full path - # - def GenDepexes(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_DEPEX) - Depex = {} - # Get all Depexes - RecordSet = self.RecordSet[MODEL_EFI_DEPEX] - DepexString = '' - for Record in RecordSet: - DepexString = DepexString + Record[0] + '\n' - Dep = ModuleDepexClass() - if DepexString.endswith('\n'): - DepexString = DepexString[:len(DepexString) - len('\n')] - Dep.Depex = DepexString - if self.Module.ModuleHeader.ModuleType in ['DXE_SMM_DRIVER']: - self.Module.SmmDepex = Dep - elif self.Module.ModuleHeader.ModuleType in ['PEI_CORE', 'PEIM']: - self.Module.PeiDepex = Dep - else: - self.Module.DxeDepex = Dep -# for Record in RecordSet: -# -# Dep = ModuleDepexClass() -# Dep.Depex = Record[0] -# Dep.SupArchList = Record[1] -# if GenerateHelpText(Record[5], ''): -# Dep.HelpTextList.append(GenerateHelpText(Record[5], '')) -# DepexString = DepexString + Dep -# List.append(Dep) -# self.Module.Depex = List -# if self.Module.ModuleHeader.ModuleType in ['DXE_SMM_DRIVER']: -# self.Module.SmmDepex = List -# elif self.Module.ModuleHeader.ModuleType in ['PEI_CORE', 'PEIM']: -# self.Module.PeiDepex = List -# else: -# self.Module.DxeDepex = List - - ## GenBinaries - # - # Gen Binary of Inf - # ||[|.] - # - # @param ContainerFile: The Dec file full path - # - def GenBinaries(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_BINARIES) - Binaries = {} - - # Get all Guids - RecordSet = self.RecordSet[MODEL_EFI_BINARY_FILE] - for Record in RecordSet: - (FileType, Filename, Target, Pcd) = GetBinary(Record[0], ContainerFile, self.Identification.RelaPath, Record[2]) - Binary = ModuleBinaryFileClass(Filename, FileType, Target, Pcd, Record[1]) - if GenerateHelpText(Record[5], ''): - Binary.HelpTextList.append(GenerateHelpText(Record[5], '')) - self.Module.Binaries.append(Binary) - #self.Module.FileList.append(os.path.normpath(os.path.join(self.Identification.RelaPath, Filename))) - - ## GenGuids - # - # Gen Guids of Inf - # = - # - # @param ContainerFile: The Inf file full path - # - def GenGuidProtocolPpis(self, Type, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % Type) - Lists = {} - # Get all Items - if Type == TAB_GUIDS: - ListMember = self.Module.Guids - elif Type == TAB_PROTOCOLS: - ListMember = self.Module.Protocols - elif Type == TAB_PPIS: - ListMember = self.Module.Ppis - - RecordSet = self.RecordSet[Section[Type.upper()]] - for Record in RecordSet: - (Name, Value) = GetGuidsProtocolsPpisOfInf(Record[0], Type, ContainerFile, Record[2]) - ListClass = GuidProtocolPpiCommonClass() - ListClass.CName = Name - ListClass.SupArchList = Record[1] - ListClass.FeatureFlag = Value - if GenerateHelpText(Record[5], ''): - ListClass.HelpTextList.append(GenerateHelpText(Record[5], '')) - ListMember.append(ListClass) - -## -# -# This acts like the main() function for the script, unless it is 'import'ed into another -# script. -# -if __name__ == '__main__': - EdkLogger.Initialize() - EdkLogger.SetLevel(EdkLogger.QUIET) - - W = os.getenv('WORKSPACE') - F = os.path.join(W, 'MdeModulePkg/Application/HelloWorld/HelloWorld.inf') - - P = Inf(os.path.normpath(F), True, W, 'MdeModulePkg') - P.ShowModule() - print P.ModuleToInf(P.Module) diff --git a/BaseTools/Source/Python/Common/XmlParser.py b/BaseTools/Source/Python/Common/XmlParser.py deleted file mode 100644 index dcafb5f156..0000000000 --- a/BaseTools/Source/Python/Common/XmlParser.py +++ /dev/null @@ -1,1754 +0,0 @@ -## @file -# This file is used to parse a xml file of .PKG file -# -# Copyright (c) 2008, 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. -# - -## -# Import Modules -# -from xml.dom import minidom -from XmlRoutines import * -from CommonDataClass.DistributionPackageClass import * -from CommonDataClass.PackageClass import * -from CommonDataClass.ModuleClass import * -from Common.String import GetStringOfList - -# -# Get Help Text -# -def GetHelpTextList(HelpText): - HelpTextList = [] - for HT in HelpText: - HelpTextObj = HelpTextClass() - HelpTextObj.Lang = HT.Lang - HelpTextObj.String = HT.HelpText - HelpTextList.append(HelpTextObj) - return HelpTextList - -# HeaderXml -class HeaderXml(object): - def __init__(self): - self.Name = '' - self.BaseName = '' - self.GUID = '' - self.Version = '' - self.Copyright = '' - self.License = '' - self.Abstract = '' - self.Description = '' - - def FromXml(self, Item, Key): - self.Name = XmlElement(Item, '%s/Name' % Key) - self.BaseName = XmlAttribute(XmlNode(Item, '%s/Name' % Key), 'BaseName') - self.GUID = XmlElement(Item, '%s/GUID' % Key) - self.Version = XmlAttribute(XmlNode(Item, '%s/GUID' % Key), 'Version') - self.Copyright = XmlElement(Item, '%s/Copyright' % Key) - self.License = XmlElement(Item, '%s/License' % Key) - self.Abstract = XmlElement(Item, '%s/Abstract' % Key) - self.Description = XmlElement(Item, '%s/Description' % Key) - - ModuleHeader = ModuleHeaderClass() - ModuleHeader.Name = self.Name - ModuleHeader.BaseName = self.BaseName - ModuleHeader.Guid = self.GUID - ModuleHeader.Version = self.Version - ModuleHeader.Copyright = self.Copyright - ModuleHeader.License = self.License - ModuleHeader.Abstract = self.Abstract - ModuleHeader.Description = self.Description - - return ModuleHeader - - def ToXml(self, Header, Key): - Element1 = CreateXmlElement('Name', Header.Name, [], [['BaseName', Header.BaseName]]) - Element2 = CreateXmlElement('GUID', Header.Guid, [], [['Version', Header.Version]]) - AttributeList = [] - NodeList = [Element1, - Element2, - ['Abstract', Header.Abstract], - ['Copyright', Header.Copyright], - ['License', Header.License], - ['Description', Header.Description], - ] - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - return "Name = %s BaseName = %s GUID = %s Version = %s Copyright = %s License = %s Abstract = %s Description = %s" \ - % (self.Name, self.BaseName, self.GUID, self.Version, self.Copyright, self.License, self.Abstract, self.Description) - -# DistributionPackageHeaderXml -class DistributionPackageHeaderXml(object): - def __init__(self): - self.Header = HeaderXml() - self.ReadOnly = False - self.RePackage = True - self.Vendor = '' - self.Date = '' - self.Signature = '' - self.XmlSpecification = '' - - def FromXml(self, Item, Key): - self.ReadOnly = XmlAttribute(XmlNode(Item, '%s' % Key), 'ReadOnly') - self.RePackage = XmlAttribute(XmlNode(Item, '%s' % Key), 'RePackage') - self.Vendor = XmlElement(Item, '%s/Vendor' % Key) - self.Date = XmlElement(Item, '%s/Date' % Key) - self.Signature = XmlElement(Item, '%s/Signature' % Key) - self.XmlSpecification = XmlElement(Item, '%s/XmlSpecification' % Key) - self.Header.FromXml(Item, Key) - - DistributionPackageHeader = DistributionPackageHeaderClass() - DistributionPackageHeader.ReadOnly = self.ReadOnly - DistributionPackageHeader.RePackage = self.RePackage - DistributionPackageHeader.Name = self.Header.Name - DistributionPackageHeader.BaseName = self.Header.BaseName - DistributionPackageHeader.Guid = self.Header.GUID - DistributionPackageHeader.Version = self.Header.Version - DistributionPackageHeader.Vendor = self.Vendor - DistributionPackageHeader.Date = self.Date - DistributionPackageHeader.Copyright = self.Header.Copyright - DistributionPackageHeader.License = self.Header.License - DistributionPackageHeader.Abstract = self.Header.Abstract - DistributionPackageHeader.Description = self.Header.Description - DistributionPackageHeader.Signature = self.Signature - DistributionPackageHeader.XmlSpecification = self.XmlSpecification - - return DistributionPackageHeader - - def ToXml(self, DistributionPackageHeader, Key): - Element1 = CreateXmlElement('Name', DistributionPackageHeader.Name, [], [['BaseName', DistributionPackageHeader.BaseName]]) - Element2 = CreateXmlElement('GUID', DistributionPackageHeader.Guid, [], [['Version', DistributionPackageHeader.Version]]) - AttributeList = [['ReadOnly', str(DistributionPackageHeader.ReadOnly)], ['RePackage', str(DistributionPackageHeader.RePackage)]] - NodeList = [Element1, - Element2, - ['Vendor', DistributionPackageHeader.Vendor], - ['Date', DistributionPackageHeader.Date], - ['Copyright', DistributionPackageHeader.Copyright], - ['License', DistributionPackageHeader.License], - ['Abstract', DistributionPackageHeader.Abstract], - ['Description', DistributionPackageHeader.Description], - ['Signature', DistributionPackageHeader.Signature], - ['XmlSpecification', DistributionPackageHeader.XmlSpecification], - ] - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - return "ReadOnly = %s RePackage = %s Vendor = %s Date = %s Signature = %s XmlSpecification = %s %s" \ - % (self.ReadOnly, self.RePackage, self.Vendor, self.Date, self.Signature, self.XmlSpecification, self.Header) - -# PackageHeaderXml -class PackageHeaderXml(object): - def __init__(self): - self.Header = HeaderXml() - self.PackagePath = '' - - def FromXml(self, Item, Key): - self.PackagePath = XmlElement(Item, '%s/PackagePath' % Key) - self.Header.FromXml(Item, Key) - - PackageHeader = PackageHeaderClass() - PackageHeader.Name = self.Header.Name - PackageHeader.BaseName = self.Header.BaseName - PackageHeader.Guid = self.Header.GUID - PackageHeader.Version = self.Header.Version - PackageHeader.Copyright = self.Header.Copyright - PackageHeader.License = self.Header.License - PackageHeader.Abstract = self.Header.Abstract - PackageHeader.Description = self.Header.Description - PackageHeader.CombinePath = self.PackagePath - - return PackageHeader - - def ToXml(self, PackageHeader, Key): - Element1 = CreateXmlElement('Name', PackageHeader.Name, [], [['BaseName', PackageHeader.BaseName]]) - Element2 = CreateXmlElement('GUID', PackageHeader.Guid, [], [['Version', PackageHeader.Version]]) - AttributeList = [] - NodeList = [Element1, - Element2, - ['Copyright', PackageHeader.Copyright], - ['License', PackageHeader.License], - ['Abstract', PackageHeader.Abstract], - ['Description', PackageHeader.Description], - ['PackagePath', PackageHeader.CombinePath], - ] - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - return "PackagePath = %s %s" \ - % (self.PackagePath, self.Header) - -# ClonedFromXml -class ClonedFromXml(object): - def __init__(self): - self.GUID = '' - self.Version = '' - - def FromXml(self, Item, Key): - self.GUID = XmlElement(Item, '%s/GUID' % Key) - self.Version = XmlAttribute(XmlNode(Item, '%s/GUID' % Key), 'Version') - - if self.GUID == '' and self.Version == '': - return None - - ClonedFrom = ClonedRecordClass() - ClonedFrom.PackageGuid = self.GUID - ClonedFrom.PackageVersion = self.Version - - return ClonedFrom - - def ToXml(self, ClonedFrom, Key): - Root = minidom.Document() - Element1 = CreateXmlElement('GUID', ClonedFrom.PackageGuid, [], [['Version', ClonedFrom.PackageVersion]]) - AttributeList = [] - NodeList = [Element1] - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - return "GUID = %s Version = %s" % (self.GUID, self.Version) - -# CommonDefinesXml -class CommonDefinesXml(object): - def __init__(self): - self.Usage = '' - self.SupArchList = '' - self.SupModList = '' - self.FeatureFlag = '' - - def FromXml(self, Item, Key): - self.Usage = XmlAttribute(Item, 'Usage') - self.SupArchList = XmlAttribute(Item, 'SupArchList') - self.SupModList = XmlAttribute(Item, 'SupModList') - self.FeatureFlag = XmlAttribute(Item, 'FeatureFlag') - - def ToXml(self): - pass - - def __str__(self): - return "Usage = %s SupArchList = %s SupModList = %s FeatureFlag = %s" % (self.Usage, self.SupArchList, self.SupModList, self.FeatureFlag) - -# HelpTextXml -class HelpTextXml(object): - def __init__(self): - self.HelpText = '' - self.Lang = '' - - def FromXml(self, Item, Key): - self.HelpText = XmlElement(Item, 'HelpText') - self.Lang = XmlAttribute(Item, 'Lang') - - def ToXml(self, HelpText, Key = 'HelpText'): - return CreateXmlElement('%s' % Key, HelpText.String, [], [['Lang', HelpText.Lang]]) - - def __str__(self): - return "HelpText = %s Lang = %s" % (self.HelpText, self.Lang) - -# LibraryClassXml -class LibraryClassXml(object): - def __init__(self): - self.Keyword = '' - self.HeaderFile = '' - self.RecommendedInstanceGuid = '' - self.RecommendedInstanceVersion = '' - self.CommonDefines = CommonDefinesXml() - self.HelpText = [] - - def FromXml(self, Item, Key): - self.Keyword = XmlAttribute(XmlNode(Item, '%s' % Key), 'Keyword') - if self.Keyword == '': - self.Keyword = XmlElement(Item, '%s/Keyword' % Key) - self.HeaderFile = XmlElement(Item, '%s/HeaderFile' % Key) - self.RecommendedInstanceGuid = XmlElement(Item, '%s/RecommendedInstance/GUID' % Key) - self.RecommendedInstanceVersion = XmlAttribute(XmlNode(Item, '%s/RecommendedInstance/GUID' % Key), 'Version') - self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - LibraryClass = LibraryClassClass() - LibraryClass.LibraryClass = self.Keyword - LibraryClass.IncludeHeader = self.HeaderFile - LibraryClass.SupArchList = self.CommonDefines.SupArchList - LibraryClass.SupModuleList = self.CommonDefines.SupModList - LibraryClass.RecommendedInstanceGuid = self.RecommendedInstanceGuid - LibraryClass.RecommendedInstanceVersion = self.RecommendedInstanceVersion - LibraryClass.HelpTextList = GetHelpTextList(self.HelpText) - - return LibraryClass - - def ToXml(self, LibraryClass, Key): - Element1 = CreateXmlElement('GUID', LibraryClass.RecommendedInstanceGuid, [], [['Version', LibraryClass.RecommendedInstanceVersion]]) - Element2 = CreateXmlElement('RecommendedInstance', '', [Element1], []) - AttributeList = [['Keyword', LibraryClass.LibraryClass], - ['SupArchList', GetStringOfList(LibraryClass.SupArchList)], - ['SupModList', GetStringOfList(LibraryClass.SupModuleList)] - ] - NodeList = [['HeaderFile', LibraryClass.IncludeHeader], - Element2 - ] - for Item in LibraryClass.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item)) - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "Keyword = %s HeaderFile = %s RecommendedInstanceGuid = %s RecommendedInstanceVersion = %s %s" \ - % (self.Keyword, self.HeaderFile, self.RecommendedInstanceGuid, self.RecommendedInstanceVersion, \ - self.CommonDefines) - for Item in self.HelpText: - Str = Str + "\n\t" + str(Item) - return Str - -# IndustryStandardHeaderXml -class IndustryStandardHeaderXml(object): - def __init__(self): - self.HeaderFile = '' - self.HelpText = [] - - def FromXml(self, Item, Key): - self.HeaderFile = XmlElement(Item, '%s/HeaderFile' % Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - Include = IncludeClass() - Include.FilePath = self.HeaderFile - Include.HelpTextList = GetHelpTextList(self.HelpText) - - return Include - - def ToXml(self, IndustryStandardHeader, Key): - AttributeList = [] - NodeList = [['HeaderFile', IndustryStandardHeader.FilePath]] - for Item in IndustryStandardHeader.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item)) - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "HeaderFile = %s" % (self.HeaderFile) - for Item in self.HelpText: - Str = Str + "\n\t" + str(Item) - return Str - -# PackageIncludeHeaderXml -class PackageIncludeHeaderXml(object): - def __init__(self): - self.HeaderFile = '' - self.CommonDefines = CommonDefinesXml() - self.HelpText = [] - - def FromXml(self, Item, Key): - self.HeaderFile = XmlElement(Item, '%s/HeaderFile' % Key) - self.CommonDefines.FromXml(XmlNode(Item, '%s/HeaderFile' % Key), Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - Include = IncludeClass() - Include.FilePath = self.HeaderFile - Include.SupArchList = self.CommonDefines.SupArchList - Include.SupModuleList = self.CommonDefines.SupModList - Include.HelpTextList = GetHelpTextList(self.HelpText) - - return Include - - def ToXml(self, PackageIncludeHeader, Key): - AttributeList = [['SupArchList', PackageIncludeHeader.SupArchList], - ['SupModList', PackageIncludeHeader.SupModuleList] - ] - NodeList = [['HeaderFile', PackageIncludeHeader.FilePath]] - for Item in PackageIncludeHeader.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item)) - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "HeaderFile = %s\n\t%s" % (self.HeaderFile, self.CommonDefines) - for Item in self.HelpText: - Str = Str + "\n\t" + str(Item) - return Str - -#GUID/Protocol/Ppi -class GuidProtocolPpiXml(object): - def __init__(self): - self.UiName = '' - self.GuidTypes = '' - self.Notify = '' - self.CName = '' - self.GuidValue = '' - self.CommonDefines = CommonDefinesXml() - self.HelpText = [] - - def FromXml(self, Item, Key): - self.UiName = XmlAttribute(XmlNode(Item, '%s' % Key), 'UiName') - self.GuidTypes = XmlAttribute(XmlNode(Item, '%s' % Key), 'GuidTypes') - self.GuidType = XmlAttribute(XmlNode(Item, '%s' % Key), 'GuidType') - self.Notify = XmlAttribute(XmlNode(Item, '%s' % Key), 'Notify') - self.CName = XmlElement(Item, '%s/CName' % Key) - self.GuidValue = XmlElement(Item, '%s/GuidValue' % Key) - self.VariableName = XmlElement(Item, '%s/VariableName' % Key) - self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - GuidProtocolPpi = GuidProtocolPpiCommonClass() - GuidProtocolPpi.Name = self.UiName - GuidProtocolPpi.CName = self.CName - GuidProtocolPpi.Guid = self.GuidValue - GuidProtocolPpi.VariableName = self.VariableName - GuidProtocolPpi.Notify = self.Notify - GuidProtocolPpi.Usage = self.CommonDefines.Usage - GuidProtocolPpi.FeatureFlag = self.CommonDefines.FeatureFlag - GuidProtocolPpi.SupArchList = self.CommonDefines.SupArchList - GuidProtocolPpi.SupModuleList = self.CommonDefines.SupModList - GuidProtocolPpi.GuidTypeLists = self.GuidTypes - GuidProtocolPpi.GuidTypeList = self.GuidType - GuidProtocolPpi.HelpTextList = GetHelpTextList(self.HelpText) - - return GuidProtocolPpi - - def ToXml(self, GuidProtocolPpi, Key): - AttributeList = [['Usage', GetStringOfList(GuidProtocolPpi.Usage)], - ['UiName', GuidProtocolPpi.Name], - ['GuidTypes', GetStringOfList(GuidProtocolPpi.GuidTypeLists)], - ['GuidType', GetStringOfList(GuidProtocolPpi.GuidTypeList)], - ['Notify', str(GuidProtocolPpi.Notify)], - ['SupArchList', GetStringOfList(GuidProtocolPpi.SupArchList)], - ['SupModList', GetStringOfList(GuidProtocolPpi.SupModuleList)], - ['FeatureFlag', GuidProtocolPpi.FeatureFlag] - ] - NodeList = [['CName', GuidProtocolPpi.CName], - ['GuidValue', GuidProtocolPpi.Guid], - ['VariableName', GuidProtocolPpi.VariableName] - ] - for Item in GuidProtocolPpi.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item)) - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "UiName = %s Notify = %s GuidTypes = %s CName = %s GuidValue = %s %s" \ - % (self.UiName, self.Notify, self.GuidTypes, self.CName, self.GuidValue, self.CommonDefines) - for Item in self.HelpText: - Str = Str + "\n\t" + str(Item) - return Str - -# PcdErrorXml -class PcdErrorXml(object): - def __init__(self): - self.ValidValueList = '' - self.ValidValueListLang = '' - self.ValidValueRange = '' - self.Expression = '' - self.ErrorNumber = '' - self.ErrorMessage = [] - - def FromXml(self, Item, Key): - self.ValidValueList = XmlElement(Item, '%s/ValidValueList' % Key) - self.ValidValueListLang = XmlAttribute(XmlNode(Item, '%s/ValidValueList' % Key), 'Lang') - self.ValidValueRange = XmlElement(Item, '%s/ValidValueRange' % Key) - self.Expression = XmlElement(Item, '%s/Expression' % Key) - self.ErrorNumber = XmlElement(Item, '%s/ErrorNumber' % Key) - for ErrMsg in XmlList(Item, '%s/ErrorMessage' % Key): - ErrorMessageString = XmlElement(ErrMsg, 'ErrorMessage') - ErrorMessageLang = XmlAttribute(XmlNode(ErrMsg, 'ErrorMessage'), 'Lang') - self.ErrorMessage.append((ErrorMessageLang, ErrorMessageString)) - - Error = PcdErrorClass() - Error.ValidValueList = self.ValidValueList - Error.ValidValueListLang = self.ValidValueListLang - Error.ValidValueRange = self.ValidValueRange - Error.Expression = self.Expression - Error.ErrorNumber = self.ErrorNumber - Error.ErrorMessage = self.ErrorMessage - - return Error - - def ToXml(self, PcdError, Key): - AttributeList = [] - Element1 = CreateXmlElement('ValidValueList', PcdError.ValidValueList, [], [['Lang', PcdError.ValidValueListLang]]) - NodeList = [Element1, - ['ValidValueRange', PcdError.ValidValueRange], - ['Expression', PcdError.Expression], - ['ErrorNumber', PcdError.ErrorNumber], - ] - for Item in PcdError.ErrorMessage: - Element = CreateXmlElement('ErrorMessage', Item[1], [], [['Lang', Item[0]]]) - NodeList.append(Element) - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - return "ValidValueList = %s ValidValueListLang = %s ValidValueRange = %s Expression = %s ErrorNumber = %s %s" \ - % (self.ValidValueList, self.ValidValueListLang, self.ValidValueRange, self.Expression, self.ErrorNumber, self.ErrorMessage) - -# PcdEntryXml -class PcdEntryXml(object): - def __init__(self): - self.PcdItemType = '' - self.PcdUsage = '' - self.TokenSpaceGuidCName = '' - self.TokenSpaceGuidValue = '' - self.Token = '' - self.CName = '' - self.PcdCName = '' - self.DatumType = '' - self.ValidUsage = '' - self.DefaultValue = '' - self.MaxDatumSize = '' - self.Value = '' - self.Offset = '' - self.CommonDefines = CommonDefinesXml() - self.HelpText = [] - self.PcdError = [] - - def FromXml(self, Item, Key): - self.PcdItemType = XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType') - self.PcdUsage = XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdUsage') - self.TokenSpaceGuidCName = XmlElement(Item, '%s/TokenSpaceGuidCName' % Key) - self.TokenSpaceGuidValue = XmlElement(Item, '%s/TokenSpaceGuidValue' % Key) - self.Token = XmlElement(Item, '%s/Token' % Key) - self.CName = XmlElement(Item, '%s/CName' % Key) - self.PcdCName = XmlElement(Item, '%s/PcdCName' % Key) - self.DatumType = XmlElement(Item, '%s/DatumType' % Key) - self.ValidUsage = XmlElement(Item, '%s/ValidUsage' % Key) - self.DefaultValue = XmlElement(Item, '%s/DefaultValue' % Key) - self.MaxDatumSize = XmlElement(Item, '%s/MaxDatumSize' % Key) - self.Value = XmlElement(Item, '%s/Value' % Key) - self.Offset = XmlElement(Item, '%s/Offset' % Key) - self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - for PcdErrorItem in XmlList(Item, '%s/PcdError' % Key): - PcdErrorObj = PcdErrorXml() - PcdErrorObj.FromXml(PcdErrorItem, 'PcdError') - self.PcdError.append(PcdErrorObj) - - PcdEntry = PcdClass() - PcdEntry.SupArchList = self.CommonDefines.SupArchList - PcdEntry.SupModuleList = self.CommonDefines.SupModList - PcdEntry.TokenSpaceGuidCName = self.TokenSpaceGuidCName - PcdEntry.TokenSpaceGuidValue = self.TokenSpaceGuidValue - PcdEntry.Token = self.Token - PcdEntry.CName = self.CName - PcdEntry.PcdCName = self.PcdCName - PcdEntry.DatumType = self.DatumType - PcdEntry.ValidUsage = self.ValidUsage - PcdEntry.PcdUsage = self.PcdUsage - PcdEntry.Usage = self.CommonDefines.Usage - PcdEntry.DefaultValue = self.DefaultValue - PcdEntry.Value = self.Value - PcdEntry.Offset = self.Offset - PcdEntry.MaxDatumSize = self.MaxDatumSize - PcdEntry.FeatureFlag = self.CommonDefines.FeatureFlag - PcdEntry.PcdItemType = self.PcdItemType - PcdEntry.HelpTextList = GetHelpTextList(self.HelpText) - PcdEntry.PcdErrors = self.PcdError - - return PcdEntry - - def ToXml(self, PcdEntry, Key): - AttributeList = [['SupArchList', GetStringOfList(PcdEntry.SupArchList)], - ['PcdUsage', PcdEntry.PcdUsage], - ['PcdItemType', PcdEntry.PcdItemType], - ['FeatureFlag', PcdEntry.FeatureFlag], - ['SupModList', GetStringOfList(PcdEntry.SupModuleList)] - ] - NodeList = [['TokenSpaceGuidCName', PcdEntry.TokenSpaceGuidCName], - ['TokenSpaceGuidValue', PcdEntry.TokenSpaceGuidValue], - ['Token', PcdEntry.Token], - ['CName', PcdEntry.CName], - ['PcdCName', PcdEntry.PcdCName], - ['DatumType', PcdEntry.DatumType], - ['ValidUsage', GetStringOfList(PcdEntry.ValidUsage)], - ['DefaultValue', PcdEntry.DefaultValue], - ['Value', PcdEntry.Value], - ['Offset', PcdEntry.Offset], - ['MaxDatumSize', PcdEntry.MaxDatumSize], - ] - for Item in PcdEntry.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item, 'HelpText')) - for Item in PcdEntry.PcdErrors: - Tmp = PcdErrorXml() - NodeList.append(Tmp.ToXml(Item, 'PcdError')) - - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "PcdItemType = %s PcdUsage = %s TokenSpaceGuidCName = %s TokenSpaceGuidValue = %s Token = %s CName = %s PcdCName = %s DatumType = %s ValidUsage = %s DefaultValue = %s MaxDatumSize = %s Value = %s Offset = %s %s" \ - % (self.PcdItemType, self.PcdUsage, self.TokenSpaceGuidCName, self.TokenSpaceGuidValue, self.Token, self.CName, self.PcdCName, self.DatumType, self.ValidUsage, self.DefaultValue, self.MaxDatumSize, self.Value, self.Offset, self.CommonDefines) - for Item in self.HelpText: - Str = Str + "\n\t" + str(Item) - for Item in self.PcdError: - Str = Str + "\n\tPcdError:" + str(Item) - return Str - -# PcdCheckXml -class PcdCheckXml(object): - def __init__(self): - self.PcdCheck = '' - - def FromXml(self, Item, Key): - self.PcdCheck = XmlElement(Item, 'PcdCheck') - - return self.PcdCheck - - def ToXml(self, PcdCheck, Key): - Root = CreateXmlElement('%s' % Key, PcdCheck, [], []) - return Root - - def __str__(self): - return "PcdCheck = %s" % (self.PcdCheck) - -# MiscellaneousFileXml -class MiscellaneousFileXml(object): - def __init__(self): - self.Header = HeaderXml() - self.Files = [] - - def FromXml(self, Item, Key): - self.Header.FromXml(Item, Key) - NewItem = XmlNode(Item, '%s/Header' % Key) - self.Header.FromXml(NewItem, 'Header') - - for SubItem in XmlList(Item, '%s/Filename' % Key): - Filename = XmlElement(SubItem, '%s/Filename' % Key) - Executable = XmlAttribute(XmlNode(SubItem, '%s/Filename' % Key), 'Executable') - self.Files.append([Filename, Executable]) - - MiscFile = MiscFileClass() - MiscFile.Copyright = self.Header.Copyright - MiscFile.License = self.Header.License - MiscFile.Abstract = self.Header.Abstract - MiscFile.Description = self.Header.Description - for File in self.Files: - FileObj = FileClass() - FileObj.Filename = File[0] - FileObj.Executable = File[1] - MiscFile.Files.append(FileObj) - - return MiscFile - - def FromXml2(self, Item, Key): - NewItem = XmlNode(Item, '%s/Header' % Key) - self.Header.FromXml(NewItem, 'Header') - - for SubItem in XmlList(Item, '%s/Filename' % Key): - Filename = XmlElement(SubItem, '%s/Filename' % Key) - Executable = XmlAttribute(XmlNode(SubItem, '%s/Filename' % Key), 'Executable') - self.Files.append([Filename, Executable]) - - MiscFile = MiscFileClass() - MiscFile.Name = self.Header.Name - MiscFile.Copyright = self.Header.Copyright - MiscFile.License = self.Header.License - MiscFile.Abstract = self.Header.Abstract - MiscFile.Description = self.Header.Description - for File in self.Files: - FileObj = FileClass() - FileObj.Filename = File[0] - FileObj.Executable = File[1] - MiscFile.Files.append(FileObj) - - return MiscFile - - - def ToXml(self, MiscFile, Key): - if MiscFile: - NodeList = [['Copyright', MiscFile.Copyright], - ['License', MiscFile.License], - ['Abstract', MiscFile.Abstract], - ['Description', MiscFile.Description], - ] - if MiscFile != None: - for File in MiscFile.Files: - NodeList.append(CreateXmlElement('Filename', File.Filename, [], [['Executable', File.Executable]])) - Root = CreateXmlElement('%s' % Key, '', NodeList, []) - - return Root - - def ToXml2(self, MiscFile, Key): - if MiscFile: - NodeList = [['Name', MiscFile.Name], - ['Copyright', MiscFile.Copyright], - ['License', MiscFile.License], - ['Abstract', MiscFile.Abstract], - ['Description', MiscFile.Description], - ] - HeaderNode = CreateXmlElement('Header', '', NodeList, []) - NodeList = [HeaderNode] - - for File in MiscFile.Files: - NodeList.append(CreateXmlElement('Filename', File.Filename, [], [['Executable', File.Executable]])) - Root = CreateXmlElement('%s' % Key, '', NodeList, []) - - return Root - - def __str__(self): - Str = str(self.Header) - for Item in self.Files: - Str = Str + '\n\tFilename:' + str(Item) - return Str - -# UserExtensionsXml -class UserExtensionsXml(object): - def __init__(self): - self.UserId = '' - self.Identifier = '' - self.Defines = [] - self.BuildOptions = [] - - def FromXml(self, Item, Key): - self.UserId = XmlAttribute(XmlNode(Item, '%s' % Key), 'UserId') - self.Identifier = XmlAttribute(XmlNode(Item, '%s' % Key), 'Identifier') - for SubItem in XmlList(Item, '%s/Define' % Key): - self.Defines.append(XmlElement(SubItem, '%s/Define' % Key)) - for SubItem in XmlList(Item, '%s/BuildOption' % Key): - self.BuildOptions.append(XmlElement(SubItem, '%s/BuildOption' % Key)) - - UserExtension = UserExtensionsClass() - UserExtension.UserID = self.UserId - UserExtension.Identifier = self.Identifier - UserExtension.Defines = self.Defines - UserExtension.BuildOptions = self.BuildOptions - - return UserExtension - - def ToXml(self, UserExtension, Key): - AttributeList = [['UserId', str(UserExtension.UserID)], - ['Identifier', str(UserExtension.Identifier)] - ] - NodeList = [] - for Item in UserExtension.Defines: - NodeList.append(['Define', Item]) - for Item in UserExtension.BuildOptions: - NodeList.append(['BuildOption', Item]) - Root = CreateXmlElement('%s' % Key, UserExtension.Content, NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "UserId = %s Identifier = %s" % (self.UserId, self.Identifier) - Str = Str + '\n\tDefines:' + str(self.Defines) - Str = Str + '\n\tBuildOptions:' + str(self.BuildOptions) - return Str - -# BootModeXml -class BootModeXml(object): - def __init__(self): - self.SupportedBootModes = '' - self.CommonDefines = CommonDefinesXml() - self.HelpText = [] - - def FromXml(self, Item, Key): - self.SupportedBootModes = XmlElement(Item, '%s/SupportedBootModes' % Key) - self.CommonDefines.FromXml(Item, Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - BootMode = ModuleBootModeClass() - BootMode.Name = self.SupportedBootModes - BootMode.SupArchList = self.CommonDefines.SupArchList - BootMode.Usage = self.CommonDefines.Usage - BootMode.FeatureFlag = self.CommonDefines.FeatureFlag - BootMode.HelpTextList = GetHelpTextList(self.HelpText) - - return BootMode - - def ToXml(self, BootMode, Key): - AttributeList = [['Usage', BootMode.Usage], - ['SupArchList', GetStringOfList(BootMode.SupArchList)], - ['FeatureFlag', BootMode.FeatureFlag], - ] - NodeList = [['SupportedBootModes', BootMode.Name]] - for Item in BootMode.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item, 'HelpText')) - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "SupportedBootModes = %s %s" % (self.SupportedBootModes, self.CommonDefines) - for Item in self.HelpText: - Str = Str + '\n\t' + str(Item) - return Str - -# EventXml -class EventXml(object): - def __init__(self): - self.EventType = '' - self.Name = '' - self.CommonDefines = CommonDefinesXml() - self.HelpText = [] - - def FromXml(self, Item, Key): - self.EventType = XmlAttribute(XmlNode(Item, '%s' % Key), 'EventType') - self.Name = XmlElement(Item, '%s' % Key) - self.CommonDefines.FromXml(Item, Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - Event = ModuleEventClass() - Event.Type = self.EventType - Event.GuidCName = self.Name - Event.SupArchList = self.CommonDefines.SupArchList - Event.Usage = self.CommonDefines.Usage - Event.FeatureFlag = self.CommonDefines.FeatureFlag - Event.HelpTextList = GetHelpTextList(self.HelpText) - - return Event - - def ToXml(self, Event, Key): - AttributeList = [['EventType', Event.Type], - ['Usage', Event.Usage], - ['SupArchList', GetStringOfList(Event.SupArchList)], - ['FeatureFlag', Event.FeatureFlag], - ] - NodeList = [] - for Item in Event.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item, 'HelpText')) - Root = CreateXmlElement('%s' % Key, Event.GuidCName, NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "EventType = %s %s" % (self.EventType, self.CommonDefines) - for Item in self.HelpText: - Str = Str + '\n\t' + str(Item) - return Str - -# HobXml -class HobXml(object): - def __init__(self): - self.HobType = '' - self.Name = '' - self.CommonDefines = CommonDefinesXml() - self.HelpText = [] - - def FromXml(self, Item, Key): - self.HobType = XmlAttribute(XmlNode(Item, '%s' % Key), 'HobType') - self.Name = XmlElement(Item, '%s' % Key) - self.CommonDefines.FromXml(Item, Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - Hob = ModuleHobClass() - Hob.Type = self.HobType - Hob.GuidCName = self.Name - Hob.SupArchList = self.CommonDefines.SupArchList - Hob.Usage = self.CommonDefines.Usage - Hob.FeatureFlag = self.CommonDefines.FeatureFlag - Hob.HelpTextList = GetHelpTextList(self.HelpText) - - return Hob - - def ToXml(self, Hob, Key): - AttributeList = [['EventType', Hob.Type], - ['Usage', Hob.Usage], - ['SupArchList', GetStringOfList(Hob.SupArchList)], - ['FeatureFlag', Hob.FeatureFlag], - ] - NodeList = [] - for Item in Hob.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item, 'HelpText')) - Root = CreateXmlElement('%s' % Key, Hob.GuidCName, NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "HobType = %s %s" % (self.HobType, self.CommonDefines) - for Item in self.HelpText: - Str = Str + '\n\t' + str(Item) - return Str - -# ModulePropertyXml -class ModulePropertyXml(object): - def __init__(self): - self.CommonDefines = CommonDefinesXml() - self.ModuleType = '' - self.Path = '' - self.PcdIsDriver = '' - self.UefiSpecificationVersion = '' - self.PiSpecificationVersion = '' - self.Specification = '' - self.SpecificationVersion = '' - self.BootModes = [] - self.Events = [] - self.HOBs = [] - - def FromXml(self, Item, Key, Header = None): - self.CommonDefines.FromXml(Item, Key) - self.ModuleType = XmlElement(Item, '%s/ModuleType' % Key) - self.Path = XmlElement(Item, '%s/Path' % Key) - self.PcdIsDriver = XmlElement(Item, '%s/PcdIsDriver' % Key) - self.UefiSpecificationVersion = XmlElement(Item, '%s/UefiSpecificationVersion' % Key) - self.PiSpecificationVersion = XmlElement(Item, '%s/PiSpecificationVersion' % Key) - self.Specification = XmlElement(Item, '%s/Specification' % Key) - self.SpecificationVersion = XmlAttribute(XmlNode(Item, '%s/Specification' % Key), 'Version') - for SubItem in XmlList(Item, '%s/BootMode' % Key): - A = BootModeXml() - BootMode = A.FromXml(SubItem, 'BootMode') - self.BootModes.append(BootMode) - for SubItem in XmlList(Item, '%s/Event' % Key): - A = EventXml() - Event = A.FromXml(SubItem, 'Event') - self.Events.append(Event) - for SubItem in XmlList(Item, '%s/HOB' % Key): - A = HobXml() - Hob = A.FromXml(SubItem, 'HOB') - self.HOBs.append(Hob) - - if Header == None: - Header = ModuleHeaderClass() - - Header.ModuleType = self.ModuleType - Header.SupArchList = self.CommonDefines.SupArchList - Header.SupModuleList = self.CommonDefines.SupModList - Header.CombinePath = self.Path - Header.PcdIsDriver = self.PcdIsDriver - Header.UefiSpecificationVersion = self.UefiSpecificationVersion - Header.PiSpecificationVersion = self.PiSpecificationVersion - - return Header, self.BootModes, self.Events, self.HOBs - - - def ToXml(self, Header, BootModes, Events, Hobs, Key): - AttributeList = [['SupArchList', GetStringOfList(Header.SupArchList)], - ['SupModList', GetStringOfList(Header.SupModuleList)], - ] - NodeList = [['ModuleType', Header.ModuleType], - ['Path', Header.CombinePath], - ['PcdIsDriver', Header.PcdIsDriver], - ['UefiSpecificationVersion', Header.UefiSpecificationVersion], - ['PiSpecificationVersion', Header.PiSpecificationVersion], - ] - for Item in BootModes: - Tmp = BootModeXml() - NodeList.append(Tmp.ToXml(Item, 'BootMode')) - for Item in Events: - Tmp = EventXml() - NodeList.append(Tmp.ToXml(Item, 'Event')) - for Item in Hobs: - Tmp = HobXml() - NodeList.append(Tmp.ToXml(Item, 'Hob')) - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "ModuleType = %s Path = %s PcdIsDriver = %s UefiSpecificationVersion = %s PiSpecificationVersion = %s Specification = %s SpecificationVersion = %s %s" \ - % (self.ModuleType, self.Path, self.PcdIsDriver, self.UefiSpecificationVersion, self.PiSpecificationVersion, \ - self.Specification, self.SpecificationVersion, self.CommonDefines) - for Item in self.BootModes: - Str = Str + '\n\t' + str(Item) - for Item in self.Events: - Str = Str + '\n\t' + str(Item) - for Item in self.HOBs: - Str = Str + '\n\t' + str(Item) - return Str - -# SourceFileXml -class SourceFileXml(object): - def __init__(self): - self.SourceFile = '' - self.ToolChainFamily = '' - self.FileType = '' - self.CommonDefines = CommonDefinesXml() - - def FromXml(self, Item, Key): - self.ToolChainFamily = XmlAttribute(Item, 'Family') - self.FileType = XmlAttribute(Item, 'FileType') - self.SourceFile = XmlElement(Item, 'Filename') - self.CommonDefines.FromXml(Item, Key) - - SourceFile = ModuleSourceFileClass() - SourceFile.SourceFile = self.SourceFile - SourceFile.FileType = self.FileType - SourceFile.ToolChainFamily = self.ToolChainFamily - SourceFile.SupArchList = self.CommonDefines.SupArchList - SourceFile.FeatureFlag = self.CommonDefines.FeatureFlag - - return SourceFile - - def ToXml(self, SourceFile, Key): - AttributeList = [['SupArchList', GetStringOfList(SourceFile.SupArchList)], - ['Family', SourceFile.ToolChainFamily], - ['FileType', SourceFile.FileType], - ['FeatureFlag', SourceFile.FeatureFlag], - ] - Root = CreateXmlElement('%s' % Key, SourceFile.SourceFile, [], AttributeList) - - return Root - -# FilenameXml -class FilenameXml(object): - def __init__(self): - self.OS = '' - self.Family = '' - self.FileType = '' - self.Filename = '' - self.Executable = '' - self.CommonDefines = CommonDefinesXml() - - def FromXml(self, Item, Key): - self.OS = XmlAttribute(Item, 'OS') - self.Family = XmlAttribute(Item, 'Family') - self.FileType = XmlAttribute(Item, 'FileType') - self.Filename = XmlElement(Item, 'Filename') - self.Executable = XmlElement(Item, 'Executable') - self.CommonDefines.FromXml(Item, Key) - - Filename = FileClass() - Filename.Family = self.Family - Filename.FileType = self.FileType - Filename.Filename = self.Filename - Filename.Executable = self.Executable - Filename.SupArchList = self.CommonDefines.SupArchList - Filename.FeatureFlag = self.CommonDefines.FeatureFlag - - return Filename - - def ToXml(self, Filename, Key): - AttributeList = [['SupArchList', GetStringOfList(Filename.SupArchList)], - ['Family', Filename.Family], - ['FileType', Filename.FileType], - ['Executable', Filename.Executable], - ['FeatureFlag', Filename.FeatureFlag], - ] - NodeList = [['Filename', Filename.Filename], - ] - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - return "OS = %s Family = %s FileType = %s Filename = %s Executable = %s %s" \ - % (self.OS, self.Family, self.FileType, self.Filename, self.Executable, self.CommonDefines) - -class BinaryFileXml(object): - def __init__(self): - self.Filenames = [] - self.PatchPcdValues = [] - self.PcdExValues = [] - self.LibraryInstances = [] - self.BuildFlags = [] - - def FromXml(self, Item, Key): - BinaryFile = ModuleBinaryFileClass() - for SubItem in XmlList(Item, '%s/Filename' % Key): - A = FilenameXml() - B = A.FromXml(SubItem, 'Filename') - BinaryFile.Filenames.append(B) - for SubItem in XmlList(Item, '%s/AsBuilt/PatchPcdValue' % Key): - A = PcdEntryXml() - B = A.FromXml(SubItem, 'PatchPcdValue') - BinaryFile.PatchPcdValues.append(B) - for SubItem in XmlList(Item, '%s/AsBuilt/PcdExValue' % Key): - A = PcdEntryXml() - B = A.FromXml(SubItem, 'PcdExValue') - BinaryFile.PatchPcdValues.append(B) - for SubItem in XmlList(Item, '%s/AsBuilt/LibraryInstances/GUID' % Key): - GUID = XmlElement(SubItem, 'GUID') - Version = XmlAttribute(XmlNode(SubItem, 'GUID'), 'Version') - BinaryFile.LibraryInstances.append([GUID, Version]) - for SubItem in XmlList(Item, '%s/AsBuilt/BuildFlags' % Key): - BinaryFile.BuildFlags.append(XmlElement(SubItem, 'BuildFlags')) - - return BinaryFile - - def ToXml(self, BinaryFile, Key): - NodeList = [] - for Item in BinaryFile.Filenames: - Tmp = FilenameXml() - NodeList.append(Tmp.ToXml(Item, 'Filename')) - AsBuiltNodeList = [] - for Item in BinaryFile.PatchPcdValues: - Tmp = PcdEntryXml() - AsBuiltNodeList.append(Tmp.ToXml(Item, 'PatchPcdValue')) - for Item in BinaryFile.PcdExValues: - Tmp = PcdEntryXml() - AsBuiltNodeList.append(Tmp.ToXml(Item, 'PcdExValue')) - LibNodeList = [] - for Item in BinaryFile.LibraryInstances: - LibNode = CreateXmlElement('GUID', Item[0], [], [['Version', Item[1]]]) - LibNodeList.append(LibNode) - if LibNodeList: - AsBuiltNodeList.append(CreateXmlElement('LibraryInstances', '', LibNodeList, [])) - for Item in BinaryFile.BuildFlags: - AsBuiltNodeList.append(CreateXmlElement('BuildFlags', Item, [], [])) - Element = CreateXmlElement('AsBuilt', '', AsBuiltNodeList, []) - NodeList.append(Element) - - Root = CreateXmlElement('%s' % Key, '', NodeList, []) - - return Root - - def __str__(self): - Str = "BinaryFiles:" - for Item in self.Filenames: - Str = Str + '\n\t' + str(Item) - for Item in self.PatchPcdValues: - Str = Str + '\n\t' + str(Item) - for Item in self.PcdExValues: - Str = Str + '\n\t' + str(Item) - for Item in self.LibraryInstances: - Str = Str + '\n\t' + str(Item) - for Item in self.BuildFlags: - Str = Str + '\n\t' + str(Item) - return Str - -# PackageXml -class PackageXml(object): - def __init__(self): - self.Description = '' - self.Guid = '' - self.Version = '' - self.CommonDefines = CommonDefinesXml() - - def FromXml(self, Item, Key): - self.Description = XmlElement(Item, '%s/Description' % Key) - self.Guid = XmlElement(Item, '%s/GUID' % Key) - self.Version = XmlAttribute(XmlNode(Item, '%s/GUID' % Key), 'Version') - self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key) - - PackageDependency = ModulePackageDependencyClass() - PackageDependency.FilePath = self.Description - PackageDependency.PackageGuid = self.Guid - PackageDependency.PackageVersion = self.Version - PackageDependency.FeatureFlag = self.CommonDefines.FeatureFlag - PackageDependency.SupArchList = self.CommonDefines.SupArchList - - return PackageDependency - - def ToXml(self, PackageDependency, Key): - AttributeList = [['SupArchList', GetStringOfList(PackageDependency.SupArchList)], - ['FeatureFlag', PackageDependency.FeatureFlag], - ] - Element1 = CreateXmlElement('GUID', PackageDependency.PackageGuid, [], [['Version', PackageDependency.PackageVersion]]) - NodeList = [['Description', PackageDependency.FilePath], - Element1, - ] - - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "Description = %s Guid = %s Version = %s %s" \ - % (self.Description, self.Guid, self.Version, self.CommonDefines) - return Str - -# ExternXml -class ExternXml(object): - def __init__(self): - self.CommonDefines = CommonDefinesXml() - self.EntryPoint = '' - self.UnloadImage = '' - self.Constructor = '' - self.Destructor = '' - self.HelpText = [] - - def FromXml(self, Item, Key): - self.CommonDefines.FromXml(Item, Key) - self.EntryPoint = XmlElement(Item, '%s/EntryPoint' % Key) - self.UnloadImage = XmlElement(Item, '%s/UnloadImage' % Key) - self.Constructor = XmlElement(Item, '%s/Constructor' % Key) - self.Destructor = XmlElement(Item, '%s/Destructor' % Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - Extern = ModuleExternClass() - Extern.EntryPoint = self.EntryPoint - Extern.UnloadImage = self.UnloadImage - Extern.Constructor = self.Constructor - Extern.Destructor = self.Destructor - Extern.SupArchList = self.CommonDefines.SupArchList - Extern.FeatureFlag = self.CommonDefines.FeatureFlag - Extern.HelpTextList = GetHelpTextList(self.HelpText) - - return Extern - - def ToXml(self, Extern, Key): - AttributeList = [['SupArchList', GetStringOfList(Extern.SupArchList)], - ['FeatureFlag', Extern.FeatureFlag], - ] - NodeList = [['EntryPoint', Extern.EntryPoint], - ['UnloadImage', Extern.UnloadImage], - ['Constructor', Extern.Constructor], - ['Destructor', Extern.Destructor], - ] - for Item in Extern.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item, 'HelpText')) - - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "EntryPoint = %s UnloadImage = %s Constructor = %s Destructor = %s %s" \ - % (self.EntryPoint, self.UnloadImage, self.Constructor, self.Destructor, self.CommonDefines) - for Item in self.HelpText: - Str = Str + '\n\t' + str(Item) - return Str -# DepexXml -class DepexXml(object): - def __init__(self): - self.Expression = '' - #self.HelpText = HelpTextXml() - self.HelpText = [] - - def FromXml(self, Item, Key): - self.Expression = XmlElement(Item, '%s/Expression' % Key) - for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): - HelpTextObj = HelpTextXml() - HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) - self.HelpText.append(HelpTextObj) - - Depex = ModuleDepexClass() - Depex.Depex = self.Expression - Depex.HelpTextList = GetHelpTextList(self.HelpText) - - return Depex - - def ToXml(self, Depex, Key): - AttributeList = [] - NodeList = [['Expression', Depex.Depex], - ] - for Item in Depex.HelpTextList: - Tmp = HelpTextXml() - NodeList.append(Tmp.ToXml(Item, 'HelpText')) - - Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList) - - return Root - - def __str__(self): - Str = "Expression = %s" % (self.Expression) - for Item in self.HelpText: - Str = Str + '\n\t' + str(Item) - return Str - -# PackageSurfaceAreaXml -class PackageSurfaceAreaXml(object): - def __init__(self): - self.Package = None - - def FromXml(self, Item, Key): - # Create a package object - Package = PackageClass() - - # Header - Tmp = PackageHeaderXml() - PackageHeader = Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/Header'), 'Header') - Package.PackageHeader = PackageHeader - - # ClonedFrom - Tmp = ClonedFromXml() - ClonedFrom = Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/ClonedFrom'), 'ClonedFrom') - if ClonedFrom: - Package.PackageHeader.ClonedFrom.append(ClonedFrom) - - # LibraryClass - for SubItem in XmlList(Item, '/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass'): - Tmp = LibraryClassXml() - LibraryClass = Tmp.FromXml(SubItem, 'LibraryClass') - Package.LibraryClassDeclarations.append(LibraryClass) - - # IndustryStandardHeader - for SubItem in XmlList(Item, '/PackageSurfaceArea/IndustryStandardIncludes/IndustryStandardHeader'): - Tmp = IndustryStandardHeaderXml() - Include = Tmp.FromXml(SubItem, 'IndustryStandardHeader') - Package.IndustryStdHeaders.append(Include) - - # PackageHeader - for SubItem in XmlList(Item, '/PackageSurfaceArea/PackageIncludes/PackageHeader'): - Tmp = PackageIncludeHeaderXml() - Include = Tmp.FromXml(SubItem, 'PackageHeader') - Package.PackageIncludePkgHeaders.append(Include) - - # Guid - for SubItem in XmlList(Item, '/PackageSurfaceArea/GuidDeclarations/Entry'): - Tmp = GuidProtocolPpiXml() - GuidProtocolPpi = Tmp.FromXml(SubItem, 'Entry') - Package.GuidDeclarations.append(GuidProtocolPpi) - - # Protocol - for SubItem in XmlList(Item, '/PackageSurfaceArea/ProtocolDeclarations/Entry'): - Tmp = GuidProtocolPpiXml() - GuidProtocolPpi = Tmp.FromXml(SubItem, 'Entry') - Package.ProtocolDeclarations.append(GuidProtocolPpi) - - # Ppi - for SubItem in XmlList(Item, '/PackageSurfaceArea/PpiDeclarations/Entry'): - Tmp = GuidProtocolPpiXml() - GuidProtocolPpi = Tmp.FromXml(SubItem, 'Entry') - Package.PpiDeclarations.append(GuidProtocolPpi) - - # PcdEntry - for SubItem in XmlList(Item, '/PackageSurfaceArea/PcdDeclarations/PcdEntry'): - Tmp = PcdEntryXml() - PcdEntry = Tmp.FromXml(SubItem, 'PcdEntry') - Package.PcdDeclarations.append(PcdEntry) - - # PcdCheck - for SubItem in XmlList(Item, '/PackageSurfaceArea/PcdRelationshipChecks/PcdCheck'): - Tmp = PcdCheckXml() - PcdCheck = Tmp.FromXml(SubItem, 'PcdCheck') - Package.PcdChecks.append(PcdCheck) - - # MiscellaneousFile - Tmp = MiscellaneousFileXml() - Package.MiscFiles = Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/MiscellaneousFiles'), 'MiscellaneousFiles') - - # UserExtensions - Tmp = UserExtensionsXml() - Package.UserExtensions = Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/UserExtensions'), 'UserExtensions') - - # Modules - for SubItem in XmlList(Item, '/PackageSurfaceArea/Modules/ModuleSurfaceArea'): - Tmp = ModuleSurfaceAreaXml() - Module = Tmp.FromXml(SubItem, 'ModuleSurfaceArea') - Package.Modules[(Module.ModuleHeader.Guid, Module.ModuleHeader.Version, Module.ModuleHeader.CombinePath)] = Module - - self.Package = Package - return self.Package - - def ToXml(self, Package): - # Create PackageSurfaceArea node - DomPackage = minidom.Document().createElement('PackageSurfaceArea') - - # Header - Tmp = PackageHeaderXml() - DomPackage.appendChild(Tmp.ToXml(Package.PackageHeader, 'Header')) - - # ClonedFrom - Tmp = ClonedFromXml() - if Package.PackageHeader.ClonedFrom != []: - DomPackage.appendChild(Tmp.ToXml(Package.PackageHeader.ClonedFrom[0], 'ClonedFrom')) - - # LibraryClass - LibraryClassNode = CreateXmlElement('LibraryClassDeclarations', '', [], []) - for LibraryClass in Package.LibraryClassDeclarations: - Tmp = LibraryClassXml() - LibraryClassNode.appendChild(Tmp.ToXml(LibraryClass, 'LibraryClass')) - DomPackage.appendChild(LibraryClassNode) - - # IndustryStandardHeader - IndustryStandardHeaderNode = CreateXmlElement('IndustryStandardIncludes', '', [], []) - for Include in Package.IndustryStdHeaders: - Tmp = IndustryStandardHeaderXml() - IndustryStandardHeaderNode.appendChild(Tmp.ToXml(Include, 'IndustryStandardHeader')) - DomPackage.appendChild(IndustryStandardHeaderNode) - - # PackageHeader - PackageIncludeHeaderNode = CreateXmlElement('PackageIncludes', '', [], []) - for Include in Package.PackageIncludePkgHeaders: - Tmp = PackageIncludeHeaderXml() - PackageIncludeHeaderNode.appendChild(Tmp.ToXml(Include, 'PackageHeader')) - DomPackage.appendChild(PackageIncludeHeaderNode) - - # Guid - GuidProtocolPpiNode = CreateXmlElement('GuidDeclarations', '', [], []) - for GuidProtocolPpi in Package.GuidDeclarations: - Tmp = GuidProtocolPpiXml() - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'Entry')) - DomPackage.appendChild(GuidProtocolPpiNode) - - # Protocol - GuidProtocolPpiNode = CreateXmlElement('ProtocolDeclarations', '', [], []) - for GuidProtocolPpi in Package.ProtocolDeclarations: - Tmp = GuidProtocolPpiXml() - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'Entry')) - DomPackage.appendChild(GuidProtocolPpiNode) - - # Ppi - GuidProtocolPpiNode = CreateXmlElement('PpiDeclarations', '', [], []) - for GuidProtocolPpi in Package.PpiDeclarations: - Tmp = GuidProtocolPpiXml() - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'Entry')) - DomPackage.appendChild(GuidProtocolPpiNode) - - # PcdEntry - PcdEntryNode = CreateXmlElement('PcdDeclarations', '', [], []) - for PcdEntry in Package.PcdDeclarations: - Tmp = PcdEntryXml() - PcdEntryNode.appendChild(Tmp.ToXml(PcdEntry, 'PcdEntry')) - DomPackage.appendChild(PcdEntryNode) - - # PcdCheck - PcdCheckNode = CreateXmlElement('PcdRelationshipChecks', '', [], []) - for PcdCheck in Package.PcdChecks: - Tmp = PcdCheckXml() - PcdCheckNode.appendChild(Tmp.ToXml(PcdCheck, 'PcdCheck')) - DomPackage.appendChild(PcdCheckNode) - - # MiscellaneousFile - Tmp = MiscellaneousFileXml() - DomPackage.appendChild(Tmp.ToXml(Package.MiscFiles, 'MiscellaneousFiles')) - - # UserExtensions - Tmp = UserExtensionsXml() - DomPackage.appendChild(Tmp.ToXml(Package.UserExtensions, 'UserExtensions')) - - # Modules - ModuleNode = CreateXmlElement('Modules', '', [], []) - for Module in Package.Modules.values(): - Tmp = ModuleSurfaceAreaXml() - ModuleNode.appendChild(Tmp.ToXml(Module)) - DomPackage.appendChild(ModuleNode) - - return DomPackage - -# ModuleXml -class ModuleSurfaceAreaXml(object): - def __init__(self): - self.Module = None - - def FromXml(self, Item, Key): - # Create a package object - Module = ModuleClass() - - # Header - Tmp = HeaderXml() - ModuleHeader = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/Header'), 'Header') - Module.ModuleHeader = ModuleHeader - - # ModuleProperties - Tmp = ModulePropertyXml() - (Header, BootModes, Events, HOBs) = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/ModuleProperties'), 'ModuleProperties', ModuleHeader) - Module.ModuleHeader = Header - Module.BootModes = BootModes - Module.Events = Events - Module.Hobs = HOBs - - # ClonedFrom - Tmp = ClonedFromXml() - ClonedFrom = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/ClonedFrom'), 'ClonedFrom') - if ClonedFrom: - Module.ModuleHeader.ClonedFrom.append(ClonedFrom) - - # LibraryClass - #LibraryClassNode = CreateXmlElement('LibraryClassDefinitions', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass'): - Tmp = LibraryClassXml() - LibraryClass = Tmp.FromXml(SubItem, 'LibraryClass') - Module.LibraryClasses.append(LibraryClass) - - # SourceFile - #SourceFileNode = CreateXmlElement('SourceFiles', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/SourceFiles/Filename'): - Tmp = SourceFileXml() - SourceFile = Tmp.FromXml(SubItem, 'Filename') - Module.Sources.append(SourceFile) - - # BinaryFile - #BinaryFileNode = CreateXmlElement('BinaryFiles', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/BinaryFiles/BinaryFile'): - Tmp = BinaryFileXml() - BinaryFile = Tmp.FromXml(SubItem, 'BinaryFile') - Module.Binaries.append(BinaryFile) - - # PackageDependencies - #PackageDependencyNode = CreateXmlElement('PackageDependencies', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/PackageDependencies/Package'): - Tmp = PackageXml() - PackageDependency = Tmp.FromXml(SubItem, 'Package') - Module.PackageDependencies.append(PackageDependency) - - # Guid - #GuidProtocolPpiNode = CreateXmlElement('Guids', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/Guids/GuidCName'): - Tmp = GuidProtocolPpiXml() - GuidProtocolPpi = Tmp.FromXml(SubItem, 'GuidCName') - Module.Guids.append(GuidProtocolPpi) - - # Protocol - #GuidProtocolPpiNode = CreateXmlElement('Protocols', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/Protocols/Protocol'): - Tmp = GuidProtocolPpiXml() - GuidProtocolPpi = Tmp.FromXml(SubItem, 'Protocol') - Module.Protocols.append(GuidProtocolPpi) - - # Ppi - #GuidProtocolPpiNode = CreateXmlElement('PPIs', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/PPIs/Ppi'): - Tmp = GuidProtocolPpiXml() - GuidProtocolPpi = Tmp.FromXml(SubItem, 'Ppi') - Module.Ppis.append(GuidProtocolPpi) - - # Extern - #ExternNode = CreateXmlElement('Externs', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/Externs/Extern'): - Tmp = ExternXml() - Extern = Tmp.FromXml(SubItem, 'Extern') - Module.Externs.append(Extern) - - # PcdCoded - #PcdEntryNode = CreateXmlElement('PcdCoded', '', [], []) - for SubItem in XmlList(Item, '/ModuleSurfaceArea/PcdCoded/PcdEntry'): - Tmp = PcdEntryXml() - PcdEntry = Tmp.FromXml(SubItem, 'PcdEntry') - Module.PcdCodes.append(PcdEntry) - - # PeiDepex - #DepexNode = CreateXmlElement('PeiDepex', '', [], []) - Tmp = DepexXml() - Module.PeiDepex = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/PeiDepex'), 'PeiDepex') - - # DxeDepex - #DepexNode = CreateXmlElement('DxeDepex', '', [], []) - Tmp = DepexXml() - Module.DxeDepex = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/DxeDepex'), 'DxeDepex') - - # SmmDepex - #DepexNode = CreateXmlElement('SmmDepex', '', [], []) - Tmp = DepexXml() - Module.SmmDepex = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/DxeDepex'), 'SmmDepex') - - # MiscellaneousFile - Tmp = MiscellaneousFileXml() - Module.MiscFiles = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/MiscellaneousFiles'), 'MiscellaneousFiles') - - # UserExtensions - Tmp = UserExtensionsXml() - Module.UserExtensions = Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/UserExtensions'), 'UserExtensions') - - # return the module object - self.Module = Module - return self.Module - - def ToXml(self, Module): - # Create root node of module surface area - DomModule = minidom.Document().createElement('ModuleSurfaceArea') - - # Header - Tmp = HeaderXml() - DomModule.appendChild(Tmp.ToXml(Module.ModuleHeader, 'Header')) - - # ModuleProperties - Tmp = ModulePropertyXml() - DomModule.appendChild(Tmp.ToXml(Module.ModuleHeader, Module.BootModes, Module.Events, Module.Hobs, 'ModuleProperties')) - - # ClonedFrom - Tmp = ClonedFromXml() - if Module.ModuleHeader.ClonedFrom != []: - DomModule.appendChild(Tmp.ToXml(Module.ModuleHeader.ClonedFrom[0], 'ClonedFrom')) - - # LibraryClass - LibraryClassNode = CreateXmlElement('LibraryClassDefinitions', '', [], []) - for LibraryClass in Module.LibraryClasses: - Tmp = LibraryClassXml() - LibraryClassNode.appendChild(Tmp.ToXml(LibraryClass, 'LibraryClass')) - DomModule.appendChild(LibraryClassNode) - - # SourceFile - SourceFileNode = CreateXmlElement('SourceFiles', '', [], []) - for SourceFile in Module.Sources: - Tmp = SourceFileXml() - SourceFileNode.appendChild(Tmp.ToXml(SourceFile, 'Filename')) - DomModule.appendChild(SourceFileNode) - - # BinaryFile - BinaryFileNode = CreateXmlElement('BinaryFiles', '', [], []) - for BinaryFile in Module.Binaries: - Tmp = BinaryFileXml() - BinaryFileNode.appendChild(Tmp.ToXml(BinaryFile, 'BinaryFile')) - DomModule.appendChild(BinaryFileNode) - - # PackageDependencies - PackageDependencyNode = CreateXmlElement('PackageDependencies', '', [], []) - for PackageDependency in Module.PackageDependencies: - Tmp = PackageXml() - PackageDependencyNode.appendChild(Tmp.ToXml(PackageDependency, 'Package')) - DomModule.appendChild(PackageDependencyNode) - - # Guid - GuidProtocolPpiNode = CreateXmlElement('Guids', '', [], []) - for GuidProtocolPpi in Module.Guids: - Tmp = GuidProtocolPpiXml() - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'GuidCName')) - DomModule.appendChild(GuidProtocolPpiNode) - - # Protocol - GuidProtocolPpiNode = CreateXmlElement('Protocols', '', [], []) - for GuidProtocolPpi in Module.Protocols: - Tmp = GuidProtocolPpiXml() - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'Protocol')) - DomModule.appendChild(GuidProtocolPpiNode) - - # Ppi - GuidProtocolPpiNode = CreateXmlElement('PPIs', '', [], []) - for GuidProtocolPpi in Module.Ppis: - Tmp = GuidProtocolPpiXml() - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'Ppi')) - DomModule.appendChild(GuidProtocolPpiNode) - - # Extern - ExternNode = CreateXmlElement('Externs', '', [], []) - for Extern in Module.Externs: - Tmp = ExternXml() - ExternNode.appendChild(Tmp.ToXml(Extern, 'Extern')) - DomModule.appendChild(ExternNode) - - # PcdCoded - PcdEntryNode = CreateXmlElement('PcdCoded', '', [], []) - for PcdEntry in Module.PcdCodes: - Tmp = PcdEntryXml() - PcdEntryNode.appendChild(Tmp.ToXml(PcdEntry, 'PcdEntry')) - DomModule.appendChild(PcdEntryNode) - - # PeiDepex - if Module.PeiDepex: - DepexNode = CreateXmlElement('PeiDepex', '', [], []) - Tmp = DepexXml() - DomModule.appendChild(Tmp.ToXml(Module.PeiDepex, 'PeiDepex')) - - # DxeDepex - if Module.DxeDepex: - DepexNode = CreateXmlElement('DxeDepex', '', [], []) - Tmp = DepexXml() - DomModule.appendChild(Tmp.ToXml(Module.DxeDepex, 'DxeDepex')) - - # SmmDepex - if Module.SmmDepex: - DepexNode = CreateXmlElement('SmmDepex', '', [], []) - Tmp = DepexXml() - DomModule.appendChild(Tmp.ToXml(Module.SmmDepex, 'SmmDepex')) - - # MiscellaneousFile - Tmp = MiscellaneousFileXml() - DomModule.appendChild(Tmp.ToXml(Module.MiscFiles, 'MiscellaneousFiles')) - - # UserExtensions - Tmp = UserExtensionsXml() - DomModule.appendChild(Tmp.ToXml(Module.UserExtensions, 'UserExtensions')) - - return DomModule - -# DistributionPackageXml -class DistributionPackageXml(object): - def __init__(self): - self.Dp = DistributionPackageClass() - - def FromXml(self, Filename = None): - if Filename != None: - self.Dp = DistributionPackageClass() - - # Load to XML - self.Pkg = XmlParseFile(Filename) - - # Parse Header information - Tmp = DistributionPackageHeaderXml() - DistributionPackageHeader = Tmp.FromXml(XmlNode(self.Pkg, '/DistributionPackage/DistributionHeader'), 'DistributionHeader') - self.Dp.Header = DistributionPackageHeader - - # Parse each PackageSurfaceArea - for Item in XmlList(self.Pkg, '/DistributionPackage/PackageSurfaceArea'): - Psa = PackageSurfaceAreaXml() - Package = Psa.FromXml(Item, 'PackageSurfaceArea') - self.Dp.PackageSurfaceArea[(Package.PackageHeader.Guid, Package.PackageHeader.Version, Package.PackageHeader.CombinePath)] = Package - - # Parse each ModuleSurfaceArea - for Item in XmlList(self.Pkg, '/DistributionPackage/ModuleSurfaceArea'): - Msa = ModuleSurfaceAreaXml() - Module = Msa.FromXml(Item, 'ModuleSurfaceArea') - self.Dp.ModuleSurfaceArea[(Module.ModuleHeader.Guid, Module.ModuleHeader.Version, Module.ModuleHeader.CombinePath)] = Module - - # Parse Tools - Tmp = MiscellaneousFileXml() - self.Dp.Tools = Tmp.FromXml2(XmlNode(self.Pkg, '/DistributionPackage/Tools'), 'Tools') - - # Parse MiscFiles - Tmp = MiscellaneousFileXml() - self.Dp.MiscellaneousFiles = Tmp.FromXml2(XmlNode(self.Pkg, '/DistributionPackage/MiscellaneousFiles'), 'MiscellaneousFiles') - - return self.Dp - - def ToXml(self, Dp): - if Dp != None: - # Parse DistributionPackageHeader - Attrs = [['xmlns', 'http://www.uefi.org/2008/2.1'], - ['xmlns:xsi', 'http:/www.w3.org/2001/XMLSchema-instance'], - ] - Root = CreateXmlElement('DistributionPackage', '', [], Attrs) - - Tmp = DistributionPackageHeaderXml() - Root.appendChild(Tmp.ToXml(Dp.Header, 'DistributionHeader')) - - # Parse each PackageSurfaceArea - for Package in Dp.PackageSurfaceArea.values(): - Psa = PackageSurfaceAreaXml() - DomPackage = Psa.ToXml(Package) - Root.appendChild(DomPackage) - - # Parse each ModuleSurfaceArea - for Module in Dp.ModuleSurfaceArea.values(): - Msa = ModuleSurfaceAreaXml() - DomModule = Msa.ToXml(Module) - Root.appendChild(DomModule) - - # Parse Tools - Tmp = MiscellaneousFileXml() - #Tools = Tmp.FromXml2(XmlNode(self.Pkg, '/DistributionPackage/Tools'), 'Tools') - Root.appendChild(Tmp.ToXml2(Dp.Tools, 'Tools')) - - # Parse MiscFiles - Tmp = MiscellaneousFileXml() - #Tools = Tmp.FromXml2(XmlNode(self.Pkg, '/DistributionPackage/MiscellaneousFiles'), 'MiscellaneousFiles') - Root.appendChild(Tmp.ToXml2(Dp.MiscellaneousFiles, 'MiscellaneousFiles')) - - return Root.toprettyxml(indent = ' ') - - return '' - -if __name__ == '__main__': - M = DistributionPackageXml() - M.FromXml('C:\Test.xml') - print M.ToXml(M.Dp) - \ No newline at end of file diff --git a/BaseTools/Source/Python/Common/XmlRoutines.py b/BaseTools/Source/Python/Common/XmlRoutines.py deleted file mode 100644 index 5823067056..0000000000 --- a/BaseTools/Source/Python/Common/XmlRoutines.py +++ /dev/null @@ -1,228 +0,0 @@ -## @file -# This is an XML API that uses a syntax similar to XPath, but it is written in -# standard python so that no extra python packages are required to use it. -# -# Copyright (c) 2007, 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. -# - -## -# Import Modules -# -import xml.dom.minidom - -## Create a element of XML -# -# @param Name -# @param String -# @param NodeList -# @param AttributeList -# -# @revel Element -# -def CreateXmlElement(Name, String, NodeList, AttributeList): - Doc = xml.dom.minidom.Document() - Element = Doc.createElement(Name) - if String != '' and String != None: - Element.appendChild(Doc.createTextNode(String)) - - for Item in NodeList: - if type(Item) == type([]): - Key = Item[0] - Value = Item[1] - if Key != '' and Key != None and Value != '' and Value != None: - Node = Doc.createElement(Key) - Node.appendChild(Doc.createTextNode(Value)) - Element.appendChild(Node) - else: - Element.appendChild(Item) - for Item in AttributeList: - Key = Item[0] - Value = Item[1] - if Key != '' and Key != None and Value != '' and Value != None: - Element.setAttribute(Key, Value) - - return Element - -## Get a list of XML nodes using XPath style syntax. -# -# Return a list of XML DOM nodes from the root Dom specified by XPath String. -# If the input Dom or String is not valid, then an empty list is returned. -# -# @param Dom The root XML DOM node. -# @param String A XPath style path. -# -# @revel Nodes A list of XML nodes matching XPath style Sting. -# -def XmlList(Dom, String): - if String == None or String == "" or Dom == None or Dom == "": - return [] - if Dom.nodeType == Dom.DOCUMENT_NODE: - Dom = Dom.documentElement - if String[0] == "/": - String = String[1:] - TagList = String.split('/') - Nodes = [Dom] - Index = 0 - End = len(TagList) - 1 - while Index <= End: - ChildNodes = [] - for Node in Nodes: - if Node.nodeType == Node.ELEMENT_NODE and Node.tagName == TagList[Index]: - if Index < End: - ChildNodes.extend(Node.childNodes) - else: - ChildNodes.append(Node) - Nodes = ChildNodes - ChildNodes = [] - Index += 1 - - return Nodes - - -## Get a single XML node using XPath style syntax. -# -# Return a single XML DOM node from the root Dom specified by XPath String. -# If the input Dom or String is not valid, then an empty string is returned. -# -# @param Dom The root XML DOM node. -# @param String A XPath style path. -# -# @revel Node A single XML node matching XPath style Sting. -# -def XmlNode(Dom, String): - if String == None or String == "" or Dom == None or Dom == "": - return "" - if Dom.nodeType == Dom.DOCUMENT_NODE: - Dom = Dom.documentElement - if String[0] == "/": - String = String[1:] - TagList = String.split('/') - Index = 0 - End = len(TagList) - 1 - ChildNodes = [Dom] - while Index <= End: - for Node in ChildNodes: - if Node.nodeType == Node.ELEMENT_NODE and Node.tagName == TagList[Index]: - if Index < End: - ChildNodes = Node.childNodes - else: - return Node - break - Index += 1 - return "" - - -## Get a single XML element using XPath style syntax. -# -# Return a single XML element from the root Dom specified by XPath String. -# If the input Dom or String is not valid, then an empty string is returned. -# -# @param Dom The root XML DOM object. -# @param Strin A XPath style path. -# -# @revel Element An XML element matching XPath style Sting. -# -def XmlElement(Dom, String): - try: - return XmlNode(Dom, String).firstChild.data.strip() - except: - return "" - - -## Get a single XML element of the current node. -# -# Return a single XML element specified by the current root Dom. -# If the input Dom is not valid, then an empty string is returned. -# -# @param Dom The root XML DOM object. -# -# @revel Element An XML element in current root Dom. -# -def XmlElementData(Dom): - try: - return Dom.firstChild.data.strip() - except: - return "" - - -## Get a list of XML elements using XPath style syntax. -# -# Return a list of XML elements from the root Dom specified by XPath String. -# If the input Dom or String is not valid, then an empty list is returned. -# -# @param Dom The root XML DOM object. -# @param String A XPath style path. -# -# @revel Elements A list of XML elements matching XPath style Sting. -# -def XmlElementList(Dom, String): - return map(XmlElementData, XmlList(Dom, String)) - - -## Get the XML attribute of the current node. -# -# Return a single XML attribute named Attribute from the current root Dom. -# If the input Dom or Attribute is not valid, then an empty string is returned. -# -# @param Dom The root XML DOM object. -# @param Attribute The name of Attribute. -# -# @revel Element A single XML element matching XPath style Sting. -# -def XmlAttribute(Dom, Attribute): - try: - return Dom.getAttribute(Attribute).strip() - except: - return '' - - -## Get the XML node name of the current node. -# -# Return a single XML node name from the current root Dom. -# If the input Dom is not valid, then an empty string is returned. -# -# @param Dom The root XML DOM object. -# -# @revel Element A single XML element matching XPath style Sting. -# -def XmlNodeName(Dom): - try: - return Dom.nodeName.strip() - except: - return '' - -## Parse an XML file. -# -# Parse the input XML file named FileName and return a XML DOM it stands for. -# If the input File is not a valid XML file, then an empty string is returned. -# -# @param FileName The XML file name. -# -# @revel Dom The Dom object achieved from the XML file. -# -def XmlParseFile(FileName): - try: - XmlFile = open(FileName) - Dom = xml.dom.minidom.parse(XmlFile) - XmlFile.close() - return Dom - except Exception, X: - print X - return "" - -# This acts like the main() function for the script, unless it is 'import'ed -# into another script. -if __name__ == '__main__': - # Nothing to do here. Could do some unit tests. - A = CreateXmlElement('AAA', 'CCC', [['AAA', '111'], ['BBB', '222']], [['A', '1'], ['B', '2']]) - B = CreateXmlElement('ZZZ', 'CCC', [['XXX', '111'], ['YYY', '222']], [['A', '1'], ['B', '2']]) - C = CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG']) - print C.toprettyxml(indent = " ") - pass diff --git a/BaseTools/Source/Python/CommonDataClass/DistributionPackageClass.py b/BaseTools/Source/Python/CommonDataClass/DistributionPackageClass.py deleted file mode 100644 index 8f12026887..0000000000 --- a/BaseTools/Source/Python/CommonDataClass/DistributionPackageClass.py +++ /dev/null @@ -1,158 +0,0 @@ -## @file -# This file is used to define a class object to describe a distribution package -# -# Copyright (c) 2008, 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. - -## -# Import Modules -# -import os.path -from CommonClass import * -from Common.Misc import sdict -from Common.Misc import GetFiles -from Common.DecClassObjectLight import Dec -from Common.InfClassObjectLight import Inf -from Common.XmlParser import * - -## DistributionPackageHeaderClass -# -class DistributionPackageHeaderClass(IdentificationClass, CommonHeaderClass): - def __init__(self): - IdentificationClass.__init__(self) - CommonHeaderClass.__init__(self) - self.ReadOnly = 'False' - self.RePackage = 'True' - self.Vendor = '' - self.Date = '' - self.Signature = 'Md5Sum' - self.XmlSpecification = '' - -## DistributionPackageClass -# -# -class DistributionPackageClass(object): - def __init__(self): - self.Header = DistributionPackageHeaderClass() - self.PackageSurfaceArea = sdict() # {(Guid, Version, Path) : PackageObj} - self.ModuleSurfaceArea = sdict() # {(Guid, Version, Path) : ModuleObj} - self.Tools = MiscFileClass() - self.MiscellaneousFiles = MiscFileClass() - self.UserExtensions = [] - - ## Get all included packages and modules for a distribution package - # - # @param WorkspaceDir: WorkspaceDir - # @param PackageList: A list of all packages - # @param ModuleList: A list of all modules - # - def GetDistributionPackage(self, WorkspaceDir, PackageList, ModuleList): - AllGuidVersionDict = {} - # Get Packages - if PackageList: - for PackageFile in PackageList: - PackageFileFullPath = os.path.normpath(os.path.join(WorkspaceDir, PackageFile)) - DecObj = Dec(PackageFileFullPath, True, WorkspaceDir) - PackageObj = DecObj.Package - AllGuidVersionDict[PackageFileFullPath] = [PackageObj.PackageHeader.Guid, PackageObj.PackageHeader.Version] - - # Parser inf file one bye one - for File in PackageObj.MiscFiles.Files: - Filename = os.path.normpath(os.path.join(PackageObj.PackageHeader.RelaPath, File.Filename)) - (Name, ExtName) = os.path.splitext(Filename) - if ExtName.upper() == '.INF': - InfObj = Inf(Filename, True, WorkspaceDir, DecObj.Identification.PackagePath) - ModuleObj = InfObj.Module - AllGuidVersionDict[File] = [ModuleObj.ModuleHeader.Guid, ModuleObj.ModuleHeader.Version] - # Find and update Guid/Version of LibraryClass - for Item in ModuleObj.LibraryClasses: - if Item.RecommendedInstance: - LibClassIns = os.path.normpath(os.path.join(WorkspaceDir, Item.RecommendedInstance)) - Guid, Version = '', '' - if LibClassIns in AllGuidVersionDict: - Guid = AllGuidVersionDict[LibClassIns][0] - Version = AllGuidVersionDict[LibClassIns][1] - else: - Lib = Inf(LibClassIns, True, WorkspaceDir) - Guid = Lib.Module.ModuleHeader.Guid - Version = Lib.Module.ModuleHeader.Version - AllGuidVersionDict[LibClassIns] = [Guid, Version] - Item.RecommendedInstanceGuid = Guid - Item.RecommendedInstanceVersion = Version - # Find and update Guid/Version of - for Item in ModuleObj.PackageDependencies: - if Item.FilePath: - PackageFilePath = os.path.normpath(os.path.join(WorkspaceDir, Item.FilePath)) - Guid, Version = '', '' - if PackageFilePath in AllGuidVersionDict: - Guid = AllGuidVersionDict[PackageFilePath][0] - Version = AllGuidVersionDict[PackageFilePath][1] - else: - PackageDependencies = Dec(PackageFilePath, True, WorkspaceDir) - Guid = PackageDependencies.Package.PackageHeader.Guid - Version = PackageDependencies.Package.PackageHeader.Version - AllGuidVersionDict[PackageFilePath] = [Guid, Version] - Item.PackageGuid = Guid - Item.PackageVersion = Version - - # Add module to package - PackageObj.Modules[(ModuleObj.ModuleHeader.Guid, ModuleObj.ModuleHeader.Version, ModuleObj.ModuleHeader.CombinePath)] = ModuleObj - self.PackageSurfaceArea[(PackageObj.PackageHeader.Guid, PackageObj.PackageHeader.Version, PackageObj.PackageHeader.CombinePath)] = PackageObj - - # Get Modules - if ModuleList: - for ModuleFile in ModuleList: - ModuleFileFullPath = os.path.normpath(os.path.join(WorkspaceDir, ModuleFile)) - InfObj = Inf(ModuleFileFullPath, True, WorkspaceDir) - ModuleObj = InfObj.Module - AllGuidVersionDict[ModuleFileFullPath] = [ModuleObj.ModuleHeader.Guid, ModuleObj.ModuleHeader.Version] - # Find and update Guid/Version of LibraryClass - for Item in ModuleObj.LibraryClasses: - if Item.RecommendedInstance: - LibClassIns = os.path.normpath(os.path.join(WorkspaceDir, Item.RecommendedInstance)) - Guid, Version = '', '' - if LibClassIns in AllGuidVersionDict: - Guid = AllGuidVersionDict[LibClassIns][0] - Version = AllGuidVersionDict[LibClassIns][1] - else: - Lib = Inf(LibClassIns, True, WorkspaceDir) - Guid = Lib.Module.ModuleHeader.Guid - Version = Lib.Module.ModuleHeader.Version - AllGuidVersionDict[LibClassIns] = [Guid, Version] - Item.RecommendedInstanceGuid = Guid - Item.RecommendedInstanceVersion = Version - # Find and update Guid/Version of - for Item in ModuleObj.PackageDependencies: - if Item.FilePath: - PackageFilePath = os.path.normpath(os.path.join(WorkspaceDir, Item.FilePath)) - Guid, Version = '', '' - if PackageFilePath in AllGuidVersionDict: - Guid = AllGuidVersionDict[PackageFilePath][0] - Version = AllGuidVersionDict[PackageFilePath][1] - else: - PackageDependencies = Dec(PackageFilePath, True, WorkspaceDir) - Guid = PackageDependencies.Package.PackageHeader.Guid - Version = PackageDependencies.Package.PackageHeader.Version - AllGuidVersionDict[PackageFilePath] = [Guid, Version] - Item.PackageGuid = Guid - Item.PackageVersion = Version - self.ModuleSurfaceArea[(ModuleObj.ModuleHeader.Guid, ModuleObj.ModuleHeader.Version, ModuleObj.ModuleHeader.CombinePath)] = ModuleObj - -## -# -# This acts like the main() function for the script, unless it is 'import'ed into another -# script. -# -if __name__ == '__main__': - D = DistributionPackageClass() - D.GetDistributionPackage(os.getenv('WORKSPACE'), ['MdePkg/MdePkg.dec', 'TianoModulePkg/TianoModulePkg.dec'], ['MdeModulePkg/Application/HelloWorld/HelloWorld.inf']) - Xml = DistributionPackageXml() - print Xml.ToXml(D) - E = Xml.FromXml('C:\\2.xml') - #print Xml.ToXml(E) diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index cd47b805e5..6f5f9fd0b5 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -580,6 +580,7 @@ class Check(object): pass # Check whether the unnecessary inclusion of library classes in the Inf file + # Check whether the unnecessary duplication of library classe names in the DSC file def MetaDataFileCheckLibraryNoUse(self): if EccGlobalData.gConfig.MetaDataFileCheckLibraryNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1': EdkLogger.quiet("Checking for library instance not used ...") @@ -588,7 +589,20 @@ class Check(object): for Record in RecordSet: if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, Record[1]): EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, OtherMsg="The Library Class [%s] is not used in any platform" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0]) - + SqlCommand = """ + select A.ID, A.Value1, A.BelongsToFile, A.StartLine, B.StartLine from Dsc as A left join Dsc as B + where A.Model = %s and B.Model = %s and A.Value3 = B.Value3 and A.Arch = B.Arch and A.ID <> B.ID + and A.Value1 = B.Value1 and A.StartLine <> B.StartLine and B.BelongsToFile = A.BelongsToFile""" \ + % (MODEL_EFI_LIBRARY_CLASS, MODEL_EFI_LIBRARY_CLASS) + RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand) + for Record in RecordSet: + if Record[3] and Record[4] and Record[3] != Record[4]: + SqlCommand = """select FullPath from File where ID = %s""" % (Record[2]) + FilePathList = EccGlobalData.gDb.TblFile.Exec(SqlCommand) + for FilePath in FilePathList: + if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE, Record[1]): + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE, OtherMsg="The Library Class [%s] is duplicated in '%s' line %s and line %s." % (Record[1], FilePath, Record[3], Record[4]), BelongsToTable='Dsc', BelongsToItem=Record[0]) + # Check whether an Inf file is specified in the FDF file, but not in the Dsc file, then the Inf file must be for a Binary module only def MetaDataFileCheckBinaryInfInFdf(self): if EccGlobalData.gConfig.MetaDataFileCheckBinaryInfInFdf == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1': diff --git a/BaseTools/Source/Python/Ecc/EccToolError.py b/BaseTools/Source/Python/Ecc/EccToolError.py index 48810e466c..4039f57bc6 100644 --- a/BaseTools/Source/Python/Ecc/EccToolError.py +++ b/BaseTools/Source/Python/Ecc/EccToolError.py @@ -94,6 +94,7 @@ ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI = 10013 ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE = 10014 ERROR_META_DATA_FILE_CHECK_PCD_TYPE = 10015 ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION = 10016 +ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE = 10017 ERROR_SPELLING_CHECK_ALL = 11000 @@ -171,6 +172,7 @@ gEccErrorMessage = { ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT : "A library instance must be defined for all dependent library classes", ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_ORDER : "The library Instances specified by the LibraryClasses sections should be listed in order of dependencies", ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE : "There should be no unnecessary inclusion of library classes in the INF file", + ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE : "Duplicate Library Class Name found", ERROR_META_DATA_FILE_CHECK_BINARY_INF_IN_FDF : "An INF file is specified in the FDF file, but not in the DSC file, therefore the INF file must be for a Binary module only", ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE : "Duplicate PCDs found", ERROR_META_DATA_FILE_CHECK_PCD_FLASH : "PCD settings in the FDF file should only be related to flash", diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Python/Ecc/Exception.py index ff8736059f..ffbb62b3b0 100644 --- a/BaseTools/Source/Python/Ecc/Exception.py +++ b/BaseTools/Source/Python/Ecc/Exception.py @@ -14,7 +14,7 @@ ## # Import Modules # -from Common.XmlRoutines import * +from Xml.XmlRoutines import * import os.path # ExceptionXml to parse Exception Node of XML file diff --git a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py new file mode 100644 index 0000000000..5823067056 --- /dev/null +++ b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py @@ -0,0 +1,228 @@ +## @file +# This is an XML API that uses a syntax similar to XPath, but it is written in +# standard python so that no extra python packages are required to use it. +# +# Copyright (c) 2007, 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. +# + +## +# Import Modules +# +import xml.dom.minidom + +## Create a element of XML +# +# @param Name +# @param String +# @param NodeList +# @param AttributeList +# +# @revel Element +# +def CreateXmlElement(Name, String, NodeList, AttributeList): + Doc = xml.dom.minidom.Document() + Element = Doc.createElement(Name) + if String != '' and String != None: + Element.appendChild(Doc.createTextNode(String)) + + for Item in NodeList: + if type(Item) == type([]): + Key = Item[0] + Value = Item[1] + if Key != '' and Key != None and Value != '' and Value != None: + Node = Doc.createElement(Key) + Node.appendChild(Doc.createTextNode(Value)) + Element.appendChild(Node) + else: + Element.appendChild(Item) + for Item in AttributeList: + Key = Item[0] + Value = Item[1] + if Key != '' and Key != None and Value != '' and Value != None: + Element.setAttribute(Key, Value) + + return Element + +## Get a list of XML nodes using XPath style syntax. +# +# Return a list of XML DOM nodes from the root Dom specified by XPath String. +# If the input Dom or String is not valid, then an empty list is returned. +# +# @param Dom The root XML DOM node. +# @param String A XPath style path. +# +# @revel Nodes A list of XML nodes matching XPath style Sting. +# +def XmlList(Dom, String): + if String == None or String == "" or Dom == None or Dom == "": + return [] + if Dom.nodeType == Dom.DOCUMENT_NODE: + Dom = Dom.documentElement + if String[0] == "/": + String = String[1:] + TagList = String.split('/') + Nodes = [Dom] + Index = 0 + End = len(TagList) - 1 + while Index <= End: + ChildNodes = [] + for Node in Nodes: + if Node.nodeType == Node.ELEMENT_NODE and Node.tagName == TagList[Index]: + if Index < End: + ChildNodes.extend(Node.childNodes) + else: + ChildNodes.append(Node) + Nodes = ChildNodes + ChildNodes = [] + Index += 1 + + return Nodes + + +## Get a single XML node using XPath style syntax. +# +# Return a single XML DOM node from the root Dom specified by XPath String. +# If the input Dom or String is not valid, then an empty string is returned. +# +# @param Dom The root XML DOM node. +# @param String A XPath style path. +# +# @revel Node A single XML node matching XPath style Sting. +# +def XmlNode(Dom, String): + if String == None or String == "" or Dom == None or Dom == "": + return "" + if Dom.nodeType == Dom.DOCUMENT_NODE: + Dom = Dom.documentElement + if String[0] == "/": + String = String[1:] + TagList = String.split('/') + Index = 0 + End = len(TagList) - 1 + ChildNodes = [Dom] + while Index <= End: + for Node in ChildNodes: + if Node.nodeType == Node.ELEMENT_NODE and Node.tagName == TagList[Index]: + if Index < End: + ChildNodes = Node.childNodes + else: + return Node + break + Index += 1 + return "" + + +## Get a single XML element using XPath style syntax. +# +# Return a single XML element from the root Dom specified by XPath String. +# If the input Dom or String is not valid, then an empty string is returned. +# +# @param Dom The root XML DOM object. +# @param Strin A XPath style path. +# +# @revel Element An XML element matching XPath style Sting. +# +def XmlElement(Dom, String): + try: + return XmlNode(Dom, String).firstChild.data.strip() + except: + return "" + + +## Get a single XML element of the current node. +# +# Return a single XML element specified by the current root Dom. +# If the input Dom is not valid, then an empty string is returned. +# +# @param Dom The root XML DOM object. +# +# @revel Element An XML element in current root Dom. +# +def XmlElementData(Dom): + try: + return Dom.firstChild.data.strip() + except: + return "" + + +## Get a list of XML elements using XPath style syntax. +# +# Return a list of XML elements from the root Dom specified by XPath String. +# If the input Dom or String is not valid, then an empty list is returned. +# +# @param Dom The root XML DOM object. +# @param String A XPath style path. +# +# @revel Elements A list of XML elements matching XPath style Sting. +# +def XmlElementList(Dom, String): + return map(XmlElementData, XmlList(Dom, String)) + + +## Get the XML attribute of the current node. +# +# Return a single XML attribute named Attribute from the current root Dom. +# If the input Dom or Attribute is not valid, then an empty string is returned. +# +# @param Dom The root XML DOM object. +# @param Attribute The name of Attribute. +# +# @revel Element A single XML element matching XPath style Sting. +# +def XmlAttribute(Dom, Attribute): + try: + return Dom.getAttribute(Attribute).strip() + except: + return '' + + +## Get the XML node name of the current node. +# +# Return a single XML node name from the current root Dom. +# If the input Dom is not valid, then an empty string is returned. +# +# @param Dom The root XML DOM object. +# +# @revel Element A single XML element matching XPath style Sting. +# +def XmlNodeName(Dom): + try: + return Dom.nodeName.strip() + except: + return '' + +## Parse an XML file. +# +# Parse the input XML file named FileName and return a XML DOM it stands for. +# If the input File is not a valid XML file, then an empty string is returned. +# +# @param FileName The XML file name. +# +# @revel Dom The Dom object achieved from the XML file. +# +def XmlParseFile(FileName): + try: + XmlFile = open(FileName) + Dom = xml.dom.minidom.parse(XmlFile) + XmlFile.close() + return Dom + except Exception, X: + print X + return "" + +# This acts like the main() function for the script, unless it is 'import'ed +# into another script. +if __name__ == '__main__': + # Nothing to do here. Could do some unit tests. + A = CreateXmlElement('AAA', 'CCC', [['AAA', '111'], ['BBB', '222']], [['A', '1'], ['B', '2']]) + B = CreateXmlElement('ZZZ', 'CCC', [['XXX', '111'], ['YYY', '222']], [['A', '1'], ['B', '2']]) + C = CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG']) + print C.toprettyxml(indent = " ") + pass diff --git a/BaseTools/Source/Python/Ecc/Xml/__init__.py b/BaseTools/Source/Python/Ecc/Xml/__init__.py new file mode 100644 index 0000000000..5d268d990b --- /dev/null +++ b/BaseTools/Source/Python/Ecc/Xml/__init__.py @@ -0,0 +1,20 @@ +## @file +# Python 'Library' package initialization file. +# +# This file is required to make Python interpreter treat the directory +# as containing package. +# +# Copyright (c) 2011, 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. +# + +''' +Xml +''' \ No newline at end of file diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 358215d662..d3d50b638e 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -50,6 +50,7 @@ from Common.String import NormPath import Common.GlobalData as GlobalData from Common.Expression import * from Common import GlobalData +from Common.String import ReplaceMacro import re import os @@ -528,25 +529,35 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected include file name", self.FileName, self.CurrentLineNumber) IncFileName = self.__Token - if not os.path.isabs(IncFileName): - if IncFileName.startswith('$(WORKSPACE)'): - Str = IncFileName.replace('$(WORKSPACE)', os.environ.get('WORKSPACE')) - if os.path.exists(Str): - if not os.path.isabs(Str): - Str = os.path.abspath(Str) - IncFileName = Str - else: - # file is in the same dir with FDF file - FullFdf = self.FileName - if not os.path.isabs(self.FileName): - FullFdf = os.path.join(os.environ.get('WORKSPACE'), self.FileName) - - IncFileName = os.path.join(os.path.dirname(FullFdf), IncFileName) - - if not os.path.exists(os.path.normpath(IncFileName)): - raise Warning("Include file not exists", self.FileName, self.CurrentLineNumber) + __IncludeMacros = {} + __IncludeMacros['WORKSPACE'] = InputMacroDict['WORKSPACE'] + __IncludeMacros['ECP_SOURCE'] = InputMacroDict['ECP_SOURCE'] + __IncludeMacros['EFI_SOURCE'] = InputMacroDict['EFI_SOURCE'] + __IncludeMacros['EDK_SOURCE'] = InputMacroDict['EDK_SOURCE'] + + IncludedFile = NormPath(ReplaceMacro(IncFileName, __IncludeMacros, RaiseError=True)) + # + # First search the include file under the same directory as FDF file + # + IncludedFile1 = PathClass(IncludedFile, os.path.dirname(self.FileName)) + ErrorCode = IncludedFile1.Validate()[0] + if ErrorCode != 0: + # + # Then search the include file under the same directory as DSC file + # + IncludedFile1 = PathClass(IncludedFile, GenFdsGlobalVariable.ActivePlatform.Dir) + ErrorCode = IncludedFile1.Validate()[0] + if ErrorCode != 0: + # + # Also search file under the WORKSPACE directory + # + IncludedFile1 = PathClass(IncludedFile, GlobalData.gWorkspace) + ErrorCode = IncludedFile1.Validate()[0] + if ErrorCode != 0: + raise Warning("The include file does not exist under below directories: \n%s\n%s\n%s\n"%(os.path.dirname(self.FileName), GenFdsGlobalVariable.ActivePlatform.Dir, GlobalData.gWorkspace), + self.FileName, self.CurrentLineNumber) - IncFileProfile = IncludeFileProfile(os.path.normpath(IncFileName)) + IncFileProfile = IncludeFileProfile(IncludedFile1.Path) CurrentLine = self.CurrentLineNumber CurrentOffset = self.CurrentOffsetWithinLine @@ -2942,6 +2953,9 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected FV name", self.FileName, self.CurrentLineNumber) + if self.__Token.upper() not in self.Profile.FvDict.keys(): + raise Warning("FV name does not exist", self.FileName, self.CurrentLineNumber) + CapsuleFv = CapsuleData.CapsuleFv() CapsuleFv.FvName = self.__Token CapsuleObj.CapsuleDataList.append(CapsuleFv) @@ -2967,6 +2981,9 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected FD name", self.FileName, self.CurrentLineNumber) + if self.__Token.upper() not in self.Profile.FdDict.keys(): + raise Warning("FD name does not exist", self.FileName, self.CurrentLineNumber) + CapsuleFd = CapsuleData.CapsuleFd() CapsuleFd.FdName = self.__Token CapsuleObj.CapsuleDataList.append(CapsuleFd) diff --git a/BaseTools/Source/Python/Makefile b/BaseTools/Source/Python/Makefile index f6890787ee..a1a0a5e639 100644 --- a/BaseTools/Source/Python/Makefile +++ b/BaseTools/Source/Python/Makefile @@ -27,7 +27,6 @@ COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\Database.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\DataType.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\DecClassObject.py \ - $(BASE_TOOLS_PATH)\Source\Python\Common\DecClassObjectLight.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\Dictionary.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\DscClassObject.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\EdkIIWorkspace.py \ @@ -38,7 +37,6 @@ COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\GlobalData.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\Identification.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\InfClassObject.py \ - $(BASE_TOOLS_PATH)\Source\Python\Common\InfClassObjectLight.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\MigrationUtilities.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\Misc.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\Parsing.py \ @@ -46,8 +44,6 @@ COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\TargetTxtClassObject.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\ToolDefClassObject.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\VpdInfoFile.py \ - $(BASE_TOOLS_PATH)\Source\Python\Common\XmlParser.py \ - $(BASE_TOOLS_PATH)\Source\Python\Common\XmlRoutines.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\__init__.py \ $(BASE_TOOLS_PATH)\Source\Python\Common\BuildVersion.py \ $(BASE_TOOLS_PATH)\Source\Python\Workspace\BuildClassObject.py \ @@ -65,6 +61,7 @@ COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \ $(BASE_TOOLS_PATH)\Source\Python\Autogen\UniClassObject.py \ $(BASE_TOOLS_PATH)\Source\Python\Autogen\__init__.py +UPT_BUILDVERSION_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\UPT\BuildVersion.py all: SetPythonPath $(APPLICATIONS) @@ -104,7 +101,7 @@ $(BIN_DIR)\PatchPcdValue.exe: $(BASE_TOOLS_PATH)\Source\Python\PatchPcdValue\Pat $(BIN_DIR)\BPDG.exe: $(BASE_TOOLS_PATH)\Source\Python\BPDG\BPDG.py $(COMMON_PYTHON) @pushd . & @cd BPDG & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) BPDG.py & @popd -$(BIN_DIR)\UPT.exe: $(BASE_TOOLS_PATH)\Source\Python\UPT\UPT.py $(BASE_TOOLS_PATH)\Source\Python\UPT\UPT.py $(COMMON_PYTHON) +$(BIN_DIR)\UPT.exe: $(BASE_TOOLS_PATH)\Source\Python\UPT\UPT.py $(UPT_BUILDVERSION_PYTHON) @pushd . & @cd UPT & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) UPT.py & @popd clean: diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py index c5e9ee2f0d..34f6284a87 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -37,7 +37,9 @@ gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILI ## Regular expression for matching "#pragma pack" gPragmaPattern = re.compile("^\s*#pragma\s+pack", re.MULTILINE) ## Regular expression for matching HEX number -gHexNumberPattern = re.compile("0[xX]([0-9a-fA-F]+)") +gHexNumberPattern = re.compile("(0[xX])([0-9a-fA-F]+)U?") +## Regular expression for matching decimal number with 'U' postfix +gDecNumberPattern = re.compile("([0-9]+)U") ## Regular expression for matching "Include ()" in asl file gAslIncludePattern = re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE) ## Regular expression for matching C style #include "XXX.asl" in asl file @@ -169,10 +171,15 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong): # convert HEX number format if indicated if ConvertHex: - Line = gHexNumberPattern.sub(r"0\1h", Line) + Line = gHexNumberPattern.sub(r"0\2h", Line) + else: + Line = gHexNumberPattern.sub(r"\1\2", Line) if TrimLong: Line = gLongNumberPattern.sub(r"\1", Line) + # convert Decimal number format + Line = gDecNumberPattern.sub(r"\1", Line) + if LineNumber != None: EdkLogger.verbose("Got line directive: line=%d" % LineNumber) # in case preprocessor removed some lines, like blank or comment lines diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source/Python/UPT/BuildVersion.py new file mode 100644 index 0000000000..4bb9a8b521 --- /dev/null +++ b/BaseTools/Source/Python/UPT/BuildVersion.py @@ -0,0 +1,3 @@ +#This file is for build version number auto generation +# +gBUILD_VERSION = "Build 2423" diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source/Python/UPT/Library/Misc.py index 658c4e0cfb..b67cd102d1 100644 --- a/BaseTools/Source/Python/UPT/Library/Misc.py +++ b/BaseTools/Source/Python/UPT/Library/Misc.py @@ -834,6 +834,59 @@ def ProcessLineExtender(LineList): return NewList +## ProcessEdkComment +# +# Process EDK style comment in LineList: c style /* */ comment or cpp style // comment +# +# +# @param LineList The LineList need to be processed. +# +# @return LineList The LineList been processed. +# @return FirstPos Where Edk comment is first found, -1 if not found +# +def ProcessEdkComment(LineList): + FindEdkBlockComment = False + Count = 0 + StartPos = -1 + EndPos = -1 + FirstPos = -1 + + while(Count < len(LineList)): + Line = LineList[Count].strip() + if Line.startswith("/*"): + # + # handling c style comment + # + StartPos = Count + while Count < len(LineList): + Line = LineList[Count].strip() + if Line.endswith("*/"): + if (Count == StartPos) and Line.strip() == '/*/': + Count = Count + 1 + continue + EndPos = Count + FindEdkBlockComment = True + break + Count = Count + 1 + + if FindEdkBlockComment: + if FirstPos == -1: + FirstPos = StartPos + for Index in xrange(StartPos, EndPos+1): + LineList[Index] = '' + FindEdkBlockComment = False + elif Line.find("//") != -1: + # + # handling cpp style comment + # + LineList[Count] = Line.replace("//", '#') + if FirstPos == -1: + FirstPos = Count + + Count = Count + 1 + + return LineList, FirstPos + ## GetLibInstanceInfo # # Get the information from Library Instance INF file. diff --git a/BaseTools/Source/Python/UPT/Logger/StringTable.py b/BaseTools/Source/Python/UPT/Logger/StringTable.py index 230c659189..063ca52d2b 100644 --- a/BaseTools/Source/Python/UPT/Logger/StringTable.py +++ b/BaseTools/Source/Python/UPT/Logger/StringTable.py @@ -196,6 +196,7 @@ ERR_INF_PARSER_VER_EXIST_BOTH_NUM_STR = \ _("The INF file %s defines both VERSION_NUMBER and VERSION_STRING, " "using VERSION_STRING") ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF = _("EDKI INF is not supported") +ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII = _("The EDKI style comment is not supported in EDKII modules") ERR_INF_PARSER_FEATUREPCD_USAGE_INVALID = _("The usage for FeaturePcd can only" " be type of \"CONSUMES\".") diff --git a/BaseTools/Source/Python/UPT/Makefile b/BaseTools/Source/Python/UPT/Makefile index a6e3a6dd41..d4eef45196 100644 --- a/BaseTools/Source/Python/UPT/Makefile +++ b/BaseTools/Source/Python/UPT/Makefile @@ -24,14 +24,14 @@ SOURCES_PATH = . APPLICATIONS=$(BIN_DIR)\UPT.exe -COMMON_PYTHON=$(SOURCES_PATH)\UPT.py +UPT_BUILDVERSION_PYTHON=$(SOURCES_PATH)\BuildVersion.py all: SetPythonPath $(APPLICATIONS) SetPythonPath: set PYTHONPATH= $(SOURCES_PATH) -$(BIN_DIR)\UPT.exe: $(SOURCES_PATH)\UPT.py $(COMMON_PYTHON) +$(BIN_DIR)\UPT.exe: $(SOURCES_PATH)\UPT.py $(UPT_BUILDVERSION_PYTHON) @pushd . & @cd build & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) UPT.py & @popd @pushd . & @copy .\Dll\sqlite3.dll .\Bin\Sqlite3.dll & @popd clean: diff --git a/BaseTools/Source/Python/UPT/Parser/InfParser.py b/BaseTools/Source/Python/UPT/Parser/InfParser.py index aa44e8038d..79f71448ee 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfParser.py @@ -26,6 +26,7 @@ from copy import deepcopy from Library.String import GetSplitValueList from Library.String import ConvertSpecialChar from Library.Misc import ProcessLineExtender +from Library.Misc import ProcessEdkComment from Library.Parsing import NormPath from Library.ParserValidate import IsValidInfMoudleTypeList from Library.ParserValidate import IsValidArch @@ -164,6 +165,12 @@ class InfParser(InfSectionParser): # FileLinesList = ProcessLineExtender(FileLinesList) + # + # Process EdkI INF style comment if found + # + OrigLines = [Line for Line in FileLinesList] + FileLinesList, EdkCommentStartPos = ProcessEdkComment(FileLinesList) + # # Judge whether the INF file is Binary INF or not # @@ -338,6 +345,17 @@ class InfParser(InfSectionParser): ST.ERR_INF_PARSER_HEADER_MISSGING, File=self.FullPath) + # + # EDKII INF should not have EDKI style comment + # + if EdkCommentStartPos != -1: + Logger.Error("InfParser", + FORMAT_INVALID, + ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII, + File=self.FullPath, + Line=EdkCommentStartPos + 1, + ExtraData=OrigLines[EdkCommentStartPos]) + # # extract [Event] [Hob] [BootMode] sections # diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/UPT/UPT.py index a9066a259a..b168a51daa 100644 --- a/BaseTools/Source/Python/UPT/UPT.py +++ b/BaseTools/Source/Python/UPT/UPT.py @@ -43,7 +43,7 @@ import RmPkg from Library.Misc import CheckEnvVariable from Library import GlobalData from Core.IpiDb import IpiDatabase -from Common.BuildVersion import gBUILD_VERSION +from BuildVersion import gBUILD_VERSION ## # Version and Copyright diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index bfa7054396..d907b11ba1 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -769,7 +769,7 @@ class DscParser(MetaFileParser): self._InSubsection = False self._SubsectionType = MODEL_UNKNOWN self._SubsectionName = '' - self._Owner.pop() + self._Owner[-1] = -1 continue # subsection header elif Line[0] == TAB_OPTION_START and Line[-1] == TAB_OPTION_END: @@ -1247,19 +1247,48 @@ class DscParser(MetaFileParser): MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF]: break elif self._ItemType == MODEL_META_DATA_INCLUDE: - # The included file must be relative to workspace - IncludedFile = NormPath(ReplaceMacro(self._ValueList[1], self._Macros, RaiseError=True)) - IncludedFile = PathClass(IncludedFile, GlobalData.gWorkspace) - ErrorCode, ErrorInfo = IncludedFile.Validate() + # The included file must be relative to workspace or same directory as DSC file + __IncludeMacros = {} + # + # Allow using system environment variables in path after !include + # + __IncludeMacros['WORKSPACE'] = GlobalData.gGlobalDefines['WORKSPACE'] + if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys(): + __IncludeMacros['ECP_SOURCE'] = GlobalData.gGlobalDefines['ECP_SOURCE'] + # + # During GenFds phase call DSC parser, will go into this branch. + # + elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys(): + __IncludeMacros['ECP_SOURCE'] = GlobalData.gCommandLineDefines['ECP_SOURCE'] + + __IncludeMacros['EFI_SOURCE'] = GlobalData.gGlobalDefines['EFI_SOURCE'] + __IncludeMacros['EDK_SOURCE'] = GlobalData.gGlobalDefines['EDK_SOURCE'] + # + # 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 + # + IncludedFile1 = PathClass(IncludedFile, self.MetaFile.Dir) + ErrorCode, ErrorInfo1 = IncludedFile1.Validate() if ErrorCode != 0: - EdkLogger.error('parser', ErrorCode, File=self._FileWithError, - Line=self._LineIndex+1, ExtraData=ErrorInfo) + # + # Also search file under the WORKSPACE directory + # + 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) - self._FileWithError = IncludedFile + self._FileWithError = IncludedFile1 - IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile, MODEL_FILE_DSC, False) + IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False) Owner = self._Content[self._ContentIndex-1][0] - Parser = DscParser(IncludedFile, self._FileType, IncludedFileTable, + Parser = DscParser(IncludedFile1, self._FileType, IncludedFileTable, Owner=Owner, From=Owner) # set the parser status with current status @@ -1280,7 +1309,10 @@ class DscParser(MetaFileParser): Records = IncludedFileTable.GetAll() if Records: self._Content[self._ContentIndex:self._ContentIndex] = Records - + 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]