X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FGenMetaFile%2FGenInfFile.py;h=d7eaf3ea1d12d1bd210110970114c923d58b51ef;hb=05a32984ab799a564e2eeb7dff128fe0992910d8;hp=698089287498f494a0ea621940a6934a5dad22b5;hpb=76d475117dfa86d54cea393f00779301b318ff88;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py index 6980892874..d7eaf3ea1d 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py @@ -2,7 +2,7 @@ # # This file contained the logical of transfer package object to INF files. # -# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2017, 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 @@ -41,6 +41,7 @@ import Logger.Log as Logger from Library import DataType as DT from GenMetaFile import GenMetaFileMisc from Library.UniClassObject import FormatUniEntry +from Library.String import GetUniFileName ## Transfer Module Object to Inf files @@ -110,7 +111,7 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None): Content += GenHeaderCommentSection(ModuleAbstract, ModuleDescription, ModuleCopyright, - ModuleLicense) + ModuleLicense).replace('\r\n', '\n') # # Generate Binary Header @@ -139,7 +140,9 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None): # FileHeader = GenHeaderCommentSection(ModuleAbstract, ModuleDescription, ModuleCopyright, ModuleLicense, False, \ DT.TAB_COMMENT_EDK1_SPLIT) - GenModuleUNIEncodeFile(ModuleObject, FileHeader) + ModuleUniFile = GenModuleUNIEncodeFile(ModuleObject, FileHeader) + if ModuleUniFile: + ModuleObject.SetModuleUniFile(os.path.basename(ModuleUniFile)) # # Judge whether the INF file is an AsBuild INF. @@ -168,15 +171,16 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None): Content += GenGuidSections(ModuleObject.GetGuidList()) Content += GenBinaries(ModuleObject) Content += GenDepex(ModuleObject) - Content += GenUserExtensions(ModuleObject) + __UserExtensionsContent = GenUserExtensions(ModuleObject) + Content += __UserExtensionsContent if ModuleObject.GetEventList() or ModuleObject.GetBootModeList() or ModuleObject.GetHobList(): Content += '\n' # # generate [Event], [BootMode], [Hob] section # - Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event') - Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode') - Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob') + Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event', __UserExtensionsContent) + Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode', __UserExtensionsContent) + Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob', __UserExtensionsContent) SaveFileOnChange(ContainerFile, Content, False) if DistHeader.ReadOnly: os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH) @@ -225,8 +229,8 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCOD return else: ModuleObject.UNIFlag = True - ContainerFile = os.path.normpath(os.path.join(os.path.dirname(ModuleObject.GetFullPath()), - (ModuleObject.GetBaseName() + '.uni'))) + ContainerFile = GetUniFileName(os.path.dirname(ModuleObject.GetFullPath()), ModuleObject.GetBaseName()) + if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())): os.makedirs(os.path.dirname(ModuleObject.GetFullPath())) @@ -261,13 +265,18 @@ def GenDefines(ModuleObject): # # generate [Defines] section # + LeftOffset = 31 Content = '' NewSectionDict = {} + for UserExtension in ModuleObject.GetUserExtensionList(): DefinesDict = UserExtension.GetDefinesDict() if not DefinesDict: continue for Statement in DefinesDict: + if Statement.split(DT.TAB_EQUAL_SPLIT) > 1: + Statement = (u'%s ' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[0]).ljust(LeftOffset) \ + + u'= %s' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[1].lstrip() SortedArch = DT.TAB_ARCH_COMMON if Statement.strip().startswith(DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE): pos = Statement.find(DT.TAB_VALUE_SPLIT) @@ -280,11 +289,7 @@ def GenDefines(ModuleObject): else: NewSectionDict[SortedArch] = [Statement] SpecialStatementList = [] - # - # Add INF_VERSION statement firstly - # - - LeftOffset = 31 + # TAB_INF_DEFINES_INF_VERSION Statement = (u'%s ' % DT.TAB_INF_DEFINES_INF_VERSION).ljust(LeftOffset) + u'= %s' % '0x00010017' SpecialStatementList.append(Statement) @@ -307,7 +312,7 @@ def GenDefines(ModuleObject): # TAB_INF_DEFINES_VERSION_STRING if ModuleObject.UNIFlag: Statement = (u'%s ' % DT.TAB_INF_DEFINES_MODULE_UNI_FILE).ljust(LeftOffset) + \ - u'= %s' % ModuleObject.GetBaseName() + '.uni' + u'= %s' % ModuleObject.GetModuleUniFile() SpecialStatementList.append(Statement) # TAB_INF_DEFINES_MODULE_TYPE @@ -565,8 +570,9 @@ def GenUserExtensions(ModuleObject): if UserExtension.GetIdentifier() == 'Depex': continue Statement = UserExtension.GetStatement() - if not Statement: - continue +# Comment the code to support user extension without any statement just the section header in [] +# if not Statement: +# continue ArchList = UserExtension.GetSupArchList() for Index in xrange(0, len(ArchList)): ArchList[Index] = ConvertArchForInstall(ArchList[Index]) @@ -977,7 +983,7 @@ def GenAsBuiltPcdExSections(ModuleObject): ## GenSpecialSections # generate special sections for Event/BootMode/Hob # -def GenSpecialSections(ObjectList, SectionName): +def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''): # # generate section # @@ -1000,6 +1006,11 @@ def GenSpecialSections(ObjectList, SectionName): else: assert(SectionName) Usage = Obj.GetUsage() + + # If the content already in UserExtensionsContent then ignore + if '[%s]' % SectionName in UserExtensionsContent and Type in UserExtensionsContent: + return '' + Statement = ' ' + Type + ' ## ' + Usage if CommentStr in ['#\n', '#\n#\n']: CommentStr = '#\n#\n#\n'