+++ /dev/null
-## @file\r
-# Store a Platform class object to an INF file.\r
-#\r
-# Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-\r
-##\r
-# Import Modules\r
-#\r
-from LoadFpd import LoadFpd\r
-from CommonDataClass.PlatformClass import *\r
-from CommonDataClass.FdfClass import *\r
-from Common.MigrationUtilities import *\r
-from Common.ToolDefClassObject import *\r
-from Common.TargetTxtClassObject import *\r
-\r
-## Store Defines section\r
-#\r
-# Write [Defines] section to the DscFile based on Platform class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the Defines section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformDefinesSection(DscFile, Platform):\r
- PlatformHeader = Platform.Header\r
- \r
- DefinesTupleList = []\r
- \r
- if PlatformHeader.Name != "":\r
- DefinesTupleList.append(("PLATFORM_NAME", PlatformHeader.Name))\r
-\r
- if PlatformHeader.Guid != "":\r
- DefinesTupleList.append(("PLATFORM_GUID", PlatformHeader.Guid))\r
-\r
- if PlatformHeader.Version != "":\r
- DefinesTupleList.append(("PLATFORM_VERSION", PlatformHeader.Version))\r
- for key in PlatformHeader.Specification.keys():\r
- SpecificationValue = PlatformHeader.Specification.get(key)\r
- DefinesTupleList.append(("DSC_ SPECIFICATION", SpecificationValue))\r
- \r
- if PlatformHeader.OutputDirectory != "":\r
- DefinesTupleList.append(("OUTPUT_DIRECTORY", PlatformHeader.OutputDirectory))\r
-\r
- if PlatformHeader.SupArchList != "":\r
- String = "|".join(PlatformHeader.SupArchList)\r
- DefinesTupleList.append(("SUPPORTED_ARCHITECTURES", String))\r
-\r
- if PlatformHeader.BuildTargets != "":\r
- String = "|".join(PlatformHeader.BuildTargets)\r
- DefinesTupleList.append(("BUILD_TARGETS", String))\r
-\r
- if PlatformHeader.SkuIdName != "":\r
- #DefinesTupleList.append(("SKUID_IDENTIFIER", PlatformHeader.SkuIdName))\r
- String = "|".join(PlatformHeader.SkuIdName)\r
- if String != "":\r
- DefinesTupleList.append(("SKUID_IDENTIFIER", String))\r
- \r
- String = Platform.FlashDefinitionFile.FilePath\r
- if String != "":\r
- DefinesTupleList.append(("FLASH_DEFINITION", String))\r
-\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# Defines Section - statements that will be processed to create a Makefile.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- Section = "\n".join(List)\r
- Section += "\n"\r
- StoreTextFile(DscFile, Section)\r
- \r
- StoreDefinesSection(DscFile, DefinesTupleList)\r
-\r
-## Store SkuIds section\r
-#\r
-# Write [SkuIds] section to the DscFile based on Platform class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the Library Classes section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformSkuIdsSection(DscFile, Platform):\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# SKU Identification section - list of all SKU IDs supported by this Platform.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- Section = "\n".join(List)\r
- Section += "\n"\r
- \r
- Section += "[SkuIds]" + '\n'\r
- \r
- List = Platform.SkuInfos.SkuInfoList\r
- for Item in List:\r
- Section = Section + "%s" % Item[0] + '|' + "%s" % Item[1] + '\n'\r
- Section = Section + '\n'\r
- \r
- StoreTextFile(DscFile, Section)\r
-\r
-## Store Build Options section\r
-#\r
-# Write [BuildOptions] section to the DscFile based on Platform class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the Build Options section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformBuildOptionsSection(DscFile, Platform):\r
- # which is from tools_def.txt\r
- StandardBuildTargets = ["DEBUG", "RELEASE"]\r
- SupportedArches = ["COMMON", "IA32", "X64", "IPF", "EBC", "ARM"]\r
- Target = TargetTxtClassObject()\r
- WorkSpace = os.getenv('WORKSPACE')\r
- Target.LoadTargetTxtFile(WorkSpace + '\\Conf\\target.txt')\r
- ToolDef = ToolDefClassObject()\r
- ToolDef.LoadToolDefFile(WorkSpace + '\\' + Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF])\r
- # Now we have got ToolDef object\r
- #ToolDef.ToolsDefTxtDictionary\r
- Dict = ToolDef.ToolsDefTxtDatabase\r
-\r
- Dict1 = ToolDef.ToolsDefTxtDictionary # we care the info in this Dict\r
- #\r
- # We only support *(DEBUG/RELEASE) and *(All Arch: IA32, X64, IPF and EBC) for now\r
- #\r
- SectionWINDDK = ''\r
- SectionVS2003 = ''\r
- SectionVS2005EXP = ''\r
- SectionVS2005STD = ''\r
- SectionVS2005PRO = ''\r
- SectionVS2005TEAMSUITE = ''\r
- SectionUNIXGCC = ''\r
- SectionCYGWINGCC = ''\r
- SectionELFGCC = ''\r
- SectionICC = ''\r
- SectionMYTOOLS = ''\r
- for key in Dict1.keys():\r
- if key.find("_CC_FLAGS") != -1:\r
- if key.find('WINDDK3790x1830') != -1:\r
- SectionWINDDK = " = " + Dict1.get(key) + "\n"\r
- elif key.find('VS2003') != -1:\r
- SectionVS2003 = " = " + Dict1.get(key)+ "\n"\r
- elif key.find('VS2005EXP') != -1:\r
- SectionVS2005EXP = " = " + Dict1.get(key) + "\n"\r
- elif key.find('VS2005STD') != -1:\r
- SectionVS2005STD = " = " + Dict1.get(key) + "\n"\r
- elif key.find('VS2005PRO') != -1:\r
- SectionVS2005PRO = " = " + Dict1.get(key) + "\n"\r
- elif key.find('VS2005TEAMSUITE') != -1:\r
- SectionVS2005TEAMSUITE = " = " + Dict1.get(key) + "\n"\r
- elif key.find('UNIXGCC') != -1:\r
- SectionUNIXGCC = " = " + Dict1.get(key) + "\n"\r
- elif key.find('CYGWINGCC') != -1:\r
- SectionCYGWINGCC = " = " + Dict1.get(key) + "\n"\r
- elif key.find('ELFGCC') != -1:\r
- SectionELFGCC = " = " + Dict1.get(key) + "\n"\r
- elif key.find('ICC') != -1:\r
- SectionICC = " = " + Dict1.get(key) + "\n"\r
- elif key.find('MYTOOLS') != -1:\r
- SectionMYTOOLS = " = " + Dict1.get(key) + "\n"\r
- else:\r
- print "Error!"\r
-\r
- #\r
- # First need to check which arch\r
- #\r
- Archs = Platform.Header.SupArchList\r
- BuildTargets = Platform.Header.BuildTargets\r
- #if BuildTargets == StandardBuildTargets:\r
- #print "Debug and Release both support" # skip debug/release string search\r
- #else:\r
- #print "need to search debug/release string"\r
-\r
- if len(Archs) == 4:\r
- Arch = "*"\r
- SectionName = "[BuildOptions.Common]\n"\r
- else:\r
- for Arch in Archs:\r
- if Arch == 'IA32':\r
- SectionName = "[BuildOptions.IA32]\n"\r
- elif Arch == 'X64':\r
- SectionName = "[BuildOptions.X64]\n"\r
- elif Arch == 'IPF':\r
- SectionName = "[BuildOptions.IPF]\n"\r
- elif Arch == 'EBC':\r
- SectionName = "[BuildOptions.EBC]\n"\r
- else:\r
- print 'Error!'\r
- Section = ""\r
- if SectionWINDDK != "":\r
- SectionWINDDK = "*_WINDDK3790x1830_" + Arch + "_CC_FLAGS" + SectionWINDDK\r
- Section += SectionWINDDK\r
- if SectionVS2003 != "":\r
- SectionVS2003 = "*_VS2003_" + Arch + "_CC_FLAGS" + SectionVS2003\r
- Section += SectionVS2003\r
- if SectionVS2005EXP != "":\r
- SectionVS2005EXP = "*_VS2005EXP_" + Arch + "_CC_FLAGS" + SectionVS2005EXP\r
- Section += SectionVS2005EXP\r
- if SectionVS2005STD != "":\r
- SectionVS2005STD = "*_VS2005STD_" + Arch + "_CC_FLAGS" + SectionVS2005STD\r
- Section += SectionVS2005STD\r
- if SectionVS2005PRO != "":\r
- SectionVS2005PRO = "*_VS2005PRO_" + Arch + "_CC_FLAGS" + SectionVS2005PRO\r
- Section += SectionVS2005PRO\r
- if SectionVS2005TEAMSUITE != "":\r
- SectionVS2005TEAMSUITE = "*_VS2005TEAMSUITE_" + Arch + "_CC_FLAGS" + SectionVS2005TEAMSUITE\r
- Section += SectionVS2005TEAMSUITE\r
- if SectionUNIXGCC != "":\r
- SectionUNIXGCC = "*_UNIXGCC_" + Arch + "_CC_FLAGS" + SectionUNIXGCC\r
- Section += SectionUNIXGCC\r
- if SectionCYGWINGCC != "":\r
- SectionCYGWINGCC = "*_CYGWINGCC_" + Arch + "_CC_FLAGS" + SectionCYGWINGCC\r
- Section += SectionCYGWINGCC\r
- if SectionELFGCC != "":\r
- SectionELFGCC = "*_ELFGCC_" + Arch + "_CC_FLAGS" + SectionELFGCC\r
- Section += SectionELFGCC\r
- if SectionICC != "":\r
- SectionICC = "*_ICC_" + Arch + "_CC_FLAGS" + SectionICC\r
- Section += SectionICC\r
- if SectionMYTOOLS != "":\r
- SectionMYTOOLS = "*_MYTOOLS_" + Arch + "_CC_FLAGS" + SectionMYTOOLS\r
- Section += SectionMYTOOLS\r
-\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# Build Options section - list of all Build Options supported by this Platform.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- SectionHeader = "\n".join(List)\r
- SectionHeader += "\n"\r
- \r
- Section = SectionHeader + SectionName + Section\r
- Section += "\n"\r
- StoreTextFile(DscFile, Section)\r
-\r
-## Store Libraries section\r
-#\r
-# Write [Libraries] section to the DscFile based on Platform class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the Library Classes section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformLibrariesSection(DscFile,Platform):\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# Libraries section - list of all Libraries needed by this Platform.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- SectionHeader = "\n".join(List)\r
- SectionHeader += "\n"\r
- \r
- Section = SectionHeader + '[Libraries]\n\n'\r
- StoreTextFile(DscFile, Section)\r
-\r
-## Return a Platform Library Class Item\r
-#\r
-# Read the input LibraryClass class object and return one line of Library Class Item.\r
-#\r
-# @param LibraryClass An input LibraryClass class object\r
-#\r
-# @retval LibraryClassItem A Module Library Class Item\r
-#\r
-def GetPlatformLibraryClassItem(LibraryClass):\r
- LibraryClassList = []\r
- LibraryClassList.append(LibraryClass.Name)\r
- LibraryClassList.append(LibraryClass.FilePath)\r
-\r
- return "|$(WORKSPACE)/".join(LibraryClassList).rstrip("|")\r
-\r
-## Add item to a LibraryClass section\r
-#\r
-# Add an Item with specific Module Type to section dictionary.\r
-# The possible duplication is ensured to be removed.\r
-#\r
-# @param Section Section dictionary indexed by CPU architecture\r
-# @param SupModuleList LibraryClass SupModuleList: BASE, SEC, PEI_CORE, PEIM, etc\r
-# @param Item The Item to be added to section dictionary\r
-#\r
-def AddToLibraryClassSection(Section, SupModuleList, Item):\r
- for ModuleType in SupModuleList:\r
- SectionModule = Section.get(ModuleType, [])\r
- if Item not in SectionModule:\r
- SectionModule.append(Item)\r
- Section[ModuleType] = SectionModule\r
-\r
-## Get Library Classes section contents\r
-#\r
-# Return the content of section named SectionName.\r
-# the contents is based on Methods and ObjectLists.\r
-#\r
-# @param SectionName The name of the section\r
-# @param Method A function returning a string item of an object\r
-# @param ObjectList The list of object\r
-#\r
-# @retval Section The string content of a section\r
-#\r
-def GetLibraryClassesSection(SectionName, Method, ObjectList):\r
- SupportedArches = ["COMMON", "IA32", "X64", "IPF", "EBC"]\r
- ModuleTypes = ["BASE","SEC","PEI_CORE","PEIM","DXE_CORE","DXE_DRIVER","DXE_SMM_DRIVER","DXE_SAL_DRIVER","DXE_RUNTIME_DRIVER","UEFI_DRIVER","UEFI_APPLICATION"]\r
- SectionCommonDict = {}\r
- SectionIA32Dict = {}\r
- SectionX64Dict = {}\r
- SectionIPFDict = {}\r
- SectionEBCDict = {}\r
- #ObjectList = list(set(ObjectList)) # delete the same element in the list\r
- for Object in ObjectList:\r
- if Object == None:\r
- continue\r
- Item = Method(Object)\r
- if Item == "":\r
- continue\r
- Item = " %s" % Item\r
- Arches = Object.SupArchList\r
- if len(Arches) == 4:\r
- ModuleType = Object.ModuleType\r
- # [LibraryClasses.Common.ModuleType]\r
- if ModuleType == "BASE":\r
- SupModuleList = ["BASE"]\r
- AddToLibraryClassSection(SectionCommonDict, SupModuleList, Item)\r
- else:\r
- #\r
- SupModuleList = Object.SupModuleList\r
- #AddToSection(SectionDict, "|".join(SupModuleList), Item)\r
- AddToLibraryClassSection(SectionCommonDict, SupModuleList, Item)\r
- else:\r
- # Arch\r
- for Arch in SupportedArches:\r
- if Arch.upper() in Arches:\r
- if Arch == "IA32":\r
- # [LibraryClasses.IA32.ModuleType]\r
- ModuleType = Object.ModuleType\r
- if ModuleType == "BASE":\r
- SupModuleList = ["BASE"]\r
- AddToLibraryClassSection(SectionIA32Dict, SupModuleList, Item)\r
- else:\r
- SupModuleList = Object.SupModuleList\r
- AddToLibraryClassSection(SectionIA32Dict, SupModuleList, Item)\r
- elif Arch == "X64":\r
- # [LibraryClasses.X64.ModuleType]\r
- ModuleType = Object.ModuleType\r
- if ModuleType == "BASE":\r
- SupModuleList = ["BASE"]\r
- AddToLibraryClassSection(SectionX64Dict, SupModuleList, Item)\r
- else:\r
- SupModuleList = Object.SupModuleList\r
- AddToLibraryClassSection(SectionX64Dict, SupModuleList, Item)\r
- elif Arch == "IPF":\r
- # [LibraryClasses.IPF.ModuleType]\r
- ModuleType = Object.ModuleType\r
- if ModuleType == "BASE":\r
- SupModuleList = ["BASE"]\r
- AddToLibraryClassSection(SectionIPFDict, SupModuleList, Item)\r
- else:\r
- SupModuleList = Object.SupModuleList\r
- AddToLibraryClassSection(SectionIPFDict, SupModuleList, Item)\r
- elif Arch == "EBC":\r
- # [LibraryClasses.EBC.ModuleType]\r
- ModuleType = Object.ModuleType\r
- if ModuleType == "BASE":\r
- SupModuleList = ["BASE"]\r
- AddToLibraryClassSection(SectionEBCDict, SupModuleList, Item)\r
- else:\r
- SupModuleList = Object.SupModuleList\r
- AddToLibraryClassSection(SectionEBCDict, SupModuleList, Item)\r
-\r
- Section = ""\r
- for ModuleType in ModuleTypes:\r
- SectionCommonModule = "\n".join(SectionCommonDict.get(ModuleType, []))\r
- if SectionCommonModule != "":\r
- Section += "[%s.Common.%s]\n%s\n" % (SectionName, ModuleType, SectionCommonModule)\r
- Section += "\n"\r
- for ModuleType in ModuleTypes:\r
- ListIA32 = SectionIA32Dict.get(ModuleType, [])\r
- if ListIA32 != []:\r
- SectionIA32Module = "\n".join(SectionIA32Dict.get(ModuleType, []))\r
- if SectionIA32Module != "":\r
- Section += "[%s.IA32.%s]\n%s\n" % (SectionName, ModuleType, SectionIA32Module)\r
- Section += "\n"\r
- ListX64 = SectionX64Dict.get(ModuleType, [])\r
- if ListX64 != []:\r
- SectionX64Module = "\n".join(SectionX64Dict.get(ModuleType, []))\r
- if SectionX64Module != "":\r
- Section += "[%s.X64.%s]\n%s\n" % (SectionName, ModuleType, SectionX64Module)\r
- Section += "\n"\r
- ListIPF = SectionIPFDict.get(ModuleType, [])\r
- if ListIPF != []:\r
- SectionIPFModule = "\n".join(SectionIPFDict.get(ModuleType, []))\r
- if SectionIPFModule != "":\r
- Section += "[%s.IPF.%s]\n%s\n" % (SectionName, ModuleType, SectionIPFModule)\r
- Section += "\n"\r
- ListEBC = SectionEBCDict.get(ModuleType, [])\r
- if ListEBC != []:\r
- SectionEBCModule = "\n".join(SectionEBCDict.get(ModuleType, []))\r
- if SectionEBCModule != "":\r
- Section += "[%s.EBC.%s]\n%s\n" % (SectionName, ModuleType, SectionEBCModule)\r
- Section += "\n"\r
-\r
- if Section != "":\r
- Section += "\n"\r
- return Section\r
-\r
-## Store Library Classes section\r
-#\r
-# Write [LibraryClasses] section to the DscFile based on Platform class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the Library Classes section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformLibraryClassesSection(DscFile, Platform):\r
- Section = GetLibraryClassesSection("LibraryClasses", GetPlatformLibraryClassItem, Platform.LibraryClasses.LibraryList)\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# Library Class section - list of all Library Classes needed by this Platform.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- SectionHeader = "\n".join(List)\r
- SectionHeader += "\n"\r
- Section = SectionHeader + Section\r
- StoreTextFile(DscFile, Section)\r
-\r
-## Store Pcd section\r
-#\r
-# Write [Pcd] section to the DscFile based on Platform class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the Build Options section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformPcdSection(DscFile, Platform):\r
- # {PcdsFixedAtBuild:String1, PcdsFixedAtBuild:String2, PcdsPatchableInModule:String3}\r
- SectionDict = {}\r
- #\r
- # [PcdsFixedAtBuild], [PcdsPatchableInModule] and [PcdsFeatureFlag] are from platform.modules\r
- # [PcdsDynamic] is from platform.DynamicPcdBuildDefinitions\r
- #\r
- Modules = Platform.Modules.ModuleList # it's a list of modules\r
- for Module in Modules:\r
- PcdBuildDefinitions = Module.PcdBuildDefinitions # it's a list of PcdData\r
- for PcdData in PcdBuildDefinitions:\r
- if PcdData.ItemType == "FEATURE_FLAG":\r
- List = []\r
- List.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)\r
- List.append(PcdData.Value)\r
- String = "|".join(List)\r
- ItemType = PcdData.ItemType\r
- SectionPcdsFeatureFlag = SectionDict.get(ItemType, [])\r
- if String not in SectionPcdsFeatureFlag:\r
- SectionPcdsFeatureFlag.append(String)\r
- SectionDict[ItemType] = SectionPcdsFeatureFlag\r
- else:\r
- List = []\r
- List.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)\r
- List.append(PcdData.Value)\r
- List.append(PcdData.Token)\r
- List.append(PcdData.DatumType)\r
- List.append(PcdData.MaxDatumSize)\r
- String = "|".join(List)\r
- ItemType = PcdData.ItemType\r
- if PcdData.ItemType == "FIXED_AT_BUILD":\r
- SectionPcdsFixedAtBuild = SectionDict.get(ItemType, [])\r
- if String not in SectionPcdsFixedAtBuild:\r
- SectionPcdsFixedAtBuild.append(String)\r
- SectionDict[ItemType] = SectionPcdsFixedAtBuild\r
- #elif PcdData.ItemType == "FEATURE_FLAG":\r
- #SectionPcdsFeatureFlag = SectionDict.get(ItemType, [])\r
- #if String not in SectionPcdsFeatureFlag:\r
- #SectionPcdsFeatureFlag.append(String)\r
- #SectionDict[ItemType] = SectionPcdsFeatureFlag\r
- elif PcdData.ItemType == "PATCHABLE_IN_MODULE":\r
- SectionPcdsPatchableInModule = SectionDict.get(ItemType, [])\r
- if String not in SectionPcdsPatchableInModule:\r
- SectionPcdsPatchableInModule.append(String)\r
- SectionDict[ItemType] = SectionPcdsPatchableInModule\r
- elif PcdData.ItemType == "DYNAMIC":\r
- SectionPcdsDynamic = SectionDict.get(ItemType, [])\r
- if String not in SectionPcdsDynamic:\r
- SectionPcdsDynamic.append(String)\r
- SectionDict[ItemType] = SectionPcdsDynamic\r
-\r
- DynamicPcdBuildDefinitions = Platform.DynamicPcdBuildDefinitions # It's a list\r
- for PcdBuildData in DynamicPcdBuildDefinitions:\r
- List = []\r
- List.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)\r
- List.append(PcdData.Token)\r
- List.append(PcdData.DatumType)\r
- List.append(PcdData.MaxDatumSize)\r
- String = "|".join(List)\r
- if PcdBuildData.ItemType == "DYNAMIC":\r
- ItemType = PcdBuildData.ItemType\r
- SectionPcdsDynamic = SectionDict.get(ItemType, [])\r
- if String not in SectionPcdsDynamic:\r
- SectionPcdsDynamic.append(String)\r
- SectionDict[ItemType] = SectionPcdsDynamic\r
- ItemType = "FIXED_AT_BUILD"\r
- Section = "[PcdsFixedAtBuild]\n " + "\n ".join(SectionDict.get(ItemType, []))\r
- ItemType = "FEATURE_FLAG"\r
- Section += "\n\n[PcdsFeatureFlag]\n " + "\n ".join(SectionDict.get(ItemType, []))\r
- ItemType = "PATCHABLE_IN_MODULE"\r
- Section += "\n\n[PcdsPatchableInModule]\n " + "\n ".join(SectionDict.get(ItemType, []))\r
- Section += "\n\n"\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- String = "\n".join(List)\r
- Section += String\r
- ItemType = "DYNAMIC"\r
- Section += "\n\n[PcdsDynamic]\n " + "\n ".join(SectionDict.get(ItemType, []))\r
- Section += "\n\n"\r
- \r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# Pcd Section - list of all EDK II PCD Entries defined by this Platform.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- SectionHeader = "\n".join(List)\r
- SectionHeader += "\n"\r
- Section = SectionHeader + Section\r
- StoreTextFile(DscFile, Section)\r
-\r
-## Add item to a section\r
-#\r
-# Add an Item with specific CPU architecture to section dictionary.\r
-# The possible duplication is ensured to be removed.\r
-#\r
-# @param Section Section dictionary indexed by CPU architecture\r
-# @param Arch CPU architecture: Ia32, X64, Ipf, Ebc or Common\r
-# @param Item The Item to be added to section dictionary\r
-#\r
-def AddToSection(Section, Arch, Item):\r
- SectionArch = Section.get(Arch, [])\r
- if Item not in SectionArch:\r
- SectionArch.append(Item)\r
- Section[Arch] = SectionArch\r
-\r
-## Get section contents\r
-#\r
-# Return the content of section named SectionName.\r
-# the contents is based on Methods and ObjectLists.\r
-#\r
-# @param SectionName The name of the section\r
-# @param Method A function returning a string item of an object\r
-# @param ObjectList The list of object\r
-#\r
-# @retval Section The string content of a section\r
-#\r
-def GetSection(SectionName, Method, ObjectList):\r
- SupportedArches = ["COMMON", "IA32", "X64", "IPF", "EBC"]\r
- SectionDict = {}\r
- for Object in ObjectList:\r
- if Object.FilePath == "":\r
- continue\r
- Item = Method(Object)\r
- if Item == "":\r
- continue\r
- Item = " %s" % Item\r
- Arches = Object.SupArchList\r
- if len(Arches) == 4:\r
- AddToSection(SectionDict, "common", Item)\r
- else:\r
- for Arch in SupportedArches:\r
- if Arch.upper() in Arches:\r
- AddToSection(SectionDict, Arch, Item)\r
-\r
- Section = ""\r
- for Arch in SupportedArches:\r
- SectionArch = "\n".join(SectionDict.get(Arch, []))\r
- if SectionArch != "":\r
- Section += "[%s.%s]\n%s\n" % (SectionName, Arch, SectionArch)\r
- Section += "\n"\r
- if Section != "":\r
- Section += "\n"\r
- return Section\r
-\r
-## Return a Platform Component Item\r
-#\r
-# Read the input Platform Component object and return one line of Platform Component Item.\r
-#\r
-# @param Component An input Platform Component class object\r
-#\r
-# @retval ComponentItem A Platform Component Item\r
-#\r
-def GetPlatformComponentItem(Component):\r
- List = []\r
- Section = {}\r
-\r
- List.append("$(WORKSPACE)/" + Component.FilePath)\r
-\r
- LibraryClasses = Component.LibraryClasses\r
- if LibraryClasses != []:\r
- List = []\r
- List.append("$(WORKSPACE)/" + Component.FilePath + " {")\r
- List.append("<LibraryClasses>")\r
- for LibraryClass in LibraryClasses:\r
- if LibraryClass == ["", ""]:\r
- continue\r
- List.append(" " + LibraryClass[0] + "|$(WORKSPACE)/" + LibraryClass[1])\r
- \r
- PcdBuildDefinitions = Component.PcdBuildDefinitions\r
- for PcdData in PcdBuildDefinitions:\r
- if PcdData.ItemType == "FEATURE_FLAG":\r
- List1 = []\r
- List1.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)\r
- List1.append(PcdData.Value)\r
- String = "|".join(List1)\r
- ItemType = PcdData.ItemType\r
- SectionPcd = Section.get(ItemType, [])\r
- if String not in SectionPcd:\r
- SectionPcd.append(String)\r
- Section[ItemType] = SectionPcd\r
- else:\r
- List1 = []\r
- List1.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)\r
- List1.append(PcdData.Value)\r
- List1.append(PcdData.Token)\r
- List1.append(PcdData.DatumType)\r
- List1.append(PcdData.MaxDatumSize)\r
- String = "|".join(List1)\r
- ItemType = PcdData.ItemType\r
- if ItemType == "FIXED_AT_BUILD":\r
- SectionPcd = Section.get(ItemType, [])\r
- if String not in SectionPcd:\r
- SectionPcd.append(String)\r
- Section[ItemType] = SectionPcd\r
- #elif ItemType == "FEATURE_FLAG":\r
- #SectionPcd = Section.get(ItemType, [])\r
- #if String not in SectionPcd:\r
- #SectionPcd.append(String)\r
- #Section[ItemType] = SectionPcd\r
- elif ItemType == "PATCHABLE_IN_MODULE":\r
- SectionPcd = Section.get(ItemType, [])\r
- if String not in SectionPcd:\r
- SectionPcd.append(String)\r
- Section[ItemType] = SectionPcd\r
- elif ItemType == "DYNAMIC":\r
- SectionPcd = Section.get(ItemType, [])\r
- if String not in SectionPcd:\r
- SectionPcd.append(String)\r
- Section[ItemType] = SectionPcd\r
-\r
- ItemType = "FIXED_AT_BUILD"\r
- if Section.get(ItemType, []) != []:\r
- List.append("<PcdsFixedAtBuild>")\r
- List.append(" " + "\n ".join(Section.get(ItemType,[])))\r
- ItemType = "FEATURE_FLAG"\r
- if Section.get(ItemType, []) != []:\r
- List.append("<PcdsFeatureFlag>")\r
- List.append(" " + "\n ".join(Section.get(ItemType,[])))\r
- ItemType = "PATCHABLE_IN_MODULE"\r
- if Section.get(ItemType, []) != []:\r
- List.append("<PcdsPatchableInModule>")\r
- List.append(" " + "\n ".join(Section.get(ItemType,[])))\r
- ItemType = "DYNAMIC"\r
- if Section.get(ItemType, []) != []:\r
- List.append("<PcdsDynamic>")\r
- List.append(" " + "\n ".join(Section.get(ItemType,[])))\r
-\r
- ListOption = []\r
- SectionOption = ""\r
- ListBuildOptions = Component.BuildOptions # a list\r
- if ListBuildOptions != []:\r
- SectionOption += "\n <BuildOptions>\n"\r
- for BuildOptions in ListBuildOptions:\r
- Options = BuildOptions.Options\r
- for Option in Options:\r
- for Item in Option.BuildTargetList:\r
- ListOption.append(Item)\r
- List.append(Option.ToolChainFamily)\r
- for Item in Option.SupArchList:\r
- ListOption.append(Item)\r
- ListOption.append(Option.ToolCode)\r
- ListOption.append("FLAGS")\r
- #print ListOption\r
- SectionOption += " " + "_".join(List) + " = " + Option.Option + "\n"\r
- ListOption = []\r
- if SectionOption != "":\r
- List.append(SectionOption)\r
- if List != ["$(WORKSPACE)/" + Component.FilePath]:\r
- List.append("}\n")\r
-\r
- return "\n ".join(List)\r
-\r
-## Store Components section.\r
-#\r
-# Write [Components] section to the DscFile based on Platform class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the Components section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformComponentsSection(DscFile, Platform):\r
- Section = GetSection("Components", GetPlatformComponentItem, Platform.Modules.ModuleList)\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# Components Section - list of all EDK II Modules needed by this Platform.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- SectionHeader = "\n".join(List)\r
- SectionHeader += "\n"\r
- Section = SectionHeader + Section\r
- StoreTextFile(DscFile, Section)\r
-\r
-## Store User Extensions section.\r
-#\r
-# Write [UserExtensions] section to the InfFile based on Module class object.\r
-# Different CPU architectures are specified in the subsection if possible.\r
-#\r
-# @param DscFile The output DSC file to store the User Extensions section\r
-# @param Platform An input Platform class object\r
-#\r
-def StorePlatformUserExtensionsSection(DscFile, Platform):\r
- Section = "".join(map(GetUserExtensions, Platform.UserExtensions))\r
- List = []\r
- List.append("################################################################################")\r
- List.append("#")\r
- List.append("# User Extensions Section - list of all User Extensions specified by user.")\r
- List.append("#")\r
- List.append("################################################################################")\r
- SectionHeader = "\n".join(List)\r
- SectionHeader += "\n"\r
- Section = SectionHeader + Section\r
- StoreTextFile(DscFile, Section)\r
- \r
-## Store a Platform class object to a new DSC file.\r
-#\r
-# Read an input Platform class object and save the contents to a new DSC file.\r
-#\r
-# @param DSCFileName The output DSC file\r
-# @param Platform An input Platform class object\r
-#\r
-def StoreDsc(DscFileName, Platform):\r
- DscFile = open(DscFileName, "w+")\r
- EdkLogger.info("Save file to %s" % DscFileName)\r
-\r
- StoreHeader(DscFile, Platform.Header)\r
- StorePlatformDefinesSection(DscFile, Platform)\r
- StorePlatformBuildOptionsSection(DscFile,Platform)\r
- StorePlatformSkuIdsSection(DscFile,Platform)\r
- StorePlatformLibrariesSection(DscFile,Platform) # new in dsc, Edk I components, list of INF files\r
- StorePlatformLibraryClassesSection(DscFile, Platform) # LibraryClasses are from Modules\r
- StorePlatformPcdSection(DscFile, Platform)\r
- #StorePlatformPcdDynamicSection(DscFile, Platform)\r
- StorePlatformComponentsSection(DscFile,Platform)\r
- StorePlatformUserExtensionsSection(DscFile,Platform)\r
- DscFile.close()\r
- \r
-if __name__ == '__main__':\r
- pass\r