mirror of https://github.com/acidanthera/audk.git
BaseTools/UPT: Replace os.linesep with '\r\n' when generating UNI files.
Replace os.linesep with '\r\n' when generating UNI files to make sure all files are under DOS format. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Gao, Liming <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16041 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
b5fd61fe8c
commit
cf2b2bdef3
|
@ -582,20 +582,17 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||||
ContainerFile = os.path.normpath(os.path.join(os.path.dirname(PackageObject.GetFullPath()),
|
ContainerFile = os.path.normpath(os.path.join(os.path.dirname(PackageObject.GetFullPath()),
|
||||||
(PackageObject.GetBaseName() + '.uni')))
|
(PackageObject.GetBaseName() + '.uni')))
|
||||||
|
|
||||||
Content = UniFileHeader + os.linesep
|
Content = UniFileHeader + '\r\n'
|
||||||
Content += os.linesep
|
Content += '\r\n'
|
||||||
|
|
||||||
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_ABSTRACT, PackageObject.GetAbstract(), ContainerFile) \
|
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_ABSTRACT, PackageObject.GetAbstract(), ContainerFile) + '\r\n'
|
||||||
+ os.linesep
|
|
||||||
|
|
||||||
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_DESCRIPTION, PackageObject.GetDescription(), ContainerFile) \
|
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_DESCRIPTION, PackageObject.GetDescription(), ContainerFile) \
|
||||||
+ os.linesep
|
+ '\r\n'
|
||||||
|
|
||||||
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_ABSTRACT, BinaryAbstract, ContainerFile) \
|
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_ABSTRACT, BinaryAbstract, ContainerFile) + '\r\n'
|
||||||
+ os.linesep
|
|
||||||
|
|
||||||
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_DESCRIPTION, BinaryDescription, ContainerFile) \
|
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_DESCRIPTION, BinaryDescription, ContainerFile) + '\r\n'
|
||||||
+ os.linesep
|
|
||||||
|
|
||||||
PromptGenList = []
|
PromptGenList = []
|
||||||
HelpTextGenList = []
|
HelpTextGenList = []
|
||||||
|
@ -612,7 +609,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||||
if (PcdPromptStrName, Lang) not in PromptGenList:
|
if (PcdPromptStrName, Lang) not in PromptGenList:
|
||||||
TokenValueList.append((Lang, PromptStr))
|
TokenValueList.append((Lang, PromptStr))
|
||||||
PromptGenList.append((PcdPromptStrName, Lang))
|
PromptGenList.append((PcdPromptStrName, Lang))
|
||||||
PromptString = FormatUniEntry(PcdPromptStrName, TokenValueList, ContainerFile) + os.linesep
|
PromptString = FormatUniEntry(PcdPromptStrName, TokenValueList, ContainerFile) + '\r\n'
|
||||||
if PromptString not in Content:
|
if PromptString not in Content:
|
||||||
Content += PromptString
|
Content += PromptString
|
||||||
|
|
||||||
|
@ -628,7 +625,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||||
if (PcdHelpStrName, Lang) not in HelpTextGenList:
|
if (PcdHelpStrName, Lang) not in HelpTextGenList:
|
||||||
TokenValueList.append((Lang, HelpStr))
|
TokenValueList.append((Lang, HelpStr))
|
||||||
HelpTextGenList.append((PcdHelpStrName, Lang))
|
HelpTextGenList.append((PcdHelpStrName, Lang))
|
||||||
HelpTextString = FormatUniEntry(PcdHelpStrName, TokenValueList, ContainerFile) + os.linesep
|
HelpTextString = FormatUniEntry(PcdHelpStrName, TokenValueList, ContainerFile) + '\r\n'
|
||||||
if HelpTextString not in Content:
|
if HelpTextString not in Content:
|
||||||
Content += HelpTextString
|
Content += HelpTextString
|
||||||
|
|
||||||
|
@ -639,7 +636,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||||
PcdErrStrName = '#string ' + TAB_STR_TOKENCNAME + TAB_UNDERLINE_SPLIT + Pcd.GetTokenSpaceGuidCName() \
|
PcdErrStrName = '#string ' + TAB_STR_TOKENCNAME + TAB_UNDERLINE_SPLIT + Pcd.GetTokenSpaceGuidCName() \
|
||||||
+ TAB_UNDERLINE_SPLIT + TAB_STR_TOKENERR \
|
+ TAB_UNDERLINE_SPLIT + TAB_STR_TOKENERR \
|
||||||
+ TAB_UNDERLINE_SPLIT + ErrorNo[2:]
|
+ TAB_UNDERLINE_SPLIT + ErrorNo[2:]
|
||||||
PcdErrString = FormatUniEntry(PcdErrStrName, PcdError.GetErrorMessageList(), ContainerFile) + os.linesep
|
PcdErrString = FormatUniEntry(PcdErrStrName, PcdError.GetErrorMessageList(), ContainerFile) + '\r\n'
|
||||||
if PcdErrString not in Content:
|
if PcdErrString not in Content:
|
||||||
Content += PcdErrString
|
Content += PcdErrString
|
||||||
|
|
||||||
|
|
|
@ -230,22 +230,22 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCOD
|
||||||
if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())):
|
if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())):
|
||||||
os.makedirs(os.path.dirname(ModuleObject.GetFullPath()))
|
os.makedirs(os.path.dirname(ModuleObject.GetFullPath()))
|
||||||
|
|
||||||
Content = UniFileHeader + os.linesep
|
Content = UniFileHeader + '\r\n'
|
||||||
Content += DT.END_OF_LINE
|
Content += '\r\n'
|
||||||
|
|
||||||
Content += FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, ModuleObject.GetAbstract(), ContainerFile) + os.linesep
|
Content += FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, ModuleObject.GetAbstract(), ContainerFile) + '\r\n'
|
||||||
|
|
||||||
Content += FormatUniEntry('#string ' + DT.TAB_INF_DESCRIPTION, ModuleObject.GetDescription(), ContainerFile) \
|
Content += FormatUniEntry('#string ' + DT.TAB_INF_DESCRIPTION, ModuleObject.GetDescription(), ContainerFile) \
|
||||||
+ os.linesep
|
+ '\r\n'
|
||||||
|
|
||||||
BinaryAbstractString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_ABSTRACT, BinaryAbstract, ContainerFile)
|
BinaryAbstractString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_ABSTRACT, BinaryAbstract, ContainerFile)
|
||||||
if BinaryAbstractString:
|
if BinaryAbstractString:
|
||||||
Content += BinaryAbstractString + os.linesep
|
Content += BinaryAbstractString + '\r\n'
|
||||||
|
|
||||||
BinaryDescriptionString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_DESCRIPTION, BinaryDescription, \
|
BinaryDescriptionString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_DESCRIPTION, BinaryDescription, \
|
||||||
ContainerFile)
|
ContainerFile)
|
||||||
if BinaryDescriptionString:
|
if BinaryDescriptionString:
|
||||||
Content += BinaryDescriptionString + os.linesep
|
Content += BinaryDescriptionString + '\r\n'
|
||||||
|
|
||||||
if not os.path.exists(ContainerFile):
|
if not os.path.exists(ContainerFile):
|
||||||
File = codecs.open(ContainerFile, 'wb', Encoding)
|
File = codecs.open(ContainerFile, 'wb', Encoding)
|
||||||
|
|
|
@ -129,45 +129,45 @@ def GenHeaderCommentSection(Abstract, Description, Copyright, License, IsBinaryH
|
||||||
if isinstance(Description, unicode):
|
if isinstance(Description, unicode):
|
||||||
Description = ConvertSpecialUnicodes(Description)
|
Description = ConvertSpecialUnicodes(Description)
|
||||||
if IsBinaryHeader:
|
if IsBinaryHeader:
|
||||||
Content += CommChar * 2 + TAB_SPACE_SPLIT + TAB_BINARY_HEADER_COMMENT + END_OF_LINE
|
Content += CommChar * 2 + TAB_SPACE_SPLIT + TAB_BINARY_HEADER_COMMENT + '\r\n'
|
||||||
elif CommChar == TAB_COMMENT_EDK1_SPLIT:
|
elif CommChar == TAB_COMMENT_EDK1_SPLIT:
|
||||||
Content += CommChar + TAB_SPACE_SPLIT + TAB_COMMENT_EDK1_START + TAB_STAR + TAB_SPACE_SPLIT +\
|
Content += CommChar + TAB_SPACE_SPLIT + TAB_COMMENT_EDK1_START + TAB_STAR + TAB_SPACE_SPLIT +\
|
||||||
TAB_HEADER_COMMENT + END_OF_LINE
|
TAB_HEADER_COMMENT + '\r\n'
|
||||||
else:
|
else:
|
||||||
Content += CommChar * 2 + TAB_SPACE_SPLIT + TAB_HEADER_COMMENT + END_OF_LINE
|
Content += CommChar * 2 + TAB_SPACE_SPLIT + TAB_HEADER_COMMENT + '\r\n'
|
||||||
if Abstract:
|
if Abstract:
|
||||||
Abstract = Abstract.rstrip(END_OF_LINE)
|
Abstract = Abstract.rstrip('\r\n')
|
||||||
Content += CommChar + TAB_SPACE_SPLIT + (END_OF_LINE + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
||||||
(Abstract, END_OF_LINE))
|
(Abstract, '\n'))
|
||||||
Content += END_OF_LINE + CommChar + END_OF_LINE
|
Content += '\r\n' + CommChar + '\r\n'
|
||||||
else:
|
else:
|
||||||
Content += CommChar + END_OF_LINE
|
Content += CommChar + '\r\n'
|
||||||
|
|
||||||
if Description:
|
if Description:
|
||||||
Description = Description.rstrip(END_OF_LINE)
|
Description = Description.rstrip('\r\n')
|
||||||
Content += CommChar + TAB_SPACE_SPLIT + (END_OF_LINE + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
||||||
(Description, END_OF_LINE))
|
(Description, '\n'))
|
||||||
Content += END_OF_LINE + CommChar + END_OF_LINE
|
Content += '\r\n' + CommChar + '\r\n'
|
||||||
|
|
||||||
#
|
#
|
||||||
# There is no '#\n' line to separate multiple copyright lines in code base
|
# There is no '#\n' line to separate multiple copyright lines in code base
|
||||||
#
|
#
|
||||||
if Copyright:
|
if Copyright:
|
||||||
Copyright = Copyright.rstrip(END_OF_LINE)
|
Copyright = Copyright.rstrip('\r\n')
|
||||||
Content += CommChar + TAB_SPACE_SPLIT + (END_OF_LINE + CommChar + TAB_SPACE_SPLIT).join\
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join\
|
||||||
(GetSplitValueList(Copyright, END_OF_LINE))
|
(GetSplitValueList(Copyright, '\n'))
|
||||||
Content += END_OF_LINE + CommChar + END_OF_LINE
|
Content += '\r\n' + CommChar + '\r\n'
|
||||||
|
|
||||||
if License:
|
if License:
|
||||||
License = License.rstrip(END_OF_LINE)
|
License = License.rstrip('\r\n')
|
||||||
Content += CommChar + TAB_SPACE_SPLIT + (END_OF_LINE + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
|
||||||
(License, END_OF_LINE))
|
(License, '\n'))
|
||||||
Content += END_OF_LINE + CommChar + END_OF_LINE
|
Content += '\r\n' + CommChar + '\r\n'
|
||||||
|
|
||||||
if CommChar == TAB_COMMENT_EDK1_SPLIT:
|
if CommChar == TAB_COMMENT_EDK1_SPLIT:
|
||||||
Content += CommChar + TAB_SPACE_SPLIT + TAB_STAR + TAB_COMMENT_EDK1_END + END_OF_LINE
|
Content += CommChar + TAB_SPACE_SPLIT + TAB_STAR + TAB_COMMENT_EDK1_END + '\r\n'
|
||||||
else:
|
else:
|
||||||
Content += CommChar * 2 + END_OF_LINE
|
Content += CommChar * 2 + '\r\n'
|
||||||
|
|
||||||
return Content
|
return Content
|
||||||
|
|
||||||
|
|
|
@ -245,9 +245,9 @@ def FormatUniEntry(StrTokenName, TokenValueList, ContainerFile):
|
||||||
for SubValue in ValueList:
|
for SubValue in ValueList:
|
||||||
if SubValue.strip():
|
if SubValue.strip():
|
||||||
SubValueContent += \
|
SubValueContent += \
|
||||||
' ' * (PreFormatLength + len('#language en-US ')) + '\"%s\\n\"' % SubValue.strip() + os.linesep
|
' ' * (PreFormatLength + len('#language en-US ')) + '\"%s\\n\"' % SubValue.strip() + '\r\n'
|
||||||
SubValueContent = SubValueContent[(PreFormatLength + len('#language en-US ')):SubValueContent.rfind('\\n')] \
|
SubValueContent = SubValueContent[(PreFormatLength + len('#language en-US ')):SubValueContent.rfind('\\n')] \
|
||||||
+ '\"' + os.linesep
|
+ '\"' + '\r\n'
|
||||||
SubContent += ' '*PreFormatLength + '#language %-5s ' % Lang + SubValueContent
|
SubContent += ' '*PreFormatLength + '#language %-5s ' % Lang + SubValueContent
|
||||||
if SubContent:
|
if SubContent:
|
||||||
SubContent = StrTokenName + ' '*(PreFormatLength - len(StrTokenName)) + SubContent[PreFormatLength:]
|
SubContent = StrTokenName + ' '*(PreFormatLength - len(StrTokenName)) + SubContent[PreFormatLength:]
|
||||||
|
@ -289,7 +289,7 @@ class StringDefClassObject(object):
|
||||||
def UpdateValue(self, Value = None):
|
def UpdateValue(self, Value = None):
|
||||||
if Value != None:
|
if Value != None:
|
||||||
if self.StringValue:
|
if self.StringValue:
|
||||||
self.StringValue = self.StringValue + os.linesep + Value
|
self.StringValue = self.StringValue + '\r\n' + Value
|
||||||
else:
|
else:
|
||||||
self.StringValue = Value
|
self.StringValue = Value
|
||||||
self.StringValueByteList = UniToHexList(self.StringValue)
|
self.StringValueByteList = UniToHexList(self.StringValue)
|
||||||
|
@ -452,7 +452,7 @@ class UniFileClassObject(object):
|
||||||
if not Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderStart and not HeaderEnd:
|
if not Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderStart and not HeaderEnd:
|
||||||
HeaderEnd = True
|
HeaderEnd = True
|
||||||
if Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderStart and not HeaderEnd and FirstGenHeader:
|
if Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderStart and not HeaderEnd and FirstGenHeader:
|
||||||
self.UniFileHeader += Line + os.linesep
|
self.UniFileHeader += Line + '\r\n'
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -498,11 +498,11 @@ class UniFileClassObject(object):
|
||||||
if FileIn[LineCount].strip().startswith('#language'):
|
if FileIn[LineCount].strip().startswith('#language'):
|
||||||
Line = Line + FileIn[LineCount]
|
Line = Line + FileIn[LineCount]
|
||||||
FileIn[LineCount-1] = Line
|
FileIn[LineCount-1] = Line
|
||||||
FileIn[LineCount] = os.linesep
|
FileIn[LineCount] = '\r\n'
|
||||||
LineCount -= 1
|
LineCount -= 1
|
||||||
for Index in xrange (LineCount + 1, len (FileIn) - 1):
|
for Index in xrange (LineCount + 1, len (FileIn) - 1):
|
||||||
if (Index == len(FileIn) -1):
|
if (Index == len(FileIn) -1):
|
||||||
FileIn[Index] = os.linesep
|
FileIn[Index] = '\r\n'
|
||||||
else:
|
else:
|
||||||
FileIn[Index] = FileIn[Index + 1]
|
FileIn[Index] = FileIn[Index + 1]
|
||||||
continue
|
continue
|
||||||
|
@ -858,12 +858,12 @@ class UniFileClassObject(object):
|
||||||
Value = Value + Lines[IndexJ].strip()[1:-1]
|
Value = Value + Lines[IndexJ].strip()[1:-1]
|
||||||
CombineToken = False
|
CombineToken = False
|
||||||
else:
|
else:
|
||||||
Value = Value + Lines[IndexJ].strip()[1:-1] + os.linesep
|
Value = Value + Lines[IndexJ].strip()[1:-1] + '\r\n'
|
||||||
else:
|
else:
|
||||||
IndexI = IndexJ
|
IndexI = IndexJ
|
||||||
break
|
break
|
||||||
if Value.endswith(os.linesep):
|
if Value.endswith('\r\n'):
|
||||||
Value = Value[: Value.rfind(os.linesep)]
|
Value = Value[: Value.rfind('\r\n')]
|
||||||
Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File)
|
Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File)
|
||||||
self.AddStringToList(Name, Language, Value)
|
self.AddStringToList(Name, Language, Value)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue