X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FAutoGen.py;h=7fb1a8889aa659e88effb5f80dbe6470157dfc5b;hb=be264422c95c781a345978f17b7e80b91f816eda;hp=a2a8e7e5a36b096c36f9c184a98d7ad236e44926;hpb=35f69db91be5ccc972e0573015d37715b0aec315;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index a2a8e7e5a3..7fb1a8889a 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -651,7 +651,7 @@ class WorkspaceAutoGen(AutoGen): for Pa in self.AutoGenObjectList: for Package in Pa.PackageList: PcdList = Package.Pcds.values() - PcdList.sort(lambda x, y: cmp(x.TokenValue, y.TokenValue)) + PcdList.sort(lambda x, y: cmp(int(x.TokenValue, 0), int(y.TokenValue, 0))) Count = 0 while (Count < len(PcdList) - 1) : Item = PcdList[Count] @@ -659,13 +659,13 @@ class WorkspaceAutoGen(AutoGen): # # Make sure in the same token space the TokenValue should be unique # - if (Item.TokenValue == ItemNext.TokenValue): + if (int(Item.TokenValue, 0) == int(ItemNext.TokenValue, 0)): SameTokenValuePcdList = [] SameTokenValuePcdList.append(Item) SameTokenValuePcdList.append(ItemNext) RemainPcdListLength = len(PcdList) - Count - 2 for ValueSameCount in range(RemainPcdListLength): - if PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount].TokenValue == Item.TokenValue: + if int(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount].TokenValue, 0) == int(Item.TokenValue, 0): SameTokenValuePcdList.append(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount]) else: break; @@ -699,7 +699,7 @@ class WorkspaceAutoGen(AutoGen): # # Check PCDs with same TokenSpaceGuidCName.TokenCName have same token value as well. # - if (Item.TokenSpaceGuidCName == ItemNext.TokenSpaceGuidCName) and (Item.TokenCName == ItemNext.TokenCName) and (Item.TokenValue != ItemNext.TokenValue): + if (Item.TokenSpaceGuidCName == ItemNext.TokenSpaceGuidCName) and (Item.TokenCName == ItemNext.TokenCName) and (int(Item.TokenValue, 0) != int(ItemNext.TokenValue, 0)): EdkLogger.error( 'build', FORMAT_INVALID, @@ -1963,7 +1963,8 @@ class PlatformAutoGen(AutoGen): # Key[0] -- tool family # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE # - if Key[0] == self.BuildRuleFamily : + if (Key[0] == self.BuildRuleFamily and + (ModuleStyle == None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))): Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_') if Target == self.BuildTarget or Target == "*": if ToolChain == self.ToolChain or ToolChain == "*": @@ -1999,7 +2000,7 @@ class PlatformAutoGen(AutoGen): if Options.get((self.BuildRuleFamily, NowKey)) != None: Options.pop((self.BuildRuleFamily, NowKey)) - + OverrideOpt = set() for Key in Options: if ModuleStyle != None and len (Key) > 2: # Check Module style is EDK or EDKII. @@ -2025,7 +2026,9 @@ class PlatformAutoGen(AutoGen): if Arch == "*" or Arch == self.Arch: if Tool not in BuildOptions: BuildOptions[Tool] = {} - if Attr != "FLAGS" or Attr not in BuildOptions[Tool]: + if Options[Key].startswith('='): + OverrideOpt.add((Tool, Attr)) + if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or (Tool, Attr) in OverrideOpt: BuildOptions[Tool][Attr] = Options[Key] else: # append options for the same tool @@ -2033,7 +2036,8 @@ class PlatformAutoGen(AutoGen): # Build Option Family has been checked, which need't to be checked again for family. if FamilyMatch or FamilyIsNull: return BuildOptions - + + OverrideOpt = set() for Key in Options: if ModuleStyle != None and len (Key) > 2: # Check Module style is EDK or EDKII. @@ -2057,7 +2061,9 @@ class PlatformAutoGen(AutoGen): if Arch == "*" or Arch == self.Arch: if Tool not in BuildOptions: BuildOptions[Tool] = {} - if Attr != "FLAGS" or Attr not in BuildOptions[Tool]: + if Options[Key].startswith('='): + OverrideOpt.add((Tool, Attr)) + if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or (Tool, Attr) in OverrideOpt: BuildOptions[Tool][Attr] = Options[Key] else: # append options for the same tool @@ -2097,6 +2103,7 @@ class PlatformAutoGen(AutoGen): PlatformModuleOptions.keys() + ModuleTypeOptions.keys() + self.ToolDefinition.keys()) BuildOptions = {} + OverrideTool = set() for Tool in AllTools: if Tool not in BuildOptions: BuildOptions[Tool] = {} @@ -2115,8 +2122,9 @@ class PlatformAutoGen(AutoGen): BuildOptions[Tool][Attr] = "" # check if override is indicated if Value.startswith('='): + OverrideTool.add((Tool, Attr)) BuildOptions[Tool][Attr] = Value[1:] - else: + elif (Tool, Attr) not in OverrideTool: BuildOptions[Tool][Attr] += " " + Value if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None: # @@ -2297,7 +2305,6 @@ class ModuleAutoGen(AutoGen): if Module.MetaFile == self.MetaFile: continue if Module.Name == self.Name: - EdkLogger.warn('build', 'Modules have same BaseName:\n %s\n %s' % (Module.MetaFile, self.MetaFile)) if uuid.UUID(Module.Guid) == uuid.UUID(self.Guid): EdkLogger.error("build", FILE_DUPLICATED, 'Modules have same BaseName and FILE_GUID:\n' ' %s\n %s' % (Module.MetaFile, self.MetaFile)) @@ -3116,6 +3123,76 @@ class ModuleAutoGen(AutoGen): return HiiExPcds + def _GenOffsetBin(self): + VfrUniBaseName = {} + for SourceFile in self.Module.Sources: + if SourceFile.Type.upper() == ".VFR" : + # + # search the .map file to find the offset of vfr binary in the PE32+/TE file. + # + VfrUniBaseName[SourceFile.BaseName] = (SourceFile.BaseName + "Bin") + if SourceFile.Type.upper() == ".UNI" : + # + # search the .map file to find the offset of Uni strings binary in the PE32+/TE file. + # + VfrUniBaseName["UniOffsetName"] = (self.Name + "Strings") + + if len(VfrUniBaseName) == 0: + return None + MapFileName = os.path.join(self.OutputDir, self.Name + ".map") + EfiFileName = os.path.join(self.OutputDir, self.Name + ".efi") + VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrUniBaseName.values()) + if not VfrUniOffsetList: + return None + + OutputName = '%sOffset.bin' % self.Name + UniVfrOffsetFileName = os.path.join( self.OutputDir, OutputName) + + try: + fInputfile = open(UniVfrOffsetFileName, "wb+", 0) + except: + EdkLogger.error("build", FILE_OPEN_FAILURE, "File open failed for %s" % UniVfrOffsetFileName,None) + + # Use a instance of StringIO to cache data + fStringIO = StringIO('') + + for Item in VfrUniOffsetList: + if (Item[0].find("Strings") != -1): + # + # UNI offset in image. + # GUID + Offset + # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } } + # + UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66] + UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid] + fStringIO.write(''.join(UniGuid)) + UniValue = pack ('Q', int (Item[1], 16)) + fStringIO.write (UniValue) + else: + # + # VFR binary offset in image. + # GUID + Offset + # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } }; + # + VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2] + VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid] + fStringIO.write(''.join(VfrGuid)) + type (Item[1]) + VfrValue = pack ('Q', int (Item[1], 16)) + fStringIO.write (VfrValue) + # + # write data into file. + # + try : + fInputfile.write (fStringIO.getvalue()) + except: + EdkLogger.error("build", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the " + "file been locked or using by other applications." %UniVfrOffsetFileName,None) + + fStringIO.close () + fInputfile.close () + return OutputName + ## Create AsBuilt INF file the module # def CreateAsBuiltInf(self): @@ -3270,6 +3347,10 @@ class ModuleAutoGen(AutoGen): if self.ModuleType in ['DXE_SMM_DRIVER']: AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex'] + Bin = self._GenOffsetBin() + if Bin: + AsBuiltInfDict['binary_item'] += ['BIN|%s' % Bin] + for Root, Dirs, Files in os.walk(OutputDir): for File in Files: if File.lower().endswith('.pdb'):