From 756ad8f8e9d3e345f1883546e2a3125203e234aa Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 3 Aug 2010 03:29:17 +0000 Subject: Sync EDKII BaseTools to BaseTools project r2006. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10764 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Bin/Win32/BootSectImage.exe | Bin 393216 -> 393216 bytes BaseTools/Bin/Win32/EfiLdrImage.exe | Bin 421888 -> 421888 bytes BaseTools/Bin/Win32/EfiRom.exe | Bin 446464 -> 446464 bytes BaseTools/Bin/Win32/GenBootSector.exe | Bin 425984 -> 425984 bytes BaseTools/Bin/Win32/GenCrc32.exe | Bin 425984 -> 425984 bytes BaseTools/Bin/Win32/GenFfs.exe | Bin 430080 -> 430080 bytes BaseTools/Bin/Win32/GenFv.exe | Bin 479232 -> 479232 bytes BaseTools/Bin/Win32/GenFw.exe | Bin 495616 -> 495616 bytes BaseTools/Bin/Win32/GenPage.exe | Bin 421888 -> 421888 bytes BaseTools/Bin/Win32/GenSec.exe | Bin 446464 -> 446464 bytes BaseTools/Bin/Win32/GenVtf.exe | Bin 446464 -> 446464 bytes BaseTools/Bin/Win32/LzmaCompress.exe | Bin 397312 -> 397312 bytes BaseTools/Bin/Win32/Split.exe | Bin 425984 -> 425984 bytes BaseTools/Bin/Win32/TianoCompress.exe | Bin 434176 -> 434176 bytes BaseTools/Bin/Win32/VfrCompile.exe | Bin 1187840 -> 1187840 bytes BaseTools/Bin/Win32/VolInfo.exe | Bin 471040 -> 471040 bytes BaseTools/Bin/Win32/build.exe | Bin 2616692 -> 2617426 bytes BaseTools/Conf/build_rule.template | 2 +- BaseTools/Source/C/GenFw/Elf32Convert.c | 63 +++++++++- BaseTools/Source/C/GenFw/elf_common.h | 34 ++++++ BaseTools/Source/Python/AutoGen/GenC.py | 2 +- BaseTools/Source/Python/AutoGen/GenMake.py | 3 +- BaseTools/Source/Python/AutoGen/StrGather.py | 26 ++-- BaseTools/Source/Python/AutoGen/UniClassObject.py | 140 ++++++++++++---------- 24 files changed, 199 insertions(+), 71 deletions(-) diff --git a/BaseTools/Bin/Win32/BootSectImage.exe b/BaseTools/Bin/Win32/BootSectImage.exe index 433d8de..0ddaa55 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 ab8e438..d18067e 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 7c2fd61..700e3ba 100755 Binary files a/BaseTools/Bin/Win32/EfiRom.exe and b/BaseTools/Bin/Win32/EfiRom.exe differ diff --git a/BaseTools/Bin/Win32/GenBootSector.exe b/BaseTools/Bin/Win32/GenBootSector.exe index 3e37a4f..0dac396 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 bd6ba31..6bac0d0 100755 Binary files a/BaseTools/Bin/Win32/GenCrc32.exe and b/BaseTools/Bin/Win32/GenCrc32.exe differ diff --git a/BaseTools/Bin/Win32/GenFfs.exe b/BaseTools/Bin/Win32/GenFfs.exe index 9148751..e7dae7a 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 fade8ee..2401013 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 0130d63..6ec43f4 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 5850eed..8a03a51 100755 Binary files a/BaseTools/Bin/Win32/GenPage.exe and b/BaseTools/Bin/Win32/GenPage.exe differ diff --git a/BaseTools/Bin/Win32/GenSec.exe b/BaseTools/Bin/Win32/GenSec.exe index d3eb98e..9cd22fe 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 98f677a..ab2b374 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 34f753c..edca459 100755 Binary files a/BaseTools/Bin/Win32/LzmaCompress.exe and b/BaseTools/Bin/Win32/LzmaCompress.exe differ diff --git a/BaseTools/Bin/Win32/Split.exe b/BaseTools/Bin/Win32/Split.exe index b73d3d1..0ff1301 100755 Binary files a/BaseTools/Bin/Win32/Split.exe and b/BaseTools/Bin/Win32/Split.exe differ diff --git a/BaseTools/Bin/Win32/TianoCompress.exe b/BaseTools/Bin/Win32/TianoCompress.exe index 728af8b..f106424 100755 Binary files a/BaseTools/Bin/Win32/TianoCompress.exe and b/BaseTools/Bin/Win32/TianoCompress.exe differ diff --git a/BaseTools/Bin/Win32/VfrCompile.exe b/BaseTools/Bin/Win32/VfrCompile.exe index 7885c56..daf66f2 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 3a6b1e9..a470075 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 d73c4fa..54a3239 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 139289e..70f510a 100644 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -413,7 +413,7 @@ cd $(OUTPUT_DIR)(+)${s_dir} - "$(ASM16)" /nologo /c /omf /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj ${src} + "$(ASM16)" /nologo /c /omf $(INC) /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj ${src} "$(ASMLINK)" $(ASMLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj,${dst},,,, diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index 9e4a9a2..539fdf5 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -632,6 +632,7 @@ WriteSections32 ( switch (ELF32_R_TYPE(Rel->r_info)) { case R_ARM_RBASE: // No relocation - no action required + // break skipped case R_ARM_PC24: case R_ARM_XPC25: @@ -639,6 +640,35 @@ WriteSections32 ( case R_ARM_THM_JUMP19: case R_ARM_CALL: case R_ARM_JMP24: + case R_ARM_THM_JUMP24: + case R_ARM_PREL31: + case R_ARM_MOVW_PREL_NC: + case R_ARM_MOVT_PREL: + case R_ARM_THM_MOVW_PREL_NC: + case R_ARM_THM_MOVT_PREL: + case R_ARM_THM_JMP6: + case R_ARM_THM_ALU_PREL_11_0: + case R_ARM_THM_PC12: + case R_ARM_REL32_NOI: + case R_ARM_ALU_PC_G0_NC: + case R_ARM_ALU_PC_G0: + case R_ARM_ALU_PC_G1_NC: + case R_ARM_ALU_PC_G1: + case R_ARM_ALU_PC_G2: + case R_ARM_LDR_PC_G1: + case R_ARM_LDR_PC_G2: + case R_ARM_LDRS_PC_G0: + case R_ARM_LDRS_PC_G1: + case R_ARM_LDRS_PC_G2: + case R_ARM_LDC_PC_G0: + case R_ARM_LDC_PC_G1: + case R_ARM_LDC_PC_G2: + case R_ARM_GOT_PREL: + case R_ARM_THM_JUMP11: + case R_ARM_THM_JUMP8: + case R_ARM_TLS_GD32: + case R_ARM_TLS_LDM32: + case R_ARM_TLS_IE32: // Thease are all PC-relative relocations and don't require modification // GCC does not seem to have the concept of a application that just needs to get relocated. break; @@ -736,14 +766,45 @@ WriteRelocations32 ( } } else if (mEhdr->e_machine == EM_ARM) { switch (ELF32_R_TYPE(Rel->r_info)) { - case R_ARM_RBASE: + case R_ARM_RBASE: // No relocation - no action required + // break skipped + case R_ARM_PC24: case R_ARM_XPC25: case R_ARM_THM_PC22: case R_ARM_THM_JUMP19: case R_ARM_CALL: case R_ARM_JMP24: + case R_ARM_THM_JUMP24: + case R_ARM_PREL31: + case R_ARM_MOVW_PREL_NC: + case R_ARM_MOVT_PREL: + case R_ARM_THM_MOVW_PREL_NC: + case R_ARM_THM_MOVT_PREL: + case R_ARM_THM_JMP6: + case R_ARM_THM_ALU_PREL_11_0: + case R_ARM_THM_PC12: + case R_ARM_REL32_NOI: + case R_ARM_ALU_PC_G0_NC: + case R_ARM_ALU_PC_G0: + case R_ARM_ALU_PC_G1_NC: + case R_ARM_ALU_PC_G1: + case R_ARM_ALU_PC_G2: + case R_ARM_LDR_PC_G1: + case R_ARM_LDR_PC_G2: + case R_ARM_LDRS_PC_G0: + case R_ARM_LDRS_PC_G1: + case R_ARM_LDRS_PC_G2: + case R_ARM_LDC_PC_G0: + case R_ARM_LDC_PC_G1: + case R_ARM_LDC_PC_G2: + case R_ARM_GOT_PREL: + case R_ARM_THM_JUMP11: + case R_ARM_THM_JUMP8: + case R_ARM_TLS_GD32: + case R_ARM_TLS_LDM32: + case R_ARM_TLS_IE32: // Thease are all PC-relative relocations and don't require modification break; diff --git a/BaseTools/Source/C/GenFw/elf_common.h b/BaseTools/Source/C/GenFw/elf_common.h index d53f98b..9618d48 100644 --- a/BaseTools/Source/C/GenFw/elf_common.h +++ b/BaseTools/Source/C/GenFw/elf_common.h @@ -602,6 +602,38 @@ typedef struct { #define R_ARM_THM_MOVW_ABS_NC 47 #define R_ARM_THM_MOVT_ABS 48 +// Block of PC-relative relocations added to work around gcc putting +// object relocations in static executables. +#define R_ARM_THM_JUMP24 30 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 +#define R_ARM_THM_JMP6 52 +#define R_ARM_THM_ALU_PREL_11_0 53 +#define R_ARM_THM_PC12 54 +#define R_ARM_REL32_NOI 56 +#define R_ARM_ALU_PC_G0_NC 57 +#define R_ARM_ALU_PC_G0 58 +#define R_ARM_ALU_PC_G1_NC 59 +#define R_ARM_ALU_PC_G1 60 +#define R_ARM_ALU_PC_G2 61 +#define R_ARM_LDR_PC_G1 62 +#define R_ARM_LDR_PC_G2 63 +#define R_ARM_LDRS_PC_G0 64 +#define R_ARM_LDRS_PC_G1 65 +#define R_ARM_LDRS_PC_G2 66 +#define R_ARM_LDC_PC_G0 67 +#define R_ARM_LDC_PC_G1 68 +#define R_ARM_LDC_PC_G2 69 +#define R_ARM_GOT_PREL 96 +#define R_ARM_THM_JUMP11 102 +#define R_ARM_THM_JUMP8 103 +#define R_ARM_TLS_GD32 104 +#define R_ARM_TLS_LDM32 105 +#define R_ARM_TLS_IE32 107 + #define R_ARM_THM_JUMP19 51 #define R_ARM_GNU_VTENTRY 100 #define R_ARM_GNU_VTINHERIT 101 @@ -612,6 +644,8 @@ typedef struct { #define R_ARM_RPC24 254 #define R_ARM_RBASE 255 + + /* Name Value Field Calculation */ #define R_IA_64_NONE 0 /* None */ #define R_IA_64_IMM14 0x21 /* immediate14 S + A */ diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index f0f92b0..1db68eb 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1888,7 +1888,7 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenBinBuff else: ShellMode = False - Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer) + Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, Info.IncludePathList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer) if CompatibleMode or UniGenCFlag: AutoGenC.Append("\n//\n//Unicode String Pack Definition\n//\n") AutoGenC.Append(Code) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index e3f5c2b..2e18f67 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -26,7 +26,7 @@ from BuildEngine import * import Common.GlobalData as GlobalData ## Regular expression for finding header file inclusions -gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:[\"<]?[ \t]*)([\w.\\/]+)(?:[ \t]*[\">]?)", re.MULTILINE|re.UNICODE) +gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:[\"<]?[ \t]*)([\w.\\/() \t]+)(?:[ \t]*[\">]?)", re.MULTILINE|re.UNICODE|re.IGNORECASE) ## Regular expression for matching macro used in header file inclusion gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE) @@ -754,6 +754,7 @@ cleanlib: CurrentFilePath = F.Dir for Inc in IncludedFileList: + Inc = Inc.strip() # if there's macro used to reference header file, expand it HeaderList = gMacroPattern.findall(Inc) if len(HeaderList) == 1 and len(HeaderList[0]) == 2: diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index 1759da7..52ab439 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -1,4 +1,4 @@ -# Copyright (c) 2007, Intel Corporation. All rights reserved.
+# 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 @@ -168,6 +168,8 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): Str = WriteLine(Str, Line) Line = COMMENT_DEFINE_STR + ' ' + PRINTABLE_LANGUAGE_NAME_STRING_NAME + ' ' * (ValueStartPtr - len(DEFINE_STR + PRINTABLE_LANGUAGE_NAME_STRING_NAME)) + DecToHexStr(1, 4) + COMMENT_NOT_REFERENCED Str = WriteLine(Str, Line) + + #Group the referred STRING token together. for Index in range(2, len(UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]])): StringItem = UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]][Index] Name = StringItem.StringName @@ -180,12 +182,22 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): Line = DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(Token, 4) else: Line = DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) - else: + Str = WriteLine(Str, Line) + + #Group the unused STRING token together. + for Index in range(2, len(UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]])): + StringItem = UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]][Index] + Name = StringItem.StringName + Token = StringItem.Token + Referenced = StringItem.Referenced + if Name != None: + Line = '' + if Referenced == False: if (ValueStartPtr - len(DEFINE_STR + Name)) <= 0: Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED else: Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED - Str = WriteLine(Str, Line) + Str = WriteLine(Str, Line) Str = WriteLine(Str, '') if IsCompatibleMode or UniGenCFlag: @@ -506,7 +518,7 @@ def SearchString(UniObjectClass, FileList, IsCompatibleMode): # This function is used for UEFI2.1 spec # # -def GetStringFiles(UniFilList, SourceFileList, IncludeList, SkipList, BaseName, IsCompatibleMode = False, ShellMode = False, UniGenCFlag = True, UniGenBinBuffer = None): +def GetStringFiles(UniFilList, SourceFileList, IncludeList, IncludePathList, SkipList, BaseName, IsCompatibleMode = False, ShellMode = False, UniGenCFlag = True, UniGenBinBuffer = None): Status = True ErrorMessage = '' @@ -515,15 +527,15 @@ def GetStringFiles(UniFilList, SourceFileList, IncludeList, SkipList, BaseName, # # support ISO 639-2 codes in .UNI files of EDK Shell # - Uni = UniFileClassObject(UniFilList, True) + Uni = UniFileClassObject(sorted (UniFilList), True, IncludePathList) else: - Uni = UniFileClassObject(UniFilList, IsCompatibleMode) + Uni = UniFileClassObject(sorted (UniFilList), IsCompatibleMode, IncludePathList) else: EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, 'No unicode files given') FileList = GetFileList(SourceFileList, IncludeList, SkipList) - Uni = SearchString(Uni, FileList, IsCompatibleMode) + Uni = SearchString(Uni, sorted (FileList), IsCompatibleMode) HFile = CreateHFile(BaseName, Uni, IsCompatibleMode, UniGenCFlag) CFile = None diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 8f929a3..76a0549 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -177,18 +177,24 @@ class StringDefClassObject(object): repr(self.StringValue) + ' ' + \ repr(self.UseOtherLangDef) + def UpdateValue(self, Value = None): + if Value != None: + self.StringValue = Value + u'\x00' # Add a NULL at string tail + self.StringValueByteList = UniToHexList(self.StringValue) + self.Length = len(self.StringValueByteList) + ## UniFileClassObject # # A structure for .uni file definition # class UniFileClassObject(object): - def __init__(self, FileList = [], IsCompatibleMode = False): + def __init__(self, FileList = [], IsCompatibleMode = False, IncludePathList = []): self.FileList = FileList self.Token = 2 self.LanguageDef = [] #[ [u'LanguageIdentifier', u'PrintableName'], ... ] self.OrderedStringList = {} #{ u'LanguageIdentifier' : [StringDefClassObject] } self.IsCompatibleMode = IsCompatibleMode - + self.IncludePathList = IncludePathList if len(self.FileList) > 0: self.LoadUniFiles(FileList) @@ -226,6 +232,21 @@ class UniFileClassObject(object): self.AddStringToList(u'$LANGUAGE_NAME', LangName, LangName, 0, True, Index=0) self.AddStringToList(u'$PRINTABLE_LANGUAGE_NAME', LangName, LangPrintName, 1, True, Index=1) + if not IsLangInDef: + # + # The found STRING tokens will be added into new language string list + # so that the unique STRING identifier is reserved for all languages in the package list. + # + FirstLangName = self.LanguageDef[0][0] + if LangName != FirstLangName: + for Index in range (2, len (self.OrderedStringList[FirstLangName])): + Item = self.OrderedStringList[FirstLangName][Index] + if Item.UseOtherLangDef != '': + OtherLang = Item.UseOtherLangDef + else: + OtherLang = FirstLangName + self.OrderedStringList[LangName].append (StringDefClassObject(Item.StringName, '', Item.Referenced, Item.Token, OtherLang)) + return True # @@ -266,7 +287,6 @@ class UniFileClassObject(object): if not os.path.exists(File.Path) or not os.path.isfile(File.Path): EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, ExtraData=File.Path) - Dir = File.Dir try: FileIn = codecs.open(File.Path, mode='rb', encoding='utf-16').readlines() except UnicodeError, X: @@ -309,7 +329,13 @@ class UniFileClassObject(object): IncList = gIncludePattern.findall(Line) if len(IncList) == 1: - Lines.extend(self.PreProcess(PathClass(str(IncList[0]), Dir))) + for Dir in [File.Dir] + self.IncludePathList: + IncFile = PathClass(str(IncList[0]), Dir) + if os.path.isfile(IncFile.Path): + Lines.extend(self.PreProcess(IncFile)) + break + else: + EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, Message="Cannot find include file", ExtraData=str(IncList[0])) continue Lines.append(Line) @@ -421,15 +447,30 @@ class UniFileClassObject(object): if Language not in self.OrderedStringList: self.OrderedStringList[Language] = [] - IsAdded = False + IsAdded = True for Item in self.OrderedStringList[Language]: if Name == Item.StringName: - IsAdded = True + IsAdded = False + if Value != None: + Item.UpdateValue(Value) + Item.UseOtherLangDef = '' break - if not IsAdded: + + if IsAdded: Token = len(self.OrderedStringList[Language]) if Index == -1: self.OrderedStringList[Language].append(StringDefClassObject(Name, Value, Referenced, Token, UseOtherLangDef)) + for LangName in self.LanguageDef: + # + # New STRING token will be added into all language string lists. + # so that the unique STRING identifier is reserved for all languages in the package list. + # + if LangName[0] != Language: + if UseOtherLangDef != '': + OtherLangDef = UseOtherLangDef + else: + OtherLangDef = Language + self.OrderedStringList[LangName[0]].append(StringDefClassObject(Name, '', Referenced, Token, OtherLangDef)) else: self.OrderedStringList[Language].insert(Index, StringDefClassObject(Name, Value, Referenced, Token, UseOtherLangDef)) @@ -437,11 +478,15 @@ class UniFileClassObject(object): # Set the string as referenced # def SetStringReferenced(self, Name): - for Lang in self.OrderedStringList: - for Item in self.OrderedStringList[Lang]: - if Name == Item.StringName: - Item.Referenced = True - break + # + # String stoken are added in the same order in all language string lists. + # So, only update the status of string stoken in first language string list. + # + Lang = self.LanguageDef[0][0] + for Item in self.OrderedStringList[Lang]: + if Name == Item.StringName: + Item.Referenced = True + break # # Search the string in language definition by Name # @@ -467,61 +512,36 @@ class UniFileClassObject(object): # def ReToken(self): # - # Search each string to find if it is defined for each language - # Use secondary language value to replace if missing in any one language - # - for IndexI in range(0, len(self.LanguageDef)): - LangKey = self.LanguageDef[IndexI][0] - for Item in self.OrderedStringList[LangKey]: - Name = Item.StringName - Value = Item.StringValue[0:-1] - Referenced = Item.Referenced - Index = self.OrderedStringList[LangKey].index(Item) - for IndexJ in range(0, len(self.LanguageDef)): - LangFind = self.LanguageDef[IndexJ][0] - if self.FindStringValue(Name, LangFind) == None: - EdkLogger.debug(EdkLogger.DEBUG_5, Name) - Token = len(self.OrderedStringList[LangFind]) - self.AddStringToList(Name, LangFind, Value, Token, Referenced, LangKey, Index) - # - # Retoken + # Retoken all language strings according to the status of string stoken in the first language string. # - # First re-token the first language - LangName = self.LanguageDef[0][0] - ReferencedStringList = [] - NotReferencedStringList = [] - Token = 0 + FirstLangName = self.LanguageDef[0][0] # - # Order UNI token by their String Name + # Use small token for all referred string stoken. # - StringNameList = [] - for Item in self.OrderedStringList[LangName]: - StringNameList.append (Item.StringName) - StringNameList.sort() - - for Name in StringNameList: - Item = self.FindStringValue (Name, LangName) - if Item.Referenced == True: - Item.Token = Token - ReferencedStringList.append(Item) - Token = Token + 1 - else: - NotReferencedStringList.append(Item) - self.OrderedStringList[LangName] = ReferencedStringList - for Index in range(len(NotReferencedStringList)): - NotReferencedStringList[Index].Token = Token + Index - self.OrderedStringList[LangName].append(NotReferencedStringList[Index]) + RefToken = 0 + for Index in range (0, len (self.OrderedStringList[FirstLangName])): + FirstLangItem = self.OrderedStringList[FirstLangName][Index] + if FirstLangItem.Referenced == True: + for LangNameItem in self.LanguageDef: + LangName = LangNameItem[0] + OtherLangItem = self.OrderedStringList[LangName][Index] + OtherLangItem.Referenced = True + OtherLangItem.Token = RefToken + RefToken = RefToken + 1 # - # Adjust the orders of other languages + # Use big token for all unreferred string stoken. # - for IndexOfLanguage in range(1, len(self.LanguageDef)): - for OrderedString in self.OrderedStringList[LangName]: - for UnOrderedString in self.OrderedStringList[self.LanguageDef[IndexOfLanguage][0]]: - if OrderedString.StringName == UnOrderedString.StringName: - UnOrderedString.Token = OrderedString.Token - break + UnRefToken = 0 + for Index in range (0, len (self.OrderedStringList[FirstLangName])): + FirstLangItem = self.OrderedStringList[FirstLangName][Index] + if FirstLangItem.Referenced == False: + for LangNameItem in self.LanguageDef: + LangName = LangNameItem[0] + OtherLangItem = self.OrderedStringList[LangName][Index] + OtherLangItem.Token = RefToken + UnRefToken + UnRefToken = UnRefToken + 1 # # Show the instance itself -- cgit v1.1