+ ## Create AsBuilt INF file the module\r
+ #\r
+ def CreateAsBuiltInf(self):\r
+ if self.IsAsBuiltInfCreated:\r
+ return\r
+ \r
+ # Skip the following code for EDK I inf\r
+ if self.AutoGenVersion < 0x00010005:\r
+ return\r
+ \r
+ # Skip the following code for libraries\r
+ if self.IsLibrary:\r
+ return\r
+ \r
+ # Skip the following code for modules with no source files\r
+ if self.SourceFileList == None or self.SourceFileList == []:\r
+ return\r
+\r
+ # Skip the following code for modules without any binary files\r
+ if self.BinaryFileList <> None and self.BinaryFileList <> []:\r
+ return\r
+ \r
+ ### TODO: How to handles mixed source and binary modules\r
+\r
+ # Find all DynamicEx PCDs used by this module and dependent libraries\r
+ # Also find all packages that the DynamicEx PCDs depend on\r
+ Pcds = []\r
+ Packages = [] \r
+ for Pcd in self.ModulePcdList + self.LibraryPcdList:\r
+ if Pcd.Type in GenC.gDynamicExPcd:\r
+ if Pcd not in Pcds:\r
+ Pcds += [Pcd]\r
+ for Package in self.DerivedPackageList:\r
+ if Package not in Packages:\r
+ if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx') in Package.Pcds:\r
+ Packages += [Package]\r
+ elif (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic') in Package.Pcds:\r
+ Packages += [Package]\r
+\r
+ ModuleType = self.ModuleType\r
+ if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:\r
+ ModuleType = 'DXE_DRIVER'\r
+\r
+ AsBuiltInfDict = {\r
+ 'module_name' : self.Name,\r
+ 'module_guid' : self.Guid,\r
+ 'module_module_type' : ModuleType,\r
+ 'module_version_string' : self.Version,\r
+ 'module_uefi_specification_version' : [],\r
+ 'module_pi_specification_version' : [],\r
+ 'module_arch' : self.Arch,\r
+ 'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],\r
+ 'binary_item' : [],\r
+ 'pcd_item' : [],\r
+ 'flags_item' : []\r
+ }\r
+\r
+ if 'UEFI_SPECIFICATION_VERSION' in self.Specification:\r
+ AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]\r
+ if 'PI_SPECIFICATION_VERSION' in self.Specification:\r
+ AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]\r
+\r
+ OutputDir = self.OutputDir.replace('\\','/').strip('/')\r
+ if self.ModuleType in ['BASE', 'USER_DEFINED']:\r
+ for Item in self.CodaTargetList:\r
+ File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')\r
+ if Item.Target.Ext.lower() == '.aml': \r
+ AsBuiltInfDict['binary_item'] += ['ASL|' + File]\r
+ elif Item.Target.Ext.lower() == '.acpi': \r
+ AsBuiltInfDict['binary_item'] += ['ACPI|' + File]\r
+ else:\r
+ AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
+ else:\r
+ for Item in self.CodaTargetList:\r
+ File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')\r
+ if Item.Target.Ext.lower() == '.efi': \r
+ AsBuiltInfDict['binary_item'] += ['PE32|' + self.Name + '.efi']\r
+ else:\r
+ AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
+ if self.DepexGenerated:\r
+ if self.ModuleType in ['PEIM']:\r
+ AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']\r
+ if self.ModuleType in ['DXE_DRIVER','DXE_RUNTIME_DRIVER','DXE_SAL_DRIVER','UEFI_DRIVER']:\r
+ AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex']\r
+ if self.ModuleType in ['DXE_SMM_DRIVER']:\r
+ AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']\r
+\r
+ for Pcd in Pcds:\r
+ AsBuiltInfDict['pcd_item'] += [Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName]\r
+ \r
+ for Item in self.BuildOption:\r
+ if 'FLAGS' in self.BuildOption[Item]:\r
+ AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]\r
+ \r
+ AsBuiltInf = TemplateString()\r
+ AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))\r
+ \r
+ SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)\r
+ \r
+ self.IsAsBuiltInfCreated = True\r
+ \r