summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r--BaseTools/Source/Python/AutoGen/AutoGen.py32
-rw-r--r--BaseTools/Source/Python/AutoGen/BuildEngine.py7
-rw-r--r--BaseTools/Source/Python/AutoGen/GenC.py20
-rw-r--r--BaseTools/Source/Python/Common/BuildVersion.py2
-rw-r--r--BaseTools/Source/Python/Common/DataType.py9
-rw-r--r--BaseTools/Source/Python/Common/Expression.py22
-rw-r--r--BaseTools/Source/Python/Common/GlobalData.py4
-rw-r--r--BaseTools/Source/Python/Common/String.py4
-rw-r--r--BaseTools/Source/Python/Ecc/Ecc.py16
-rw-r--r--BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py5
-rw-r--r--BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py3
-rw-r--r--BaseTools/Source/Python/Fdb/__init__.py15
-rw-r--r--BaseTools/Source/Python/FixFlash/__init__.py15
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py43
-rw-r--r--BaseTools/Source/Python/GenFds/Ffs.py1
-rw-r--r--BaseTools/Source/Python/GenFds/GenFds.py11
-rw-r--r--BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py4
-rw-r--r--BaseTools/Source/Python/Makefile11
-rw-r--r--BaseTools/Source/Python/MigrationMsa2Inf/AutoGenExterns.py369
-rw-r--r--BaseTools/Source/Python/MigrationMsa2Inf/MigrationMsa2Inf.py2478
-rw-r--r--BaseTools/Source/Python/MigrationMsa2Inf/__init__.py15
-rw-r--r--BaseTools/Source/Python/MkBOM/__init__.py15
-rw-r--r--BaseTools/Source/Python/UPT/BuildVersion.py2
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileParser.py94
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileTable.py4
-rw-r--r--BaseTools/Source/Python/Workspace/WorkspaceDatabase.py24
-rw-r--r--BaseTools/Source/Python/build/BuildReport.py65
-rw-r--r--BaseTools/Source/Python/build/build.py20
-rw-r--r--BaseTools/Source/Python/fpd2dsc/EdkIIWorkspaceGuidsInfo.py327
-rw-r--r--BaseTools/Source/Python/fpd2dsc/LoadFpd.py1039
-rw-r--r--BaseTools/Source/Python/fpd2dsc/MigrationUtilities.py563
-rw-r--r--BaseTools/Source/Python/fpd2dsc/StoreDsc.py765
-rw-r--r--BaseTools/Source/Python/fpd2dsc/__init__.py15
-rw-r--r--BaseTools/Source/Python/fpd2dsc/fpd2dsc.py117
-rw-r--r--BaseTools/Source/Python/msa2inf/ConvertModule.py112
-rw-r--r--BaseTools/Source/Python/msa2inf/EdkIIWorkspaceGuidsInfo.py325
-rw-r--r--BaseTools/Source/Python/msa2inf/LoadMsa.py747
-rw-r--r--BaseTools/Source/Python/msa2inf/Msa2Inf.py44
-rw-r--r--BaseTools/Source/Python/msa2inf/StoreInf.py442
-rw-r--r--BaseTools/Source/Python/msa2inf/__init__.py15
-rw-r--r--BaseTools/Source/Python/spd2dec/ConvertPackage.py66
-rw-r--r--BaseTools/Source/Python/spd2dec/LoadSpd.py273
-rw-r--r--BaseTools/Source/Python/spd2dec/Spd2Dec.py46
-rw-r--r--BaseTools/Source/Python/spd2dec/StoreDec.py247
-rw-r--r--BaseTools/Source/Python/spd2dec/__init__.py15
45 files changed, 310 insertions, 8158 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 894ec8dcd8..2f38c6afd5 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -46,6 +46,9 @@ gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}
## Build rule configuration file
gBuildRuleFile = 'Conf/build_rule.txt'
+## Build rule default version
+AutoGenReqBuildRuleVerNum = "0.1"
+
## default file name for AutoGen
gAutoGenCodeFileName = "AutoGen.c"
gAutoGenHeaderFileName = "AutoGen.h"
@@ -288,8 +291,25 @@ class WorkspaceAutoGen(AutoGen):
# apply SKU and inject PCDs from Flash Definition file
for Arch in self.ArchList:
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
+
+ DecPcds = set()
+ PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
+ Pkgs = PGen.PackageList
+ for Pkg in Pkgs:
+ for Pcd in Pkg.Pcds.keys():
+ DecPcds.add((Pcd[0], Pcd[1]))
+ Platform.IsPlatformPcdDeclared(DecPcds)
+
Platform.SkuName = self.SkuId
for Name, Guid in PcdSet:
+ if (Name, Guid) not in DecPcds:
+ EdkLogger.error(
+ 'build',
+ PARSER_ERROR,
+ "PCD (%s.%s) used in FDF is not declared in DEC files." % (Guid, Name),
+ File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],
+ Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]
+ )
Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])
Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)
@@ -334,11 +354,14 @@ class WorkspaceAutoGen(AutoGen):
#
InfFoundFlag = False
for Pa in self.AutoGenObjectList:
+ if InfFoundFlag:
+ break
for Module in Pa.ModuleAutoGenList:
if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName):
InfFoundFlag = True
if not Module.Guid.upper() in _GuidDict.keys():
_GuidDict[Module.Guid.upper()] = FfsFile
+ break
else:
EdkLogger.error("build",
FORMAT_INVALID,
@@ -1230,6 +1253,15 @@ class PlatformAutoGen(AutoGen):
if BuildRuleFile in [None, '']:
BuildRuleFile = gBuildRuleFile
self._BuildRule = BuildRule(BuildRuleFile)
+ if self._BuildRule._FileVersion == "":
+ self._BuildRule._FileVersion = AutoGenReqBuildRuleVerNum
+ else:
+ if self._BuildRule._FileVersion < AutoGenReqBuildRuleVerNum :
+ # If Build Rule's version is less than the version number required by the tools, halting the build.
+ EdkLogger.error("build", AUTOGEN_ERROR,
+ ExtraData="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\
+ % (self._BuildRule._FileVersion, AutoGenReqBuildRuleVerNum))
+
return self._BuildRule
## Summarize the packages used by modules in this platform
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index 45a560448e..5a7527ef4b 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -354,6 +354,7 @@ class BuildRule:
self._FamilyList = []
self._TotalToolChainFamilySet = set()
self._RuleObjectList = [] # FileBuildRule object list
+ self._FileVersion = ""
self.Parse()
@@ -368,7 +369,11 @@ class BuildRule:
# Clean up the line and replace path separator with native one
Line = self.RuleContent[Index].strip().replace(self._PATH_SEP, os.path.sep)
self.RuleContent[Index] = Line
-
+
+ # find the build_rule_version
+ if Line and Line[0] == "#" and Line.find(TAB_BUILD_RULE_VERSION) <> -1:
+ if Line.find("=") <> -1 and Line.find("=") < (len(Line)-1) and (Line[(Line.find("=") + 1):]).split():
+ self._FileVersion = (Line[(Line.find("=") + 1):]).split()[0]
# skip empty or comment line
if Line == "" or Line[0] == "#":
continue
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 63131cee24..fafcd70b86 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1,7 +1,7 @@
## @file
# Routines for generating AutoGen.h and AutoGen.c
#
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -103,17 +103,17 @@ typedef struct {
} SKU_HEAD;
typedef struct {
+ UINT32 StringIndex; // Offset in String Table in units of UINT32.
+ UINT32 DefaultValueOffset; // Offset of the Default Value
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
- UINT16 StringIndex; // Offset in String Table in units of UINT16.
UINT16 Offset; // Offset in Variable
- UINT16 DefaultValueOffset; // Offset of the Default Value
} VARIABLE_HEAD;
typedef struct {
UINT32 Offset;
} VPD_HEAD;
-typedef UINT16 STRING_HEAD;
+typedef UINT32 STRING_HEAD;
typedef UINT16 SIZE_INFO;
@@ -1346,13 +1346,13 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
VariableHeadGuidIndex = GuidList.index(VariableGuid)
if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
- VariableHeadValueList.append('%dU, %dU, %sU, offsetof(%s_PCD_DATABASE, Init.%s_%s)' %
- (VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset,
- Phase, CName, TokenSpaceGuid))
+ VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s), %dU, %sU' %
+ (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid,
+ VariableHeadGuidIndex, Sku.VariableOffset))
else:
- VariableHeadValueList.append('%dU, %dU, %sU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s)' %
- (VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset,
- Phase, CName, TokenSpaceGuid, SkuIdIndex))
+ VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s), %dU, %sU' %
+ (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid, SkuIdIndex,
+ VariableHeadGuidIndex, Sku.VariableOffset))
Dict['VARDEF_CNAME_'+Pcd.DatumType].append(CName)
Dict['VARDEF_GUID_'+Pcd.DatumType].append(TokenSpaceGuid)
Dict['VARDEF_SKUID_'+Pcd.DatumType].append(SkuIdIndex)
diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py
index b6b02cf8ae..c5dae6daa4 100644
--- a/BaseTools/Source/Python/Common/BuildVersion.py
+++ b/BaseTools/Source/Python/Common/BuildVersion.py
@@ -13,4 +13,4 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-gBUILD_VERSION = "Build 2474"
+gBUILD_VERSION = "Build 2518"
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index fc0a7ad026..e5e7eaeede 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -29,6 +29,7 @@ TAB_OPTION_START = '<'
TAB_OPTION_END = '>'
TAB_SLASH = '\\'
TAB_BACK_SLASH = '/'
+TAB_LINE_BREAK = '\n'
TAB_EDK_SOURCE = '$(EDK_SOURCE)'
TAB_EFI_SOURCE = '$(EFI_SOURCE)'
@@ -421,3 +422,11 @@ TAB_DEPENDENCY_EXPRESSION_FILE = "DEPENDENCY-EXPRESSION-FILE"
TAB_UNKNOWN_FILE = "UNKNOWN-TYPE-FILE"
TAB_DEFAULT_BINARY_FILE = "_BINARY_FILE_"
+# used by BRG
+TAB_BRG_PCD = 'PCD'
+TAB_BRG_LIBRARY = 'Library'
+
+#
+# Build Rule File Version Definition
+#
+TAB_BUILD_RULE_VERSION = "build_rule_version"
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 8b112d50b3..a4853b78a4 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -36,6 +36,7 @@ ERR_STRING_CMP = 'Unicode string and general string cannot be compared:
ERR_ARRAY_TOKEN = 'Bad C array or C format GUID token: [%s].'
ERR_ARRAY_ELE = 'This must be HEX value for NList or Array: [%s].'
ERR_EMPTY_EXPR = 'Empty expression is not allowed.'
+ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
## SplitString
# Split string to list according double quote
@@ -88,22 +89,29 @@ def ReplaceExprMacro(String, Macros, ExceptionList = None):
# If an undefined macro name appears in the constant-expression of
# !if or !elif, it is replaced by the integer constant 0.
RetStr += '0'
- elif not InQuote and ExceptionList and Macro in ExceptionList:
+ elif not InQuote:
+ Tklst = RetStr.split()
+ if Tklst and Tklst[-1] in ['IN', 'in'] and ExceptionList and Macro not in ExceptionList:
+ raise BadExpression(ERR_IN_OPERAND)
# Make sure the macro in exception list is encapsulated by double quote
# For example: DEFINE ARCH = IA32 X64
# $(ARCH) is replaced with "IA32 X64"
- RetStr += '"' + Macros[Macro] + '"'
- else:
- if Macros[Macro].strip() != "":
+ if ExceptionList and Macro in ExceptionList:
+ RetStr += '"' + Macros[Macro] + '"'
+ elif Macros[Macro].strip():
RetStr += Macros[Macro]
else:
RetStr += '""'
+ else:
+ RetStr += Macros[Macro]
RetStr += String[MacroEndPos+1:]
String = RetStr
MacroStartPos = String.find('$(')
StrList[i] = RetStr
return ''.join(StrList)
+SupportedInMacroList = ['TARGET', 'TOOL_CHAIN_TAG', 'ARCH', 'FAMILY']
+
class ValueExpression(object):
# Logical operator mapping
LogicalOperators = {
@@ -213,7 +221,7 @@ class ValueExpression(object):
self._Expr = ReplaceExprMacro(Expression.strip(),
SymbolTable,
- ['TARGET', 'TOOL_CHAIN_TAG', 'ARCH'])
+ SupportedInMacroList)
if not self._Expr.strip():
raise BadExpression(ERR_EMPTY_EXPR)
@@ -457,7 +465,9 @@ class ValueExpression(object):
# PCD token
if self.PcdPattern.match(self._Token):
if self._Token not in self._Symb:
- raise BadExpression(ERR_PCD_RESOLVE % self._Token)
+ Ex = BadExpression(ERR_PCD_RESOLVE % self._Token)
+ Ex.Pcd = self._Token
+ raise Ex
self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True)
if type(self._Token) != type(''):
self._LiteralToken = hex(self._Token)
diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index 492aa39962..d566a57844 100644
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -26,6 +26,10 @@ gAllFiles = None
gGlobalDefines = {}
gPlatformDefines = {}
+# PCD name and value pair for fixed at build and feature flag
+gPlatformPcds = {}
+# PCDs with type that are not fixed at build and feature flag
+gPlatformOtherPcds = {}
gActivePlatform = None
gCommandLineDefines = {}
gEdkGlobal = {}
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py
index 0f2a61b1b9..068a63d1c1 100644
--- a/BaseTools/Source/Python/Common/String.py
+++ b/BaseTools/Source/Python/Common/String.py
@@ -319,7 +319,7 @@ def NormPath(Path, Defines={}):
#
# @retval Path Formatted path
#
-def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False):
+def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False, BuildOption=False):
#
# remove whitespace
#
@@ -343,7 +343,7 @@ def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyle
Line = Line[0: Index]
break
- if CommentInString:
+ if CommentInString and BuildOption:
Line = Line.replace('"', '')
ChIndex = Line.find('#')
while ChIndex >= 0:
diff --git a/BaseTools/Source/Python/Ecc/Ecc.py b/BaseTools/Source/Python/Ecc/Ecc.py
index e2e92ef672..b1a0ab8272 100644
--- a/BaseTools/Source/Python/Ecc/Ecc.py
+++ b/BaseTools/Source/Python/Ecc/Ecc.py
@@ -28,6 +28,7 @@ from Common.String import NormPath
from Common.BuildVersion import gBUILD_VERSION
from Common import BuildToolError
from Common.Misc import PathClass
+from Common.Misc import DirCache
from MetaFileWorkspace.MetaFileParser import DscParser
from MetaFileWorkspace.MetaFileParser import DecParser
from MetaFileWorkspace.MetaFileParser import InfParser
@@ -106,6 +107,11 @@ class Ecc(object):
EccGlobalData.gDb = Database.Database(Database.DATABASE_PATH)
EccGlobalData.gDb.InitDatabase(self.IsInit)
+ #
+ # Get files real name in workspace dir
+ #
+ GlobalData.gAllFiles = DirCache(GlobalData.gWorkspace)
+
# Build ECC database
self.BuildDatabase()
@@ -137,13 +143,13 @@ class Ecc(object):
EccGlobalData.gDb.TblReport.Create()
# Build database
- if self.IsInit:
- if self.ScanSourceCode:
- EdkLogger.quiet("Building database for source code ...")
- c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget)
+ if self.IsInit:
if self.ScanMetaData:
- EdkLogger.quiet("Building database for source code done!")
+ EdkLogger.quiet("Building database for Meta Data File ...")
self.BuildMetaDataFileDatabase()
+ if self.ScanSourceCode:
+ EdkLogger.quiet("Building database for Meta Data File Done!")
+ c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget)
EccGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb)
EccGlobalData.gCFileList = GetFileList(MODEL_FILE_C, EccGlobalData.gDb)
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
index 3060698288..643c228665 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
@@ -96,7 +96,10 @@ class Table(object):
#
def Drop(self):
SqlCommand = """drop table IF EXISTS %s""" % self.Table
- self.Cur.execute(SqlCommand)
+ try:
+ self.Cur.execute(SqlCommand)
+ except sqlite3.Error, e:
+ print "An error occurred when Drop a table:", e.args[0]
## Get count
#
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index 9ca00f043b..d10265e973 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
@@ -1162,8 +1162,9 @@ class DscParser(MetaFileParser):
self._IdMapping[Id] = self._LastItem
RecordList = self._Table.GetAll()
- self._Table.Drop()
+
self._RawTable.Drop()
+ self._Table.Drop()
for Record in RecordList:
EccGlobalData.gDb.TblDsc.Insert(Record[1],Record[2],Record[3],Record[4],Record[5],Record[6],Record[7],Record[8],Record[9],Record[10],Record[11],Record[12],Record[13],Record[14])
GlobalData.gPlatformDefines.update(self._FileLocalMacros)
diff --git a/BaseTools/Source/Python/Fdb/__init__.py b/BaseTools/Source/Python/Fdb/__init__.py
deleted file mode 100644
index c9dbe8e4f1..0000000000
--- a/BaseTools/Source/Python/Fdb/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-## @file
-# Python 'Fdb' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
diff --git a/BaseTools/Source/Python/FixFlash/__init__.py b/BaseTools/Source/Python/FixFlash/__init__.py
deleted file mode 100644
index b648fcaf0e..0000000000
--- a/BaseTools/Source/Python/FixFlash/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-## @file
-# Python 'FixFlash' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 7a569e88dd..dc5c4fa034 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -77,6 +77,7 @@ SEPERATOR_TUPLE = ('=', '|', ',', '{', '}')
RegionSizePattern = re.compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
RegionSizeGuidPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*\|\s*(?P<size>\w+\.\w+)\s*")
+ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
IncludeFileList = []
@@ -679,7 +680,7 @@ class FdfParser:
PreIndex = 0
StartPos = CurLine.find('$(', PreIndex)
EndPos = CurLine.find(')', StartPos+2)
- while StartPos != -1 and EndPos != -1 and not (self.__Token == '!ifdef' or self.__Token == '!ifndef'):
+ while StartPos != -1 and EndPos != -1 and self.__Token not in ['!ifdef', '!ifndef', '!if', '!elseif']:
MacroName = CurLine[StartPos+2 : EndPos]
MacorValue = self.__GetMacroValue(MacroName)
if MacorValue != None:
@@ -711,6 +712,8 @@ class FdfParser:
self.__SetMacroValue(Macro, Value)
self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token == 'SET':
+ SetLine = self.CurrentLineNumber - 1
+ SetOffset = self.CurrentOffsetWithinLine - len('SET')
PcdPair = self.__GetNextPcdName()
PcdName = "%s.%s" % (PcdPair[1], PcdPair[0])
if not self.__IsToken( "="):
@@ -720,6 +723,12 @@ class FdfParser:
Value = self.__EvaluateConditional(Value, self.CurrentLineNumber, 'eval', True)
self.__PcdDict[PcdName] = Value
+
+ self.Profile.PcdDict[PcdPair] = Value
+ FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
+ self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
+
+ self.__WipeOffArea.append(((SetLine, SetOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token in ('!ifdef', '!ifndef', '!if'):
IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token))
IfList.append([IfStartPos, None, None])
@@ -773,6 +782,11 @@ class FdfParser:
if self.CurrentLineNumber <= RegionLayoutLine:
# Don't try the same line twice
continue
+ SetPcd = ShortcutPcdPattern.match(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
+ if SetPcd:
+ self.__PcdDict[SetPcd.group('name')] = SetPcd.group('value')
+ RegionLayoutLine = self.CurrentLineNumber
+ continue
RegionSize = RegionSizePattern.match(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
if not RegionSize:
RegionLayoutLine = self.CurrentLineNumber
@@ -793,6 +807,7 @@ class FdfParser:
MacroDict = {}
# PCD macro
+ MacroDict.update(GlobalData.gPlatformPcds)
MacroDict.update(self.__PcdDict)
# Lowest priority
@@ -838,7 +853,19 @@ class FdfParser:
Line=Line)
return Excpt.result
except Exception, Excpt:
- raise Warning("Invalid expression", *FileLineTuple)
+ if hasattr(Excpt, 'Pcd'):
+ if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
+ Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd]
+ raise Warning("Cannot use this PCD (%s) in an expression as"
+ " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
+ " of the DSC file (%s), and it is currently defined in this section:"
+ " %s, line #: %d." % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE'], Info[0], Info[1]),
+ *FileLineTuple)
+ else:
+ raise Warning("PCD (%s) is not defined in DSC file (%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']),
+ *FileLineTuple)
+ else:
+ raise Warning(str(Excpt), *FileLineTuple)
else:
if Expression.startswith('$(') and Expression[-1] == ')':
Expression = Expression[2:-1]
@@ -2287,6 +2314,10 @@ class FdfParser:
if not self.__GetNextToken():
raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)
ffsInf.InfFileName = self.__Token
+
+ ffsInf.CurrentLineNum = self.CurrentLineNumber
+ ffsInf.CurrentLineContent = self.__CurrentLine()
+
if ffsInf.InfFileName.replace('$(WORKSPACE)', '').find('$') == -1:
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
@@ -2306,9 +2337,6 @@ class FdfParser:
else:
raise Warning("Unknown reloc strip flag '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
- ffsInf.CurrentLineNum = self.CurrentLineNumber
- ffsInf.CurrentLineContent = self.__CurrentLine()
-
if ForCapsule:
capsuleFfs = CapsuleData.CapsuleFfs()
capsuleFfs.Ffs = ffsInf
@@ -2419,9 +2447,6 @@ class FdfParser:
FfsFileObj.NameGuid = self.__Token
- FfsFileObj.CurrentLineNum = self.CurrentLineNumber
- FfsFileObj.CurrentLineContent = self.__CurrentLine()
-
self.__GetFilePart( FfsFileObj, MacroDict.copy())
if ForCapsule:
@@ -2511,6 +2536,8 @@ class FdfParser:
self.__UndoToken()
self.__GetSectionData( FfsFileObj, MacroDict)
else:
+ FfsFileObj.CurrentLineNum = self.CurrentLineNumber
+ FfsFileObj.CurrentLineContent = self.__CurrentLine()
FfsFileObj.FileName = self.__Token
if FfsFileObj.FileName.replace('$(WORKSPACE)', '').find('$') == -1:
#
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py
index d9f1cdaff0..c8c5a6e861 100644
--- a/BaseTools/Source/Python/GenFds/Ffs.py
+++ b/BaseTools/Source/Python/GenFds/Ffs.py
@@ -64,6 +64,7 @@ class Ffs(FDClassObject):
'COMPAT16' : '.com16',
'RAW' : '.raw',
'FREEFORM_SUBTYPE_GUID': '.guid',
+ 'SUBTYPE_GUID' : '.guid',
'FV_IMAGE' : 'fv.sec',
'COMPRESS' : '.com',
'GUIDED' : '.guided',
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 8a742d95be..fb86a152b6 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -314,7 +314,7 @@ def myOptionParser():
Parser.add_option("-r", "--rom_image", dest="uiFdName", help="Build the image using the [FD] section named by FdUiName.")
Parser.add_option("-i", "--FvImage", dest="uiFvName", help="Build the FV image using the [FV] section named by UiFvName")
Parser.add_option("-C", "--CapsuleImage", dest="uiCapName", help="Build the Capsule image using the [Capsule] section named by UiCapName")
- Parser.add_option("-b", "--buildtarget", type="choice", choices=['DEBUG','RELEASE', 'NOOPT'], dest="BuildTarget", help="Build TARGET is one of list: DEBUG, RELEASE, NOOPT.",
+ Parser.add_option("-b", "--buildtarget", type="string", dest="BuildTarget", help="Set the build TARGET, overrides target.txt TARGET setting.",
action="callback", callback=SingleCheckCallback)
Parser.add_option("-t", "--tagname", type="string", dest="ToolChain", help="Using the tools: TOOL_CHAIN_TAG name to build the platform.",
action="callback", callback=SingleCheckCallback)
@@ -516,10 +516,13 @@ class GenFds :
for ModuleFile in PlatformDataBase.Modules:
Module = BuildDb.BuildObject[ModuleFile, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
GuidXRefFile.write("%s %s\n" % (Module.Guid, Module.BaseName))
- SaveFileOnChange(GuidXRefFileName, GuidXRefFile.getvalue(), False)
+ if GuidXRefFile.getvalue():
+ SaveFileOnChange(GuidXRefFileName, GuidXRefFile.getvalue(), False)
+ GenFdsGlobalVariable.InfLogger("\nGUID cross reference file can be found at %s" % GuidXRefFileName)
+ elif os.path.exists(GuidXRefFileName):
+ os.remove(GuidXRefFileName)
GuidXRefFile.close()
- GenFdsGlobalVariable.InfLogger("\nGUID cross reference file can be found at %s" % GuidXRefFileName)
-
+
##Define GenFd as static function
GenFd = staticmethod(GenFd)
GetFvBlockSize = staticmethod(GetFvBlockSize)
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index ea6b191bc1..b457937628 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -1,7 +1,7 @@
## @file
# Global variables for GenFds
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -581,7 +581,7 @@ class GenFdsGlobalVariable:
sys.stdout.write('\n')
try:
- PopenObject = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr= subprocess.PIPE)
+ PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr= subprocess.PIPE, shell=True)
except Exception, X:
EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
(out, error) = PopenObject.communicate()
diff --git a/BaseTools/Source/Python/Makefile b/BaseTools/Source/Python/Makefile
index a1a0a5e639..fec8b43646 100644
--- a/BaseTools/Source/Python/Makefile
+++ b/BaseTools/Source/Python/Makefile
@@ -21,7 +21,7 @@ MODULES=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_8,encodings
BIN_DIR=$(EDK_TOOLS_PATH)\Bin\Win32
-APPLICATIONS=$(BIN_DIR)\build.exe $(BIN_DIR)\GenFds.exe $(BIN_DIR)\Trim.exe $(BIN_DIR)\MigrationMsa2Inf.exe $(BIN_DIR)\Fpd2Dsc.exe $(BIN_DIR)\TargetTool.exe $(BIN_DIR)\spd2dec.exe $(BIN_DIR)\GenDepex.exe $(BIN_DIR)\GenPatchPcdTable.exe $(BIN_DIR)\PatchPcdValue.exe $(BIN_DIR)\BPDG.exe $(BIN_DIR)\UPT.exe
+APPLICATIONS=$(BIN_DIR)\build.exe $(BIN_DIR)\GenFds.exe $(BIN_DIR)\Trim.exe $(BIN_DIR)\TargetTool.exe $(BIN_DIR)\GenDepex.exe $(BIN_DIR)\GenPatchPcdTable.exe $(BIN_DIR)\PatchPcdValue.exe $(BIN_DIR)\BPDG.exe $(BIN_DIR)\UPT.exe
COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \
$(BASE_TOOLS_PATH)\Source\Python\Common\Database.py \
@@ -77,15 +77,6 @@ $(BIN_DIR)\GenFds.exe: $(BASE_TOOLS_PATH)\Source\Python\GenFds\GenFds.py $(COMMO
$(BIN_DIR)\Trim.exe: $(BASE_TOOLS_PATH)\Source\Python\Trim\Trim.py $(COMMON_PYTHON)
@pushd . & @cd Trim & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) Trim.py & @popd
-$(BIN_DIR)\MigrationMsa2Inf.exe: $(BASE_TOOLS_PATH)\Source\Python\MigrationMsa2Inf\MigrationMsa2Inf.py $(COMMON_PYTHON)
- @pushd . & @cd MigrationMsa2Inf & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) MigrationMsa2Inf.py & @popd
-
-$(BIN_DIR)\Fpd2Dsc.exe: $(BASE_TOOLS_PATH)\Source\Python\Fpd2Dsc\Fpd2Dsc.py $(COMMON_PYTHON)
- @pushd . & @cd Fpd2Dsc & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) Fpd2Dsc.py & @popd
-
-$(BIN_DIR)\spd2dec.exe: $(BASE_TOOLS_PATH)\Source\Python\spd2dec\Spd2Dec.py $(COMMON_PYTHON)
- @pushd . & @cd Spd2Dec & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) Spd2Dec.py & @popd
-
$(BIN_DIR)\GenDepex.exe: $(BASE_TOOLS_PATH)\Source\Python\AutoGen\GenDepex.py $(COMMON_PYTHON)
@pushd . & @cd AutoGen & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) GenDepex.py & @popd
diff --git a/BaseTools/Source/Python/MigrationMsa2Inf/AutoGenExterns.py b/BaseTools/Source/Python/MigrationMsa2Inf/AutoGenExterns.py
deleted file mode 100644
index 37fff885a8..0000000000
--- a/BaseTools/Source/Python/MigrationMsa2Inf/AutoGenExterns.py
+++ /dev/null
@@ -1,369 +0,0 @@
-#!/usr/bin/env python
-#
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-
-#
-# Import Modules
-#
-import re, os, glob
-from Common.XmlRoutines import *
-
-#"ModuleType"=>(PackageGuid, headerFileName) List
-HeaderFiles = {}
-GuidList = []
-GuidMap = {}
-HeaderFileContents = {}
-gTest = {}
-GuidMacro2CName = {}
-GuidAliasList = []
-
-def collectIncludeFolder(pkgDirName, guidType, pkgName):
- includeFolder = os.path.join(pkgDirName, "Include", guidType)
- if os.path.exists(includeFolder) and os.path.isdir(includeFolder):
- for headerFileName in os.listdir(includeFolder):
- if headerFileName[-2:] == ".h":
- headerFile = open(os.path.join(includeFolder, headerFileName))
- HeaderFileContents[(guidType, headerFileName, pkgName)] = headerFile.read()
- headerFile.close()
-
-GuidMacroReg = re.compile(r"\b(?!EFI_GUID\b)[A-Z0-9_]+_GUID\b")
-GuidCNameReg = re.compile(r"\bg\w+Guid\b")
-GuidAliasReg = re.compile(r"#define\s+([A-Z0-9_]+_GUID)\s+([A-Z0-9_]+_GUID)\b")
-
-def collectPackageInfo(spdFileName):
- pkgDirName = os.path.dirname(spdFileName)
-
- spd = XmlParseFile(spdFileName)
-
- pkgName = XmlElement(spd, "/PackageSurfaceArea/SpdHeader/PackageName")
- pkgGuid = XmlElement(spd, "/PackageSurfaceArea/SpdHeader/GuidValue")
-
-
- for IncludePkgHeader in XmlList(spd, "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader"):
- moduleType = XmlAttribute(IncludePkgHeader, "ModuleType")
- headerFilePath = XmlElementData(IncludePkgHeader)
- headerFilePath = re.sub("Include/", "", headerFilePath, 1)
-
- headerTuple = HeaderFiles.get(moduleType, [])
- headerTuple.append((pkgGuid, headerFilePath))
- HeaderFiles[moduleType] = headerTuple
-
- guidTypes = ["Guid", "Protocol", "Ppi"]
-
- for guidType in guidTypes:
- for guidEntry in XmlList(spd, "/PackageSurfaceArea/" + guidType + "Declarations/Entry"):
- guidCName = XmlElement(guidEntry, "Entry/C_Name")
- GuidList.append(guidCName)
-
- collectIncludeFolder(pkgDirName, guidType, pkgName)
-
- for DecFile in glob.glob(os.path.join(pkgDirName, "*.dec")):
- fileContents = open(DecFile).read()
- for GuidCNameMatch in GuidCNameReg.finditer(fileContents):
- GuidCName = GuidCNameMatch.group(0)
- if GuidCName not in GuidList:
- GuidList.append(GuidCName)
-
-def AddGuidMacro2GuidCName(GuidMacros, GuidCNames):
- for GuidMacro in GuidMacros:
- GuessGuidCName = "g" + GuidMacro.lower().title().replace("_", "")
- if GuessGuidCName in GuidCNames:
- GuidMacro2CName[GuidMacro] = GuessGuidCName
- elif len(GuidCNames) == 1:
- GuidMacro2CName[GuidMacro] = GuidCNames[0]
- else:
- for GuidCName in GuidCNames:
- if GuidCName.lower() == GuessGuidCName.lower():
- GuidMacro2CName[GuidMacro] = GuidCName
- break
- else:
- pass
- #print "No matching GuidMacro %s" % GuidMacro
-
-
-def TranslateGuid(GuidMacroMatch):
- GuidMacro = GuidMacroMatch.group(0)
- return GuidMacro2CName.get(GuidMacro, GuidMacro)
-
-DepexReg = re.compile(r"DEPENDENCY_START(.*?)DEPENDENCY_END", re.DOTALL)
-
-def TranslateDpxSection(fileContents):
- DepexMatch = DepexReg.search(fileContents)
- if not DepexMatch:
- return "", []
-
- fileContents = DepexMatch.group(1)
- fileContents = re.sub(r"\s+", " ", fileContents).strip()
- fileContents = GuidMacroReg.sub(TranslateGuid, fileContents)
- return fileContents, GuidMacroReg.findall(fileContents)
-
-def InitializeAutoGen(workspace, db):
-
-
- for spdFile in XmlList(db, "/FrameworkDatabase/PackageList/Filename"):
- spdFileName = XmlElementData(spdFile)
- collectPackageInfo(os.path.join(workspace, spdFileName))
-
-
- BlockCommentReg = re.compile(r"/\*.*?\*/", re.DOTALL)
- LineCommentReg = re.compile(r"//.*")
- GuidReg = re.compile(r"\b(" + '|'.join(GuidList) + r")\b")
-
- for headerFile in HeaderFileContents:
- Contents = HeaderFileContents[headerFile]
- Contents = BlockCommentReg.sub("", Contents)
- Contents = LineCommentReg.sub("", Contents)
-
- FoundGuids = GuidReg.findall(Contents)
- for FoundGuid in FoundGuids:
- GuidMap[FoundGuid] = "%s/%s" % (headerFile[0], headerFile[1])
- #print "%-40s %s/%s" % (FoundGuid, headerFile[0], headerFile[1])
-
- GuidMacros = GuidMacroReg.findall(Contents)
- GuidCNames = GuidCNameReg.findall(Contents)
-
- for GuidAliasMatch in GuidAliasReg.finditer(Contents):
- Name1, Name2 = GuidAliasMatch.group(1), GuidAliasMatch.group(2)
- GuidAliasList.append((Name1, Name2))
-
- AddGuidMacro2GuidCName(GuidMacros, GuidCNames)
-
-def AddSystemIncludeStatement(moduleType, PackageList):
- IncludeStatement = "\n"
-
- headerList = HeaderFiles.get(moduleType, [])
-
- for pkgGuid in PackageList:
-
- for pkgTuple in headerList:
- if pkgTuple[0] == pkgGuid:
- IncludeStatement += "#include <%s>\n" % pkgTuple[1]
-
- return IncludeStatement
-
-
-def AddLibraryClassStatement(LibraryClassList):
- IncludeStatement = "\n"
- for LibraryClass in LibraryClassList:
- IncludeStatement += "#include <Library/%s.h>\n" % LibraryClass
-
- return IncludeStatement
-
-def AddGuidStatement(GuidList):
- IncludeStatement = "\n"
- GuidIncludeSet = {}
- for Guid in GuidList:
- if Guid in GuidMap:
- GuidIncludeSet[GuidMap[Guid]] = 1
- else:
- print "GUID CName: %s cannot be found in any public header file" % Guid
-
- for GuidInclude in GuidIncludeSet:
- IncludeStatement += "#include <%s>\n" % GuidInclude
-
- return IncludeStatement
-
-DriverBindingMap = {
- "gEfiDriverBindingProtocolGuid" : "EFI_DRIVER_BINDING_PROTOCOL",
- "gEfiComponentNameProtocolGuid" : "EFI_COMPONENT_NAME_PROTOCOL",
- "gEfiDriverConfigurationProtocolGuid" : "EFI_DRIVER_CONFIGURATION_PROTOCOL",
- "gEfiDriverDiagnosticProtocolGuid" : "EFI_DRIVER_CONFIGURATION_PROTOCOL"
- }
-
-def AddDriverBindingProtocolStatement(AutoGenDriverModel):
- InstallStatement = "\n"
- DBindingHandle = "ImageHandle"
- GlobalDeclaration = "\n"
-
-
- for DriverModelItem in AutoGenDriverModel:
-
- if DriverModelItem[1] == "NULL" and DriverModelItem[2] == "NULL" and DriverModelItem[3] == "NULL":
- InstallStatement += " Status = EfiLibInstallDriverBinding (\n"
- InstallStatement += " ImageHandle,\n"
- InstallStatement += " SystemTable,\n"
- InstallStatement += " %s,\n" % DriverModelItem[0]
- InstallStatement += " %s\n" % DBindingHandle
- InstallStatement += " );\n"
- else:
- InstallStatement += " Status = EfiLibInstallAllDriverProtocols (\n"
- InstallStatement += " ImageHandle,\n"
- InstallStatement += " SystemTable,\n"
- InstallStatement += " %s,\n" % DriverModelItem[0]
- InstallStatement += " %s,\n" % DBindingHandle
- InstallStatement += " %s,\n" % DriverModelItem[1]
- InstallStatement += " %s,\n" % DriverModelItem[2]
- InstallStatement += " %s\n" % DriverModelItem[3]
- InstallStatement += " );\n"
-
- InstallStatement += " ASSERT_EFI_ERROR (Status);\n\n"
-
- GlobalDeclaration += "extern EFI_DRIVER_BINDING_PROTOCOL %s;\n" % DriverModelItem[0][1:]
- if (DriverModelItem[1] != "NULL"):
- GlobalDeclaration += "extern EFI_COMPONENT_NAME_PROTOCOL %s;\n" % DriverModelItem[1][1:]
- if (DriverModelItem[2] != "NULL"):
- GlobalDeclaration += "extern EFI_DRIVER_CONFIGURATION_PROTOCOL %s;\n" % DriverModelItem[2][1:]
- if (DriverModelItem[3] != "NULL"):
- GlobalDeclaration += "extern EFI_DRIVER_CONFIGURATION_PROTOCOL %s;\n" % DriverModelItem[3][1:]
-
- DBindingHandle = "NULL"
-
- return (InstallStatement, "", "", GlobalDeclaration)
-
-EventDeclarationTemplate = """
-//
-// Declaration for callback Event.
-//
-VOID
-EFIAPI
-%s (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-"""
-
-def AddBootServiceEventStatement(EventList):
- FinalEvent = ""
- if len(EventList) > 1:
-
- print "Current prototype does not support multi boot service event"
- else:
- FinalEvent = EventList[0]
-
- CreateStatement = "\n"
- CreateStatement += " Status = gBS->CreateEvent (\n"
- CreateStatement += " EVT_SIGNAL_EXIT_BOOT_SERVICES,\n"
- CreateStatement += " EFI_TPL_NOTIFY,\n"
- CreateStatement += " " + FinalEvent + ",\n"
- CreateStatement += " NULL,\n"
- CreateStatement += " &mExitBootServicesEvent\n"
- CreateStatement += " );\n"
- CreateStatement += " ASSERT_EFI_ERROR (Status);\n"
-
- GlobalDefinition = "\n"
- GlobalDefinition += "STATIC EFI_EVENT mExitBootServicesEvent = NULL;\n"
-
- GlobalDeclaration = EventDeclarationTemplate % FinalEvent
-
- DestroyStatement = "\n"
- DestroyStatement += " Status = gBS->CloseEvent (mExitBootServicesEvent);\n"
- DestroyStatement += " ASSERT_EFI_ERROR (Status);\n"
- return (CreateStatement, "", GlobalDefinition, GlobalDeclaration)
-
-def AddVirtualAddressEventStatement(EventList):
- FinalEvent = ""
- if len(EventList) > 1:
- print "Current prototype does not support multi virtual address change event"
- else:
- FinalEvent = EventList[0]
-
- CreateStatement = "\n"
-
- CreateStatement += " Status = gBS->CreateEvent (\n"
- CreateStatement += " EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\n"
- CreateStatement += " TPL_NOTIFY,\n"
- CreateStatement += " " + FinalEvent + ",\n"
- CreateStatement += " NULL,\n"
- CreateStatement += " &mVirtualAddressChangedEvent\n"
- CreateStatement += " );\n"
- CreateStatement += " ASSERT_EFI_ERROR (Status);\n"
-
- GlobalDefinition = "\n"
- GlobalDefinition += "STATIC EFI_EVENT mVirtualAddressChangedEvent = NULL;\n"
-
- GlobalDeclaration = EventDeclarationTemplate % FinalEvent
-
- DestroyStatement = "\n"
- DestroyStatement += " Status = gBS->CloseEvent (mVirtualAddressChangedEvent);\n"
- DestroyStatement += " ASSERT_EFI_ERROR (Status);\n"
-
- return (CreateStatement, "", GlobalDefinition, GlobalDeclaration)
-
-
-EntryPointDeclarationTemplate = """
-//
-// Declaration for original Entry Point.
-//
-EFI_STATUS
-EFIAPI
-%s (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-"""
-
-EntryPointHeader = r"""
-/**
- The user Entry Point for module %s. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-"""
-def AddNewEntryPointContentsStatement (moduleName, EntryPoint, InstallStatement = ""):
- if EntryPoint != "Initialize%s" % moduleName:
- NewEntryPoint = "Initialize%s" % moduleName
- else:
- NewEntryPoint = "NewInitialize%s" % moduleName
-
- EntryPointContents = EntryPointHeader % moduleName
- EntryPointContents += "EFI_STATUS\n"
- EntryPointContents += "EFIAPI\n"
- EntryPointContents += NewEntryPoint + "(\n"
- EntryPointContents += " IN EFI_HANDLE ImageHandle,\n"
- EntryPointContents += " IN EFI_SYSTEM_TABLE *SystemTable\n"
- EntryPointContents += " )\n"
- EntryPointContents += "{\n"
- EntryPointContents += " EFI_STATUS Status;\n"
- EntryPointContents += InstallStatement + "\n"
- GlobalDeclaration = ""
-
- if EntryPoint != "":
- EntryPointContents += " //\n // Call the original Entry Point\n //\n"
- EntryPointContents += " Status = %s (ImageHandle, SystemTable);\n\n" % EntryPoint
- GlobalDeclaration += EntryPointDeclarationTemplate % EntryPoint
-
- EntryPointContents += " return Status;\n"
- EntryPointContents += "}\n"
-
- return (NewEntryPoint, EntryPointContents, GlobalDeclaration)
-
-reFileHeader = re.compile(r"^\s*/\*.*?\*/\s*", re.DOTALL)
-reNext = re.compile(r"#ifndef\s*(\w+)\s*#define\s*\1\s*")
-
-def AddCommonInclusionStatement(fileContents, includeStatement):
- if includeStatement in fileContents:
- return fileContents
-
- insertPos = 0
- matchFileHeader = reFileHeader.search(fileContents)
- if matchFileHeader:
- insertPos = matchFileHeader.end()
-
- matchFileHeader = reNext.search(fileContents, insertPos)
- if matchFileHeader:
- insertPos = matchFileHeader.end()
-
- includeStatement = "\n%s\n\n" % includeStatement
- fileContents = fileContents[0:insertPos] + includeStatement + fileContents[insertPos:]
- return fileContents
-
-# This acts like the main() function for the script, unless it is 'import'ed into another
-# script.
-if __name__ == '__main__':
-
- pass
-
diff --git a/BaseTools/Source/Python/MigrationMsa2Inf/MigrationMsa2Inf.py b/BaseTools/Source/Python/MigrationMsa2Inf/MigrationMsa2Inf.py
deleted file mode 100644
index d69e2308f0..0000000000
--- a/BaseTools/Source/Python/MigrationMsa2Inf/MigrationMsa2Inf.py
+++ /dev/null
@@ -1,2478 +0,0 @@
-#!/usr/bin/env python
-#
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-
-""" This program converts EDK II MSA files into EDK II Extended INF format files """
-
-import os, re, sys, fnmatch, xml.dom.minidom
-from optparse import OptionParser
-from AutoGenExterns import *
-from Common.XmlRoutines import * # XmlParseFile, XmlElement, XmlAttribute, XmlList, XmlElementData, XmlNode
-from Common.EdkIIWorkspace import *
-from Common.BuildVersion import gBUILD_VERSION
-
-versionNumber = ("0.9" + " " + gBUILD_VERSION)
-__version__ = "%prog Version " + versionNumber
-__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
-
-commonHeaderFilename = "CommonHeader.h"
-entryPointFilename = "EntryPoint.c"
-
-AutoGenLibraryMapping = {
- "HiiLib":"HiiLibFramework",
- "EdkIfrSupportLib":"IfrSupportLibFramework",
- "EdkScsiLib":"ScsiLib",
- "EdkUsbLib":"UsbLib",
- "EdkFvbServiceLib":"FvbServiceLib",
- "EdkGraphicsLib":"GraphicsLib"
- }
-
-def myOptionParser():
- """ Argument Parser """
- usage = "%prog [options] -f input_filename"
- parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber))
- parser.add_option("-f", "--file", dest="filename", help="Name of MSA file to convert")
- parser.add_option("-o", "--output", dest="outfile", help="Specific Name of the INF file to create, otherwise it is the MSA filename with the extension repalced.")
- parser.add_option("-a", "--auto", action="store_true", dest="autowrite", default=False, help="Automatically create output files and write the INF file")
- parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, help="Set Interactive mode, user must approve each change.")
- parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")
- parser.add_option("-v", "--verbose", action="count", dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")
- parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Enable printing of debug messages.")
- parser.add_option("-c", "--convert", action="store_true", dest="convert", default=False, help="Convert package: OldMdePkg->MdePkg EdkModulePkg->MdeModulePkg.")
- parser.add_option("-e", "--event", action="store_true", dest="event", default=False, help="Enable handling of Exit Boot Services & Virtual Address Changed Event")
- parser.add_option("-m", "--manual", action="store_true", dest="manual", default=False, help="Generate CommonHeader.txt, user picks up & copy it to a module common header")
- parser.add_option("-w", "--workspace", dest="workspace", default=str(os.environ.get('WORKSPACE')), help="Specify workspace directory.")
- (options, args) = parser.parse_args(sys.argv[1:])
-
- return options,args
-
-
-def openDatabase(f):
- """ Parse XML in the FrameworkDatabase.db file pointed to by f """
- if (options.debug and options.verbose > 1):
- print "Opening the database file:", f
- if os.path.exists(f):
- fdb = XmlParseFile(f)
- else:
- return "None"
- return fdb
-
-def openSpd(s):
- """ Parse XML in the SPD file pointed to by s """
- if (options.debug and options.verbose > 1):
- print "Opening the SPD file:", s
- if os.path.exists(s):
- spd = XmlParseFile(s)
- else:
- return "None"
- return spd
-
-def openMsa(m):
- """ Parse XML in the MSA file pointed to by m """
- if (options.debug and options.verbose > 1):
- print "Opening the MSA file:", m
- if os.path.exists(m):
- msa = XmlParseFile(m)
- else:
- return "None"
- return msa
-
-def AddGuid(ArchList, CName, Usage):
- """ Add a GUID to the Architecture array that the GUID is valid for. """
- if "IA32" in ArchList:
- GuidCNameIa32.insert(0, str(" %-45s # %s" % (CName, Usage)))
- if "X64" in ArchList:
- GuidCNameX64.insert(0, str(" %-45s # %s" % (CName, Usage)))
- if "IPF" in ArchList:
- GuidCNameIPF.insert(0, str(" %-45s # %s" % (CName, Usage)))
- if "EBC" in ArchList:
- GuidCNameEBC.insert(0, str(" %-45s # %s" % (CName, Usage)))
- if "ALL" in ArchList:
- GuidCName.insert(0, str(" %-45s # %s" % (CName, Usage)))
-
-
-def removeDups(CN, ListName):
- """ Remove Duplicate Entries from the Guid List passed in """
- for Entry in ListName[:]:
- if " " + CN + " " in Entry:
- if (options.verbose > 1):
- print "Removing C Name %s Entry from Guids List." % (CN)
- ListName.remove(Entry)
-
-def chkArch(Archs):
- """ Process the supported architectures passed in to combine if possible """
- Archs = Archs.upper()
- if (("IA32" in Archs) & ("X64" in Archs) & ("IPF" in Archs) & ("EBC" in Archs)):
- Archs = "ALL"
- if (len(Archs) == 0):
- Archs = "ALL"
- return Archs
-
-def saveSourceFile(moduleDir, sourceFilename, sourceFileContents):
- newFilename = os.path.join(moduleDir, sourceFilename)
-
- try:
- f = open(newFilename, "w+")
- f.write(sourceFileContents)
- f.close()
- except:
- print "IO error in saving %s" % sourceFilename
-
- return sourceFilename
-
-def openSourceFile(moduleDir, sourceFilename):
- newFilename = os.path.join(moduleDir, sourceFilename)
- sourceFileContents = ""
- try:
- f = open(newFilename, "r")
- sourceFileContents = f.read()
- f.close()
- except:
- print "IO error in opening %s" % sourceFilename
-
- return sourceFileContents
-
-def MatchOption(eline, ToolChainFamily, Targets, Archs, ToolCode, Value):
- IDs = eline.split("_")
-
- if len(IDs) < 5:
- return []
-
- MatchedTargets = []
- if (Targets[0] == "*") or IDs[0] in Targets:
- MatchedTargets.append(IDs[0])
- elif IDs[0] == "*":
- MatchedTargets = Targets
-
- MatchedArchs = []
- if Archs[0] == "*" or IDs[2] in Archs:
- MatchedArchs.append(IDs[2])
- elif IDs[2] == "*":
- MatchedArchs = Archs
-
- if IDs[3] != ToolCode and IDs[3] != "*":
- return []
-
- result = []
- for arch in MatchedArchs:
- for target in MatchedTargets:
- line = "%s:%s_%s_%s_%s_FLAGS = %s" % (ToolChainFamily, target, IDs[1], arch, ToolCode, Value)
- result.append(line)
-
- return result
-
-def main():
-
- AutoGenSource = ""
- AutoGenHeader = ""
- AutoGenDeclaration = ""
- AutoGenModuleFolder = None
-
- workspace = ""
-
- if (options.workspace == None):
- print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory."
- sys.exit(1)
- else:
- workspace = options.workspace
- if (options.debug):
- print "Using Workspace:", workspace
-
- try:
- options.verbose +=1
- except:
- options.verbose = 1
- pass
-
-
- FdbPath = os.path.join(workspace, "Conf")
- FdbPath = os.path.join(FdbPath, "FrameworkDatabase.db")
- if os.path.exists(FdbPath):
- FdbFile = FdbPath
- else:
- print "ERROR: E0001: WORKSPACE does not contain the FrameworkDatabase File.\n Please run EdkSetup from the EDK II install directory.\n"
- sys.exit(1)
-
- Fdb = openDatabase(FdbFile)
- if (Fdb == 'None'):
- print "ERROR: E0002 Could not open the Framework Database file:", FdbFile
- sys.exit(1)
-
- if (options.debug):
- print "FrameworkDataBase.db file:", FdbFile
-
- #
- InitializeAutoGen(workspace, Fdb)
-
- if (options.filename):
- filename = options.filename
- if ((options.verbose > 1) | (options.autowrite)):
- print "Filename:", filename
- else:
- print "ERROR: E0001 - You must specify an input filename"
- sys.exit(1)
-
- if (options.outfile):
- outputFile = options.outfile
- else:
- outputFile = filename.replace('.msa', '.inf')
-
- if ((options.verbose > 2) or (options.debug)):
- print "Output Filename:", outputFile
-
- Msa = openMsa(filename)
- if (Msa == 'None'):
- ## Maybe developer think WORKSPACE macro is the root directory of file name
- ## So we will try to add WORKSPACE path into filename
- MsaFileName = ""
- MsaFileName = os.path.join(workspace, filename)
- Msa = openMsa(MsaFileName)
- if (Msa == 'None'):
- print "ERROR: E0002: Could not open the file:", filename
- sys.exit(1)
-
- AutoGenModuleFolder = os.path.dirname(filename)
-
- MsaHeader = "/ModuleSurfaceArea/MsaHeader/"
- MsaDefs = "/ModuleSurfaceArea/ModuleDefinitions/"
- BaseName = str(XmlElement(Msa, MsaDefs + "OutputFileBasename")).strip()
-
- if (len(BaseName) < 1):
- BaseName = str(XmlElement(Msa, MsaHeader + "BaseName")).strip()
- BaseName = re.sub(' ', '_', BaseName)
-
- GuidValue = str(XmlElement(Msa, MsaHeader + "GuidValue")).strip()
- VerString = str(XmlElement(Msa, MsaHeader + "Version")).strip()
- ModType = str(XmlElement(Msa, MsaHeader + "ModuleType")).strip()
- CopyRight = str(XmlElement(Msa, MsaHeader + "Copyright")).strip()
- Abstract = str(XmlElement(Msa, MsaHeader + "Abstract")).strip()
- Description = str(XmlElement(Msa, MsaHeader + "Description")).strip().replace(" ", " ").replace(" ", " ").replace(" ", " ")
- if not CopyRight.find("2007"):
- CopyRight = CopyRight.replace("2006", "2007")
- License = str(XmlElement(Msa, MsaHeader + "License")).strip().replace(" ", " ")
- MsaDefs = "/ModuleSurfaceArea/ModuleDefinitions/"
- BinModule = ""
- try:
- BinModule = str(XmlElement(Msa, MsaDefs + "BinaryModule")).strip()
- except:
- pass
-
- SupportedArchitectures = ""
- try:
- SupportedArchitectures = str(XmlElement(Msa, MsaDefs + "SupportedArchitectures")).strip()
- except:
- pass
-
- DefinesComments = []
- if (len(SupportedArchitectures) > 0):
- DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
- DefinesComments.append("# VALID_ARCHITECTURES = " + SupportedArchitectures + "\n")
- DefinesComments.append("#\n")
-
- MsaExtern = "/ModuleSurfaceArea/Externs/"
- PcdIsDriver = ""
- try:
- PcdIsDriver = str(XmlElement(Msa, MsaExtern + "PcdIsDriver")).strip()
- except:
- pass
-
- SpecList = []
- List = []
- try:
- List = XmlList(Msa, MsaExtern + "Specification")
- except:
- pass
-
- if (len(List) > 0):
- for spec in List[:]:
- SpecList.insert(0, str(XmlElementData(spec)).strip())
-
- DriverModules = []
- LibraryModules = []
- Externlist = []
- Flag = (DefinesComments == [])
-
- # Data structure to insert autogen code
- AutoGenDriverModel = []
- AutoGenExitBootServices = []
- AutoGenVirtualAddressChanged = []
- AutoGenEntryPoint = ""
- AutoGenUnload = ""
- AutoGenGuid = []
- AutoGenLibClass = []
- AutoGenPackage = []
- AutoGenSourceFiles = []
- OldEntryPoint = ""
- OldUnload = ""
-
- try:
- Externlist = XmlList(Msa, MsaExtern + "Extern")
- except:
- pass
-
- if (len(Externlist) > 0):
- if (options.debug and options.verbose > 2):
- print "In Extern Parsing Routine"
- for extern in Externlist:
- EntryPoint = ""
- Unload = ""
- DBinding = ""
- CompName = ""
- Diag = ""
- Config = ""
- Constr = ""
- Destr = ""
- CallBack = ""
- lFlag = False
- AutoGenDriverModelItem = []
- try:
- EntryPoint = str(XmlElementData(extern.getElementsByTagName("ModuleEntryPoint")[0])).strip()
- AutoGenEntryPoint = EntryPoint
- #DriverModules.append(" %-30s = %s\n" % ("ENTRY_POINT" , EntryPoint))
- except:
- pass
-
- try:
- Unload = str(XmlElementData(extern.getElementsByTagName("ModuleUnloadImage")[0])).strip()
- AutoGenUnload = Unload
- DriverModules.append(" %-30s = %s\n" % ("UNLOAD_IMAGE", Unload))
- except:
- pass
-
- try:
- DBinding = str(XmlElementData(extern.getElementsByTagName("DriverBinding")[0])).strip()
- AutoGenDriverModelItem.append("&" + DBinding)
- DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_BINDING", DBinding))
- lFlag = True
- except:
- pass
-
- try:
- CompName = str(XmlElementData(extern.getElementsByTagName("ComponentName")[0])).strip()
- AutoGenDriverModelItem.append("&" + CompName)
- DefinesComments.append("# %-29s = %-45s\n" % ("COMPONENT_NAME", CompName))
- lFlag = True
- except:
- if lFlag:
- AutoGenDriverModelItem.append("NULL")
- pass
-
- try:
- Config = str(XmlElementData(extern.getElementsByTagName("DriverConfig")[0])).strip()
- AutoGenDriverModelItem.append("&" + Config)
- DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_CONFIG", Config))
- lFlag = True
- except:
- if lFlag:
- AutoGenDriverModelItem.append("NULL")
- pass
-
- try:
- Diag = str(XmlElementData(extern.getElementsByTagName("DriverDiag")[0])).strip()
- AutoGenDriverModelItem.append("&" + Diag)
- DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_DIAG", Diag))
- lFlag = True
- except:
- if lFlag:
- AutoGenDriverModelItem.append("NULL")
- pass
-
- if len(AutoGenDriverModelItem) > 0:
- AutoGenDriverModel.append(AutoGenDriverModelItem)
-
- try:
- Constr = str(XmlElementData(extern.getElementsByTagName("Constructor")[0])).strip()
- LibraryModules.append(" %-30s = %s\n" % ("CONSTRUCTOR", Constr))
- except:
- pass
-
- try:
- Destr = str(XmlElementData(extern.getElementsByTagName("Destructor")[0])).strip()
- LibraryModules.append(" %-30s = %s\n" % ("DESTRUCTOR", Destr))
- except:
- pass
-
- try:
- CallBack = str(XmlElement(extern, "Extern/SetVirtualAddressMapCallBack")).strip()
- if CallBack != "":
- AutoGenVirtualAddressChanged.append(CallBack)
- DefinesComments.append("# %-29s = %-45s\n" % ("VIRTUAL_ADDRESS_MAP_CALLBACK", CallBack))
- lFlag = True
- except:
-
- pass
-
- try:
- CallBack = str(XmlElement(extern, "Extern/ExitBootServicesCallBack")).strip()
- if CallBack != "":
- AutoGenExitBootServices.append(CallBack)
- DefinesComments.append("# %-29s = %-45s\n" % ("EXIT_BOOT_SERVICES_CALLBACK", CallBack))
- lFlag = True
- except:
- pass
-
-
- Flag = False
-
- """ Get the Module's custom build options """
- MBOlines = []
- MBO = "/ModuleSurfaceArea/ModuleBuildOptions/Options/Option"
- mboList = []
- try:
- mboList = XmlList(Msa, MBO)
- except:
- pass
-
- if (len(mboList) > 0):
- for Option in mboList:
- Targets = []
- Archs = []
-
- bt = ""
- try:
- bt = str(Option.getAttribute("BuildTargets"))
- except:
- pass
-
- if (len(bt) > 0):
- if (re.findall(" ", bt) > 0):
- Targets = bt.split()
- else:
- Targets.insert(0, bt)
- else:
- Targets.insert(0, "*")
-
- if (options.debug and options.verbose > 2):
- print "Targets", len(Targets), Targets
-
- pro = ""
- try:
- pro = Option.getAttribute("SupArchList")
- if (re.findall(" ", pro) > 0):
- Archs = pro.split()
- elif (re.findall(",", pro) > 0):
- Archs = pro.split(",")
- except:
- pass
-
- if (len(pro) == 0):
- Archs.insert(0, "*")
-
- if (options.debug and options.verbose > 2):
- print "Archs", len(Archs), Archs
-
- ToolCode = ""
- try:
- ToolCode = str(Option.getAttribute("ToolCode"))
- except:
- pass
-
- if (len(ToolCode) == 0):
- ToolCode="*"
-
- value = ""
- try:
- value = str(XmlElementData(Option))
- except:
- pass
- Tags = []
- TagName = ""
- try:
- TagName = str(Option.getAttribute("TagName"))
- except:
- pass
-
- if (len(TagName) > 0) :
- if (options.debug and options.verbose > 2):
- print "TagName was defined:", TagName
- Tags.insert(0, TagName)
- else:
- if (options.debug and options.verbose > 2):
- print "TagName was NOT defined!"
- TagName = "*"
- Tags.insert(0, "*")
-
- Family = ""
- try:
- Family = str(Option.getAttribute("ToolChainFamily")).strip()
- except:
- pass
-
- if (len(Family) > 0):
- if (options.debug):
- print "Searching tools_def.txt for Tool Tags that belong to:", Family, "family"
- TCF = []
- tdFile = ""
- tdPath = os.path.join(workspace, "Tools")
- tdPath = os.path.join(tdPath, "Conf")
- tdPath = os.path.join(tdPath, "tools_def.txt")
- tdPath = tdPath.replace("\\", "/")
- if os.path.exists(tdPath):
- tdFile = tdPath
- else:
- tdPath = os.path.join(workspace, "Conf")
- tdPath = os.path.join(tdPath, "tools_def.txt")
- if os.path.exists(tdPath):
- tdFile = tdPath
- else:
- print "ERROR: E0001: WORKSPACE does not contain the tools_def.txt File.\n Please run EdkSetup from the EDK II install directory.\n"
- sys.exit(1)
-
- if (options.debug and options.verbose > 2):
- print "Opening:", tdFile
-
- TagNameList = []
- tools_def = open(tdFile, "r")
- for tdline in tools_def:
- if "# " in tdline:
- continue
- if "FAMILY" in tdline:
- if (options.debug and options.verbose > 2):
- print "Testing for FAMILY:", Family, "in the line:", tdline.strip()
- if Family in tdline:
- enter = tdline.split("=")[0]
- if (options.debug and options.verbose > 2):
- print "Adding TNL:", tdline
- TagNameList.insert(0, enter)
- tools_def.close()
-
- if (options.debug and options.verbose > 2):
- print "TagNameList:", TagNameList
-
- olinesSet = {}
- for eline in TagNameList:
- if "# " in eline:
- continue
- if (options.debug and options.verbose > 2):
- print "ToolsDef entry:", eline
-
- olines = MatchOption(eline, Family, Targets, Archs, ToolCode, value)
- for oline in olines:
- olinesSet[oline] = 1
-
- for oline in olinesSet:
- if (options.debug and options.verbose > 2):
- print "Adding:", str(oline)
- MBOlines.insert(0, oline)
- else:
- for targ in Targets:
- for arch in Archs:
- oline = " %s_%s_%s_%s_FLAGS = %s" % (targ, Tags[0], arch, str(ToolCode), str(Value))
- if (options.debug and options.verbose > 2):
- print "Adding:", str(oline)
- MBOlines.insert(0, oline)
-
-
-
-
- for tag in Tags:
- for targ in Targets:
- for arch in Archs:
- oline = " " + str(targ) + "_" + str(tag) + "_" + str(arch) + "_" + str(ToolCode) + "_FLAGS = " + str(value)
- if (options.debug and options.verbose > 2):
- print "Adding:", str(oline)
- #MBOlines.insert(0, oline)
-
-
- """ Get the Library Class information """
- MsaLcDefs = "/ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
- LcDefList = []
- try:
- LcDefList = XmlList(Msa, MsaLcDefs)
- except:
- pass
-
- IamLibrary = []
- LibClassList = []
- LibClassListIa32 = []
- LibClassListX64 = []
- LibClassListIpf = []
- LibClassListEbc = []
-
-
- if (len(LcDefList) > 0):
- for Lc in LcDefList:
- lcKeyword = ""
- try:
- lcKeyword = str(XmlElementData(Lc.getElementsByTagName("Keyword")[0]))
- except:
- raise SyntaxError, "The MSA is not correctly formed, a Library Class Keyword Element is required"
-
- lcUsage = ""
- try:
- lcUsage = str(XmlAttribute(Lc, "Usage"))
- except:
- raise SyntaxError, "The MSA is not correctly formed, a Usage Attribute is required for all Library Class Elements"
-
- Archs = ""
- try:
- Archs = str(XmlAttribute(Lc, "SupArchList"))
- except:
- pass
-
- Archs = chkArch(Archs)
-
- if (options.debug and options.verbose > 2):
- print "Attr: ", lcUsage, lcKeyword, Archs
-
- if (options.convert):
- lcKeyword = AutoGenLibraryMapping.get(lcKeyword, lcKeyword)
-
- if re.findall("PRODUCED", lcUsage, re.IGNORECASE):
- try:
- lcSupModList = ""
-
- try:
- lcSupModList = str(XmlAttribute(Lc, "SupModuleList"))
- except:
- lcSupModList = ""
- pass
-
- lcLine = lcKeyword
- AutoGenLibClass.append(lcKeyword)
- if len(lcSupModList) > 0:
- lcLine = lcLine + "|" + lcSupModList
- IamLibrary.insert(0, lcLine)
- except:
- pass
- elif lcKeyword != "UefiDriverModelLib":
- AutoGenLibClass.append(lcKeyword)
- # This section handles the library classes that are CONSUMED
- if "IA32" in Archs:
- LibClassListIa32.insert(0, lcKeyword)
- if "X64" in Archs:
- LibClassListX64.insert(0, lcKeyword)
- if "IPF" in Archs:
- LibClassListIpf.insert(0, lcKeyword)
- if "EBC" in Archs:
- LibClassListEbc.insert(0, lcKeyword)
- if "ALL" in Archs:
- LibClassList.insert(0, lcKeyword)
- if len(AutoGenDriverModel) > 0 and "UefiLib" not in LibClassList:
- AutoGenLibClass.append("UefiLib")
- LibClassList.insert(0, "UefiLib")
-
- AutoGenDxsFiles = []
- """ Get the Source File list """
- SrcFilenames = []
- SrcFilenamesIa32 = []
- SrcFilenamesX64 = []
- SrcFilenamesIpf = []
- SrcFilenamesEbc = []
- SrcFiles = "/ModuleSurfaceArea/SourceFiles/Filename"
- SrcList = []
- try:
- SrcList = XmlList(Msa, SrcFiles)
- except:
- pass
-
- if (len(SrcList) > 0):
- for fn in SrcList:
- file = ""
- Archs = ""
-
- try:
- Archs = fn.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- file = str(XmlElementData(fn))
- except:
- pass
-
- if file.endswith(".dxs"):
- AutoGenDxsFiles.append((file, Archs))
- else:
- AutoGenSourceFiles.append(file)
- if "IA32" in Archs:
- SrcFilenamesIa32.insert(0, file)
- if "X64" in Archs:
- SrcFilenamesX64.insert(0, file)
- if "IPF" in Archs:
- SrcFilenamesIpf.insert(0, file)
- if "EBC" in Archs:
- SrcFilenamesEbc.insert(0, file)
- if "ALL" in Archs:
- SrcFilenames.insert(0, file)
-
- """ Package Dependency section """
- DbPkgList = "/FrameworkDatabase/PackageList/Filename"
- WorkspacePkgs = []
- try:
- WorkspacePkgs = XmlList(Fdb, DbPkgList)
- except:
- print "Could not tet the package data from the database"
- sys.exit(1)
-
- PkgDb = []
- HeaderLocations = []
-
- if (options.debug and options.verbose > 1):
- print "Found %s packages in the WORKSPACE" % (len(WorkspacePkgs))
-
- Dirs = []
- GuidDecls = []
- if (len(WorkspacePkgs) > 0):
- SpdHeader = "/PackageSurfaceArea/SpdHeader/"
- for Pkg in WorkspacePkgs[:]:
- PackageGuid = ""
- PackageVersion = ""
- file = ""
- try:
- file = str(XmlElementData(Pkg))
- except:
- pass
-
- if (options.debug and options.verbose > 2):
- print "PKG:", file
-
- if fnmatch.fnmatch(file, "*.dec"):
- print "parsing " + os.path.join(workspace, file)
- PackageGuid = ""
- PackageVersion = ""
- try:
- Lines = open(os.path.join(workspace, file)).readlines()
- except:
- print "Could not parse the Package file:", file
- sys.exit(1)
-
- for Line in Lines:
- Line = Line.split("#")[0]
- Items = Line.split("=")
- if len(Items) != 2:
- continue
-
- Key = Items[0].strip().upper()
- if Key == "PACKAGE_GUID":
- PackageGuid = Items[1].strip()
- if Key == "PACKAGE_VERSION":
- PackageVersion = Items[1].strip()
-
- else:
- Spd = openSpd(os.path.join(workspace, file))
- if (Spd == 'None'):
- print "Could not parse the Package file:", file
- sys.exit(1)
-
- path = os.path.split(file)[0]
- file = file.replace(".nspd", ".dec")
- file = file.replace(".spd", ".dec")
-
- try:
- PackageGuid = str(XmlElement(Spd, SpdHeader + "GuidValue"))
- except:
- pass
-
- try:
- PackageVersion = str(XmlElement(Spd, SpdHeader + "Version"))
- except:
- pass
-
- file = file + "|" + PackageGuid + "|" + PackageVersion
- PkgDb.insert(0, file)
-
- GuidEntries = []
- try:
- GuidEntries = XmlList(Spd, "/PackageSurfaceArea/GuidDeclarations/Entry")
- except:
- pass
-
- if (len(GuidEntries) > 0):
- for Entry in GuidEntries[:]:
- try:
- GuidDecls.append(str(XmlElementData(Entry.getElementsByTagName("C_Name")[0])).strip())
- except:
- pass
-
-
- pHdrs = []
- try:
- pHdrs = XmlList(Spd, "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader")
- except:
- pass
-
- if (len(pHdrs) > 0):
- for Hdr in pHdrs[:]:
- try:
- ModTypeList = str(Hdr.getAttribute("ModuleType"))
- if (ModType in ModTypeList):
- HeaderName= str(XmlElementData(Hdr))[0]
- Dirs.insert(0, os.path.join(packagepath,str(os.path.split(HeaderName))))
- except:
- pass
-
- # Get the Guid:Header from the Packages
- SpdLcDec = "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass"
- lcList = []
- try:
- lcList = XmlList(Spd, SpdLcDec)
- except:
- pass
-
- if (len(lcList) > 0):
- for Lc in lcList[:]:
- Name = ""
- try:
- Name = Lc.getAttribute("Name")
- except:
- pass
-
- Header = ""
- try:
- Header = XmlElementData(Lc.getElementsByTagName("IncludeHeader")[0])
- except:
- pass
-
- if ((len(Name) > 0) and (len(Header) > 0)):
- line = Name + "|" + os.path.join(path, Header)
- if (options.debug and options.verbose > 2):
- print "Adding:", line
- HeaderLocations.insert(0, line)
-
- ishList = []
- try:
- IndStdHeaders = "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader"
- ishList = XmlList(Spd, IndStdHeaders)
- except:
- pass
-
- if (len(ishList) > 0):
- for Lc in ishList[:]:
- Name = ""
- try:
- Name = str(Lc.getAttribute("Name")).strip()
- except:
- pass
-
- Header = ""
- try:
- Header = str(XmlElementData(Lc.getElementsByTagName("IncludeHeader")[0])).strip()
- except:
- pass
-
- if ((len(Name) > 0) and (len(Header) > 0)):
- line = Name + "|" + os.path.join(path, Header)
- HeaderLocations.insert(0, str(line))
-
- PkgList = []
- PkgListIa32 = []
- PkgListX64 = []
- PkgListIpf = []
- PkgListEbc = []
- Pkgs = "/ModuleSurfaceArea/PackageDependencies/Package"
- pkgL = []
- try:
- pkgL = XmlList(Msa, Pkgs)
- except:
- pass
-
-
- gUnknownPkgGuid = {}
- if (len(pkgL) > 0):
- if (options.debug and options.verbose > 1):
- print "Found %s packages in the module" % (len(pkgL))
- for pkg in pkgL[:]:
- Archs = ""
- pkgGuid = ""
- pkgVer = ""
-
- FindPkgGuid = False
- try:
- Archs = pkg.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- pkgGuid = pkg.getAttribute("PackageGuid")
- except:
- pass
-
- if options.convert:
- if pkgGuid.lower() == "5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec":
- pkgGuid = "1E73767F-8F52-4603-AEB4-F29B510B6766"
- if pkgGuid.lower() == "68169ab0-d41b-4009-9060-292c253ac43d":
- pkgGuid = "BA0D78D6-2CAF-414b-BD4D-B6762A894288"
- AutoGenPackage.append(pkgGuid)
- try:
- pkgVer = pkg.getAttribute("PackageVersion")
- except:
- pass
-
- for PkgEntry in PkgDb[:]:
- if pkgGuid in PkgEntry:
- if len(pkgVer) > 0:
- if pkgVer in PkgEntry:
- FindPkgGuid = True
- if "IA32" in Archs:
- PkgListIa32.insert(0, PkgEntry.split("|")[0])
- if "X64" in Archs:
- PkgListX64.insert(0, PkgEntry.split("|")[0])
- if "IPF" in Archs:
- PkgListIpf.insert(0, PkgEntry.split("|")[0])
- if "EBC" in Archs:
- PkgListEbc.insert(0, PkgEntry.split("|")[0])
- if "ALL" in Archs:
- PkgList.insert(0, PkgEntry.split("|")[0])
- else:
- FindPkgGuid = True
- if "IA32" in Archs:
- PkgListIa32.insert(0, PkgEntry.split("|")[0])
- if "X64" in Archs:
- PkgListX64.insert(0, PkgEntry.split("|")[0])
- if "IPF" in Archs:
- PkgListIpf.insert(0, PkgEntry.split("|")[0])
- if "EBC" in Archs:
- PkgListEbc.insert(0, PkgEntry.split("|")[0])
- if "ALL" in Archs:
- PkgList.insert(0, PkgEntry.split("|")[0])
-
- if not FindPkgGuid:
- gUnknownPkgGuid[str(pkgGuid)] = 1
-
- for UnknownPkgGuid in gUnknownPkgGuid:
- print "Cannot resolve package dependency Guid:", UnknownPkgGuid
-
- PkgList.reverse()
- PkgListIa32.reverse()
- PkgListX64.reverse()
- PkgListIpf.reverse()
- PkgListEbc.reverse()
- if (options.debug):
- print "Package List:", PkgList
-
-
-
- """ Setup the Global GuidCName arrays that will hold data from various MSA locations """
- global GuidCName
- global GuidCNameIa32
- global GuidCNameX64
- global GuidCNameIPF
- global GuidCNameEBC
- GuidCName = []
- GuidCNameIa32 = []
- GuidCNameX64 = []
- GuidCNameIPF = []
- GuidCNameEBC = []
-
- """ Check for the GUIDs Element """
- Guids = "/ModuleSurfaceArea/Guids/GuidCNames"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- except:
- pass
-
- try:
- CName = str(XmlElementData(Guid.getElementsByTagName("GuidCName")[0]))
- if CName in GuidDecls:
- if (options.debug and options.verbose > 1):
- print "Guids Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- else:
- raise AssertionError, "Guid %s defined in %s is not declared in any package (.dec) file!" % (CName, filename)
- except:
- pass
-
- if (options.debug and options.verbose > 2):
- print "Guid C Name List:", GuidCName
-
- """ Check for Events """
- Guids = "/ModuleSurfaceArea/Events/CreateEvents/EventTypes"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- Type = str(XmlElementData(Guid.getElementsByTagName("EventType")[0]))
- Usage += " Create Event: " + Type
- except:
- pass
-
- try:
- CName = str(Guid.getAttribute("EventGuidCName"))
- if CName in GuidDecls:
- if (options.debug and options.verbose > 1):
- print "CreateEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- else:
- if (len(DefinesComments) == 0):
- DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
- DefinesComments.append("# Create Event Guid C Name: " + CName + " Event Type: " + Type + "\n")
- Flag = True
- except:
- pass
-
- if (Flag):
- DefinesComments.append("#\n")
- Flag = False
-
- Guids = "/ModuleSurfaceArea/Events/SignalEvents/EventTypes"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- Type = str(XmlElementData(Guid.getElementsByTagName("EventType")[0]))
- Usage += " Signal Event: " + Type
- except:
- pass
-
- try:
- CName = str(Guid.getAttribute("EventGuidCName"))
- if CName in GuidDecls:
- if (options.debug and options.verbose > 1):
- print "SignalEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- else:
- if (len(DefinesComments) == 0):
- DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
- DefinesComments.append("# Signal Event Guid C Name: " + CName + " Event Type: " + Type + "\n")
- Flag = True
- except:
- pass
-
- if (Flag):
- DefinesComments.append("#\n")
- Flag = False
-
- """ Check the HOB guids """
- Guids = "/ModuleSurfaceArea/Hobs/HobTypes"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- Type = str(XmlElementData(Guid.getElementsByTagName("HobType")[0]))
- Usage += " Hob: " + Type
- except:
- pass
-
- try:
- CName = str(Guid.getAttribute("HobGuidCName"))
- if CName in GuidDecls:
- if (options.debug and options.verbose > 1):
- print "Hob Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- else:
- if (len(DefinesComments) == 0):
- DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
- DefinesComments.append("# HOB Guid C Name: " + CName + " Hob Type: " + Type + "\n")
- Flag = True
- except:
- if (len(DefinesComments) == 0):
- DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
- DefinesComments.append("# HOB: " + Type + "\n")
- Flag = True
- pass
-
- if (Flag):
- DefinesComments.append("#\n")
- Flag = False
-
- """ Check for the SystemTables Element """
- Guids = "/ModuleSurfaceArea/SystemTables/SystemTableCNames"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- Usage += " System Table"
- except:
- pass
-
- try:
- CName = str(XmlElementData(Guid.getElementsByTagName("SystemTableCName")[0]))
- if (options.debug and options.verbose > 1):
- print "System Table Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- except:
- pass
-
- """ Check for the DataHubs Element """
- Guids = "/ModuleSurfaceArea/DataHubs/DataHubRecord"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- Usage += " Data Hub"
- except:
- pass
-
- try:
- CName = str(XmlElementData(Guid.getElementsByTagName("DataHubCName")[0]))
- if (options.debug and options.verbose > 1):
- print "Data Hub Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- except:
- pass
-
- """ Check for the HiiPackages Element """
- Guids = "/ModuleSurfaceArea/HiiPackages/HiiPackage"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- Usage += " HII Formset"
- except:
- pass
-
- try:
- CName = str(XmlElementData(Guid.getElementsByTagName("HiiCName")[0]))
- if (options.debug and options.verbose > 1):
- print "Hii Formset Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- except:
- pass
-
- """ Check for the Variables Element """
- Guids = "/ModuleSurfaceArea/Variables/Variable"
- GuidList = []
- try:
- GuidList = XmlList(Msa, Guids)
- except:
- pass
-
- if (len(GuidList) > 0):
- for Guid in GuidList:
- Archs = ""
- Usage = ""
- CName = ""
- VariableName = ""
-
- try:
- Archs = Guid.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Guid.getAttribute("Usage")
- except:
- pass
-
- try:
- VariableName = str(XmlElementData(Guid.getElementsByTagName("VariableName")[0]))
- CName = str(XmlElementData(Guid.getElementsByTagName("GuidC_Name")[0]))
-
- HexData = VariableName.strip().split()
- UniString = " L\""
- for dig in HexData[:]:
- UniString += str(unichr(eval(dig)))
- UniString += "\""
-
- Usage += UniString
-
- if CName in set(GuidDecls):
- removeDups(CName, GuidCName)
- removeDups(CName, GuidCNameIa32)
- removeDups(CName, GuidCNameX64)
- removeDups(CName, GuidCNameIPF)
- removeDups(CName, GuidCNameEBC)
-
- if (options.debug):
- print "Variable Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
- AddGuid(Archs, CName, Usage)
- AutoGenGuid.append(CName)
- else:
- if (len(DefinesComments) == 0):
- DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
- DefinesComments.append("# Variable Guid C Name: " + CName + " Variable Name:" + UniString + "\n")
- Flag = True
- except:
- pass
-
- if (Flag):
- DefinesComments.append("#\n")
- Flag = False
-
- """ Check for the Protocol Element """
- Protocols = "/ModuleSurfaceArea/Protocols/Protocol"
- ProtocolList = []
- ProtocolCName = []
- ProtocolCNameIa32 = []
- ProtocolCNameX64 = []
- ProtocolCNameIPF = []
- ProtocolCNameEBC = []
-
- try:
- ProtocolList = XmlList(Msa, Protocols)
- except:
- pass
-
- if (len(ProtocolList) > 0):
- for Protocol in ProtocolList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Protocol.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Protocol.getAttribute("Usage")
- except:
- pass
-
- try:
- CName = str(XmlElementData(Protocol.getElementsByTagName("ProtocolCName")[0]))
- AutoGenGuid.append(CName)
- removeDups(CName, GuidCName)
- removeDups(CName, GuidCNameIa32)
- removeDups(CName, GuidCNameX64)
- removeDups(CName, GuidCNameIPF)
- removeDups(CName, GuidCNameEBC)
-
- if (options.debug and options.verbose > 1):
- print "Found %s - %s - %s " % (CName, Usage, str(len(Archs)))
-
- if "IA32" in Archs:
- ProtocolCNameIa32.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
- if "X64" in Archs:
- ProtocolCNameX64.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
- if "IPF" in Archs:
- ProtocolCNameIPF.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
- if "EBC" in Archs:
- ProtocolCNameEBC.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
- if "ALL" in Archs:
- ProtocolCName.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
- except:
- pass
-
-
- Protocols = "/ModuleSurfaceArea/Protocols/ProtocolNotify"
- try:
- ProtocolList = XmlList(Msa, Protocols)
- except:
- pass
-
- if (len(ProtocolList) > 0):
- for Protocol in ProtocolList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Protocol.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Protocol.getAttribute("Usage")
- except:
- pass
-
- try:
- CName = str(XmlElementData(Protocol.getElementsByTagName("ProtocolNotifyCName")[0]))
- AutoGenGuid.append(CName)
- removeDups(CName, GuidCName)
- removeDups(CName, GuidCNameIa32)
- removeDups(CName, GuidCNameX64)
- removeDups(CName, GuidCNameIPF)
- removeDups(CName, GuidCNameEBC)
-
- if "IA32" in Archs:
- ProtocolCNameIa32.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
- if "X64" in Archs:
- ProtocolCNameX64.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
- if "IPF" in Archs:
- ProtocolCNameIPF.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
- if "EBC" in Archs:
- ProtocolCNameEBC.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
- if "ALL" in Archs:
- ProtocolCName.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
- except:
- pass
-
- """ Check for the PPIs Element """
- PPIs = "/ModuleSurfaceArea/PPIs/Ppi"
- PPIsList = []
- PpiCName = []
- PpiCNameIa32 = []
- PpiCNameX64 = []
- PpiCNameIPF = []
- PpiCNameEBC = []
-
- try:
- PPIsList = XmlList(Msa, PPIs)
- except:
- pass
-
- if (len(PPIsList) > 0):
- for Ppi in PPIsList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = str(Ppi.getAttribute("SupArchList"))
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = str(Ppi.getAttribute("Usage"))
- except:
- pass
-
- try:
- CName = str(XmlElementData(Ppi.getElementsByTagName("PpiCName")[0])).strip()
- AutoGenGuid.append(CName)
- removeDups(CName, GuidCName)
- removeDups(CName, GuidCNameIa32)
- removeDups(CName, GuidCNameX64)
- removeDups(CName, GuidCNameIPF)
- removeDups(CName, GuidCNameEBC)
-
- if "IA32" in Archs:
- PpiCNameIa32.insert(0, " %-45s # PPI %s" % (CName, Usage))
- if "X64" in Archs:
- PpiCNameX64.insert(0, " %-45s # PPI %s" % (CName, Usage))
- if "IPF" in Archs:
- PpiCNameIPF.insert(0, " %-45s # PPI %s" % (CName, Usage))
- if "EBC" in Archs:
- PpiCNameEBC.insert(0, " %-45s # PPI %s" % (CName, Usage))
- if "ALL" in Archs:
- PpiCName.insert(0, " %-45s # PPI %s" % (CName, Usage))
- except:
- pass
-
-
- PPIs = "/ModuleSurfaceArea/PPIs/PpiNotify"
- try:
- PPIsList = XmlList(Msa, PPIs)
- except:
- pass
-
- if (len(PPIsList) > 0):
- for Ppi in PPIsList:
- Archs = ""
- Usage = ""
- CName = ""
-
- try:
- Archs = Ppi.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- Usage = Ppi.getAttribute("Usage")
- except:
- pass
-
- try:
- CName = str(XmlElementData(Ppi.getElementsByTagName("PpiNotifyCName")[0]))
- AutoGenGuid.append(CName)
- removeDups(CName, GuidCName)
- removeDups(CName, GuidCNameIa32)
- removeDups(CName, GuidCNameX64)
- removeDups(CName, GuidCNameIPF)
- removeDups(CName, GuidCNameEBC)
-
- if "IA32" in Archs:
- PpiCNameIa32.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
- if "X64" in Archs:
- PpiCNameX64.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
- if "IPF" in Archs:
- PpiCNameIPF.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
- if "EBC" in Archs:
- PpiCNameEBC.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
- if "ALL" in Archs:
- PpiCName.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
- except:
- pass
-
-
- """ Get the PCD entries now """
- PcdCoded = "/ModuleSurfaceArea/PcdCoded/PcdEntry"
- PcdList = []
- try:
- PcdList = XmlList(Msa, PcdCoded)
- except:
- pass
-
- (PcdFF, PcdFFIa32, PcdFFX64, PcdFFIpf, PcdFFEbc) = ([],[],[],[],[])
- (PcdFAB, PcdFABIa32, PcdFABX64, PcdFABIpf, PcdFABEbc) = ([],[],[],[],[])
- (PcdPIM, PcdPIMIa32, PcdPIMX64, PcdPIMIpf, PcdPIMEbc) = ([],[],[],[],[])
- (PcdDY, PcdDYIa32, PcdDYX64, PcdDYIpf, PcdDYEbc) = ([],[],[],[],[])
- (PcdDYE, PcdDYEIa32, PcdDYEX64, PcdDYEIpf, PcdDYEEbc) = ([],[],[],[],[])
-
- if (len(PcdList) > 0):
- for Pcd in PcdList:
- Archs = ""
- Usage = ""
- CName = ""
- DefVal = ""
-
- try:
- Archs = Pcd.getAttribute("SupArchList")
- except:
- pass
-
- Archs = chkArch(Archs)
-
- try:
- ItemType = Pcd.getAttribute("PcdItemType")
- except:
- pass
-
- try:
- CName = str(XmlElementData(Pcd.getElementsByTagName("C_Name")[0]))
- except:
- raise SyntaxError, "ERROR: MSA has a PCD with no Pcd C_Name defined"
-
- try:
- TSGC = str(XmlElementData(Pcd.getElementsByTagName("TokenSpaceGuidCName")[0]))
- except:
- pass
-
- try:
- DefVal = str(XmlElementData(Pcd.getElementsByTagName("DefaultValue")))
- except:
- pass
-
- if (len(DefVal) > 0):
- line = TSGC + "." + CName + "|" + DefVal
- else:
- line = TSGC + "." + CName
-
- if (ItemType == "FEATURE_FLAG"):
- if ("IA32" in Archs):
- PcdFFIa32.insert(0, line)
- if ("IPF" in Archs):
- PcdFFIpf.insert(0, line)
- if ("X64" in Archs):
- PcdFFX64.insert(0, line)
- if ("EBC" in Archs):
- PcdFFEbc.insert(0, line)
- if ("ALL" in Archs):
- PcdFF.insert(0, line)
- elif (ItemType == "FIXED_AT_BUILD"):
- if ("IA32" in Archs):
- PcdFABIa32.insert(0, line)
- if ("IPF" in Archs):
- PcdFABIpf.insert(0, line)
- if ("X64" in Archs):
- PcdFABX64.insert(0, line)
- if ("EBC" in Archs):
- PcdFABEbc.insert(0, line)
- if ("ALL" in Archs):
- PcdFAB.insert(0, line)
- elif (ItemType == "PATCHABLE_IN_MODULE"):
- if ("IA32" in Archs):
- PcdPIMIa32.insert(0, line)
- if ("IPF" in Archs):
- PcdPIMIpf.insert(0, line)
- if ("X64" in Archs):
- PcdPIMX64.insert(0, line)
- if ("EBC" in Archs):
- PcdPIMEbc.insert(0, line)
- if ("ALL" in Archs):
- PcdFAB.insert(0, line)
- elif (ItemType == "DYNAMIC_EX"):
- if ("IA32" in Archs):
- PcdDYEIa32.insert(0, line)
- if ("IPF" in Archs):
- PcdDYEIpf.insert(0, line)
- if ("X64" in Archs):
- PcdDYEX64.insert(0, line)
- if ("EBC" in Archs):
- PcdDYEEbc.insert(0, line)
- if ("ALL" in Archs):
- PcdDYE.insert(0, line)
- else:
- if ("IA32" in Archs):
- PcdDYIa32.insert(0, line)
- if ("IPF" in Archs):
- PcdDYIpf.insert(0, line)
- if ("X64" in Archs):
- PcdDYX64.insert(0, line)
- if ("EBC" in Archs):
- PcdDYEbc.insert(0, line)
- if ("ALL" in Archs):
- PcdDY.insert(0, line)
-
- """ User Extensions Section """
- UEList = []
- UESectionList = []
- try:
- UESectionList = XmlList(Msa, "/ModuleSurfaceArea/UserExtensions")
- except:
- pass
-
- if (len(UESectionList) > 0):
- for UE in UESectionList[:]:
- UserId = ""
- Identifier = ""
- Value = ""
-
- try:
- UserId = str(UE.getAttribute("UserID"))
- except:
- raise SyntaxError, "ERROR: Malformed MSA, No UserID Specified in UserExtensions element"
-
- try:
- Identifier = str(UE.getAttribute("Identifier"))
- except:
- raise SyntaxError, "ERROR: Malformed MSA, No Identifier Specified in UserExtensions element"
-
- if (options.debug):
- print "FOUND A UE Element", UserId, Identifier
-
- try:
- Value = str(XmlElementData(UE))
- except:
- pass
-
- Entry = [UserId, Identifier, Value]
- UEList.insert(0, Entry)
-
-
-
- if (len(Externlist) > 0):
- AutoGenSource = ""
- AutoGenDefinitionSource = ""
- AutoGenEntryPointSource = ""
- AutoGenUnloadSource = ""
- if (len(AutoGenDriverModel) > 0):
- AutoGenCode = AddDriverBindingProtocolStatement(AutoGenDriverModel)
- AutoGenEntryPointSource += AutoGenCode[0]
- AutoGenUnloadSource += AutoGenCode[1]
- AutoGenDeclaration += AutoGenCode[3]
-
-
- if (len(AutoGenExitBootServices) > 0):
- print "[Warning] Please manually add Create Event statement for Exit Boot Service Event!"
- if options.event:
- AutoGenCode = AddBootServiceEventStatement(AutoGenExitBootServices)
- AutoGenEntryPointSource += AutoGenCode[0]
- AutoGenUnloadSource += AutoGenCode[1]
- AutoGenDefinitionSource += AutoGenCode[2]
- AutoGenDeclaration += AutoGenCode[3]
-
- if (len(AutoGenVirtualAddressChanged) > 0):
- print "[Warning] Please manually add Create Event statement for Virtual Address Change Event!"
- if options.event:
- AutoGenCode = AddVirtualAddressEventStatement(AutoGenVirtualAddressChanged)
- AutoGenEntryPointSource += AutoGenCode[0]
- AutoGenUnloadSource += AutoGenCode[1]
- AutoGenDefinitionSource += AutoGenCode[2]
- AutoGenDeclaration += AutoGenCode[3]
-
- if AutoGenEntryPointSource != "":
- OldEntryPoint = AutoGenEntryPoint
- AutoGenCode = AddNewEntryPointContentsStatement(BaseName, AutoGenEntryPoint, AutoGenEntryPointSource)
- AutoGenEntryPoint = AutoGenCode[0]
- AutoGenEntryPointSource = AutoGenCode[1]
- AutoGenDeclaration += AutoGenCode[2]
-
-
- if AutoGenEntryPoint != "":
- DriverModules.insert(0, " %-30s = %s\n" % ("ENTRY_POINT" , AutoGenEntryPoint))
-
- AutoGenSource = AutoGenDefinitionSource + AutoGenEntryPointSource + AutoGenUnloadSource
-
- if (lFlag):
- DefinesComments.append("#\n")
-
- if (Flag and len(DefinesComments) > 0):
- DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
-
- if (options.debug and options.verbose > 2):
- if (len(DriverModules) > 0):
- print DriverModules
- if (len(LibraryModules) > 0):
- print LibraryModules
- if (len(DefinesComments) > 0):
- print DefinesComments
-
- Depex = []
- DepexIa32 = []
- DepexX64 = []
- DepexIpf = []
- DepexEbc = []
-
- for DxsFile, Archs in AutoGenDxsFiles:
- fileContents = openSourceFile(AutoGenModuleFolder, DxsFile)
- Contents, Unresolved = TranslateDpxSection(fileContents)
- if Contents == "":
- print "[warning] Cannot read dxs expression"
- else:
- if (len(Unresolved) > 0):
- print "[warning] Guid Macro(s): %s cannot find corresponding cNames. Please resolve it in [depex] section in extened inf" % ",".join(Unresolved)
-
- if ("IA32" in Archs):
- DepexIa32.insert(0, Contents)
- if ("IPF" in Archs):
- DepexIpf.insert(0, Contents)
- if ("X64" in Archs):
- DepexX64.insert(0, Contents)
- if ("EBC" in Archs):
- DepexEbc.insert(0, Contents)
- if ("ALL" in Archs):
- Depex.insert(0, Contents)
-
- AutoGenSourceHeaderFormat = "/**@file\n %s\n\n %s\n %s\n %s\n**/\n\n%s"
- includeCommonHeaderFileStatement = "#include \"%s\"" % commonHeaderFilename
-
- AutoGenHeader += AddSystemIncludeStatement(ModType, AutoGenPackage)
- AutoGenHeader += AddGuidStatement(AutoGenGuid)
- AutoGenHeader += AddLibraryClassStatement(AutoGenLibClass)
-
- if options.manual:
- saveSourceFile(AutoGenModuleFolder, "CommonHeader.txt", AutoGenHeader)
- else:
-
- commonHeaderFilename2 = re.sub("(?=[^a-z])", "_", commonHeaderFilename)
- commonHeaderFilename2 = "_" + commonHeaderFilename2.replace(".", "").upper() + "_"
- briefDiscription = "Common header file shared by all source files."
- detailedDiscription = "This file includes package header files, library classes and protocol, PPI & GUID definitions.\n"
- AutoGenHeader += AutoGenDeclaration
- AutoGenHeader = "#ifndef %s\n#define %s\n\n\n%s\n#endif\n" % (commonHeaderFilename2, commonHeaderFilename2, AutoGenHeader)
- AutoGenHeader = AutoGenSourceHeaderFormat % (briefDiscription, detailedDiscription, CopyRight, License, AutoGenHeader)
- saveSourceFile(AutoGenModuleFolder, commonHeaderFilename, AutoGenHeader)
- SrcFilenames.append(commonHeaderFilename)
-
- for source in AutoGenSourceFiles:
- extension = os.path.splitext(source)[1]
- if extension == ".c":
- sourceContents = openSourceFile(AutoGenModuleFolder, source)
- sourceContents = AddCommonInclusionStatement(sourceContents, includeCommonHeaderFileStatement)
- saveSourceFile(AutoGenModuleFolder, source, sourceContents)
-
-
- if AutoGenSource != "":
- briefDiscription = "Entry Point Source file."
- detailedDiscription = "This file contains the user entry point \n"
- AutoGenSource = AutoGenSourceHeaderFormat % (briefDiscription, detailedDiscription, CopyRight, License, AutoGenSource)
- AutoGenSource = AddCommonInclusionStatement(AutoGenSource, includeCommonHeaderFileStatement)
-
- saveSourceFile(AutoGenModuleFolder, entryPointFilename, AutoGenSource)
- SrcFilenames.append(entryPointFilename)
-
-
-
-
- # DONE Getting data, now output it in INF format.
- Msa.unlink()
- Fdb.unlink()
- Output = []
-
- """ Print the converted data format """
- head = "#/** @file\n"
- head += "# " + str(Abstract) + "\n#\n"
- head += "# " + str(Description).strip().replace("\n", "\n# ") + "\n"
- head += "# " + str(CopyRight) + "\n#\n"
- head += "# " + str(License).replace("\n", "\n# ").replace(" ", " ").strip() + "\n#\n"
- head += "#\n#**/\n"
-
- Output.append(head)
- if (options.debug):
- print head
-
-## Defines = "\n" + "#"*80+ "\n#\n"
-## if (BinModule != "false"):
-## Defines += "# Defines Section - statements that will be processed to generate a binary image.\n"
-## else:
-## Defines += "# Defines Section - statements that will be processed to create a Makefile.\n"
-## Defines += "#\n" + "#"*80 + "\n"
-
- Defines = "\n"
- Defines += "[Defines]\n"
- Defines += " %-30s = %s\n" % ("INF_VERSION", "0x00010005")
- Defines += " %-30s = %s\n" % ("BASE_NAME", BaseName)
- Defines += " %-30s = %s\n" % ("FILE_GUID", GuidValue)
- Defines += " %-30s = %s\n" % ("MODULE_TYPE", ModType)
- Defines += " %-30s = %s\n" % ("VERSION_STRING", VerString)
-
- if (len(PcdIsDriver) > 0):
- Defines += " %-30s = %s\n" % ("PCD_DRIVER", PcdIsDriver)
-
- if (len(IamLibrary) > 0):
- lcstr = ""
- for lc in IamLibrary[:]:
- lcstr += lc + " "
- Defines += " %-30s = %s" % ("LIBRARY_CLASS", lcstr)
- Defines += "\n"
-
- if (len(SpecList) > 0):
- for spec in SpecList[:]:
- (specname, specval) = spec.split()
- Defines += " %-30s = %s\n" % (specname, specval)
- Defines += "\n"
-
- if (len(DriverModules) > 0):
- for line in DriverModules[:]:
- Defines += line
-
- if (len(LibraryModules) > 0):
- for line in LibraryModules[:]:
- Defines += line
-
- if (len(DefinesComments) > 0):
- for line in DefinesComments[:]:
- Defines += line
-
- Output.append(Defines)
-
- if (options.debug):
- print Defines
-
- if (BinModule != "false"):
- """ Binary Module, so sources are really binaries. """
-## Sources = "\n" + "#"*80 + "\n#\n"
-## Sources += "# Binaries Section - list of binary files that are required for the build\n# to succeed.\n"
-## Sources += "#\n" + "#"*80 + "\n\n"
- Sources = "\n"
- if ModType == "UEFI_APPLICATION":
- FileType = "UEFI_APP"
- if options.verbose > 0:
- print "WARNING: Binary Module: %s is assuming UEFI_APPLICATION file type." % (options.filename)
- else:
- FileType = "FV"
- if options.verbose > 0:
- print "WARNING: Binary Module: %s is assuming FV file type." % (options.filename)
-
- if (len(SrcFilenames) > 0):
- Sources += "[Binaries.common]\n"
- for file in SrcFilenames[:]:
- file = file.replace("\\", "/")
- Sources += " " + FileType + "|" + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesIa32) > 0):
- Sources += "[Binaries.Ia32]\n"
- for file in SrcFilenamesIa32[:]:
- file = file.replace("\\", "/")
- Sources += " " + FileType + "|" + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesX64) > 0):
- Sources += "[Binaries.X64]\n"
- for file in SrcFilenamesX64[:]:
- file = file.replace("\\", "/")
- Sources += " " + FileType + "|" + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesIpf) > 0):
- Sources += "[Binaries.IPF]\n"
- for file in SrcFilenamesIpf[:]:
- file = file.replace("\\", "/")
- Sources += " " + FileType + "|" + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesEbc) > 0):
- Sources += "[Binaries.EBC]\n"
- for file in SrcFilenamesEbc[:]:
- file = file.replace("\\", "/")
- Sources += " " + FileType + "|" + file + "\n"
- Sources += "\n"
-
- Output.append(Sources)
- if (options.debug):
- print Sources
- else:
-## Sources = "\n" + "#"*80 + "\n#\n"
-## Sources += "# Sources Section - list of files that are required for the build to succeed.\n"
-## Sources += "#\n" + "#"*80 + "\n\n"
- Sources = "\n"
- if (len(SrcFilenames) > 0):
- Sources += "[Sources.common]\n"
- for file in SrcFilenames[:]:
- Sources += " " + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesIa32) > 0):
- Sources += "[Sources.Ia32]\n"
- for file in SrcFilenamesIa32[:]:
- Sources += " " + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesX64) > 0):
- Sources += "[Sources.X64]\n"
- for file in SrcFilenamesX64[:]:
- Sources += " " + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesIpf) > 0):
- Sources += "[Sources.IPF]\n"
- for file in SrcFilenamesIpf[:]:
- Sources += " " + file + "\n"
- Sources += "\n"
-
- if (len(SrcFilenamesEbc) > 0):
- Sources += "[Sources.EBC]\n"
- for file in SrcFilenamesEbc[:]:
- Sources += " " + file + "\n"
- Sources += "\n"
-
- Output.append(Sources)
- if (options.debug):
- print Sources
-
-
- includeLine = ""
- if ((len(HeaderLocations) > 0) or (len(Dirs) > 0)):
- allLcs = set(LibClassList + LibClassListIa32 + LibClassListX64 + LibClassListIpf + LibClassListEbc + Dirs)
- Lines = []
- for line in HeaderLocations[:]:
- for Lc in allLcs:
- (keyword, header) = line.split("|")
- if Lc in keyword:
- if (options.debug):
- print "FOUND", Lc, "in", keyword, "header", header
- path = "$(WORKSPACE)/" + os.path.split(header)[0]
- Lines.insert(0, path.strip())
- Includes = ""
-## Includes = "\n" + "#"*80 + "\n#\n"
-## Includes += "# Includes Section - list of Include locations that are required for\n"
-## Includes += "# this module.\n"
-## Includes += "#\n" + "#"*80 + "\n\n"
-## Includes += "[Includes]\n"
-## includeLines = []
-## includeLines = set(Lines)
-## if (options.debug):
-## print "There are", len(includeLines), "entries"
-## for Line in includeLines:
-## Includes += " " + str(Line).strip().replace("\\", "/") + "\n"
-
- Output.append(Includes)
- if (options.debug):
- print Includes
-
-
-
- if ((len(PkgList) + len(PkgListIa32) + len(PkgListX64) + len(PkgListIpf) + len(PkgListEbc)) > 0):
- """ We do this if and only if we have Package Dependencies """
-## PackageDepends = "\n" + "#"*80 + "\n#\n"
-## PackageDepends += "# Package Dependency Section - list of Package files that are required for\n"
-## PackageDepends += "# this module.\n"
-## PackageDepends += "#\n" + "#"*80 + "\n\n"
- PackageDepends = "\n"
- if (len(PkgList) > 0):
- PackageDepends += "[Packages]\n"
- for lc in PkgList[:]:
- lc = lc.replace("\\", "/")
- PackageDepends += " " + lc + "\n"
- PackageDepends += "\n"
-
- if (len(PkgListIa32) > 0):
- PackageDepends += "[Packages.IA32]\n"
- for lc in PkgListIa32[:]:
- lc = lc.replace("\\", "/")
- PackageDepends += " " + lc + "\n"
- PackageDepends += "\n"
-
- if (len(PkgListX64) > 0):
- PackageDepends += "[Packages.X64]\n"
- for lc in PkgListX64[:]:
- lc = lc.replace("\\", "/")
- PackageDepends += " " + lc + "\n"
- PackageDepends += "\n"
-
- if (len(PkgListIpf) > 0):
- PackageDepends += "[Packages.IPF]\n"
- for lc in PkgListIpf[:]:
- lc = lc.replace("\\", "/")
- PackageDepends += " " + lc + "\n"
- PackageDepends += "\n"
-
- if (len(PkgListEbc) > 0):
- PackageDepends += "[Packages.EBC]\n"
- for lc in PkgListEbc[:]:
- lc = lc.replace("\\", "/")
- PackageDepends += " " + lc + "\n"
- PackageDepends += "\n"
-
- Output.append(PackageDepends)
- if (options.debug):
- print PackageDepends
-
- if ((len(LibClassList) + len(LibClassListIa32) + len(LibClassListX64) + len(LibClassListIpf) + len(LibClassListEbc)) > 0):
-## LibraryClasses = "\n" + "#"*80 + "\n#\n"
-## LibraryClasses += "# Library Class Section - list of Library Classes that are required for\n"
-## LibraryClasses += "# this module.\n"
-## LibraryClasses += "#\n" + "#"*80 + "\n\n"
-
- LibraryClasses = "\n"
- if (len(LibClassList) > 0):
- LibraryClasses += "[LibraryClasses]\n"
- for lc in LibClassList[:]:
- LibraryClasses += " " + lc + "\n"
- LibraryClasses += "\n"
-
- if (len(LibClassListIa32) > 0):
- LibraryClasses += "[LibraryClasses.IA32]\n"
- for lc in LibClassListIa32[:]:
- LibraryClasses += " " + lc + "\n"
- LibraryClasses += "\n"
-
- if (len(LibClassListX64) > 0):
- LibraryClasses += "[LibraryClasses.X64]\n"
- for lc in LibClassListX64[:]:
- LibraryClasses += " " + lc + "\n"
- LibraryClasses += "\n"
-
- if (len(LibClassListIpf) > 0):
- LibraryClasses += "[LibraryClasses.IPF]\n"
- for lc in LibClassListIpf[:]:
- LibraryClasses += " " + lc + "\n"
- LibraryClasses += "\n"
-
- if (len(LibClassListEbc) > 0):
- LibraryClasses += "[LibraryClasses.EBC]\n"
- for lc in LibClassListEbc[:]:
- LibraryClasses += " " + lc + "\n"
- LibraryClasses += "\n"
-
- Output.append(LibraryClasses)
- if (options.debug):
- print LibraryClasses
-
- # Print the Guids sections
- if (len(GuidCName) + len(GuidCNameIa32) + len(GuidCNameIPF) + len(GuidCNameX64) + len(GuidCNameEBC)) > 0:
-## GuidSection = "\n" + "#"*80 + "\n#\n"
-## GuidSection += "# Guid C Name Section - list of Guids that this module uses or produces.\n"
-## GuidSection += "#\n" + "#"*80 + "\n\n"
- GuidSection = "\n"
- if (len(GuidCName) > 0):
- GuidSection += "[Guids]\n"
- for Guid in GuidCName[:]:
- GuidSection += Guid + "\n"
- GuidSection += "\n"
-
- if (len(GuidCNameIa32) > 0):
- GuidSection += "[Guids.IA32]\n"
- for Guid in GuidCNameIa32[:]:
- GuidSection += Guid + "\n"
- GuidSection += "\n"
-
- if (len(GuidCNameX64) > 0):
- GuidSection += "[Guids.X64]\n"
- for Guid in GuidCNameX64[:]:
- GuidSection += Guid + "\n"
- GuidSection += "\n"
-
- if (len(GuidCNameIPF) > 0):
- GuidSection += "[Guids.IPF]\n"
- for Guid in GuidCNameIPF[:]:
- GuidSection += Guid + "\n"
- GuidSection += "\n"
-
- if (len(GuidCNameEBC) > 0):
- GuidSection += "[Guids.EBC]\n"
- for Guid in GuidCNameEBC[:]:
- GuidSection += Guid + "\n"
- GuidSection += "\n"
-
- Output.append(GuidSection)
- if (options.debug and options.verbose > 1):
- print GuidSection
-
- # Print the Protocol sections
- if (len(ProtocolCName) + len(ProtocolCNameIa32) + len(ProtocolCNameIPF) + len(ProtocolCNameX64) + len(ProtocolCNameEBC)) > 0:
-## ProtocolsSection = "\n" + "#"*80 + "\n#\n"
-## ProtocolsSection += "# Protocol C Name Section - list of Protocol and Protocol Notify C Names\n"
-## ProtocolsSection += "# that this module uses or produces.\n"
-## ProtocolsSection += "#\n" + "#"*80 + "\n\n"
-
- ProtocolsSection = "\n"
- if (len(ProtocolCName) > 0):
- ProtocolsSection += "[Protocols]\n"
- for Guid in ProtocolCName[:]:
- ProtocolsSection += Guid + "\n"
- ProtocolsSection += "\n"
-
- if (len(ProtocolCNameIa32) > 0):
- ProtocolsSection += "[Protocols.IA32]\n"
- for Guid in ProtocolCNameIa32[:]:
- ProtocolsSection += Guid + "\n"
- ProtocolsSection += "\n"
-
- if (len(ProtocolCNameX64) > 0):
- ProtocolsSection += "[Protocols.X64]\n"
- for Guid in ProtocolCNameX64[:]:
- ProtocolsSection += Guid + "\n"
- ProtocolsSection += "\n"
-
- if (len(ProtocolCNameIPF) > 0):
- ProtocolsSection += "[Protocols.IPF]\n"
- for Guid in ProtocolCNameIPF[:]:
- ProtocolsSection += Guid + "\n"
- ProtocolsSection += "\n"
-
- if (len(ProtocolCNameEBC) > 0):
- ProtocolsSection += "[Protocols.EBC]\n"
- for Guid in ProtocolCNameEBC[:]:
- ProtocolsSection += Guid + "\n"
- ProtocolsSection += "\n"
-
- Output.append(ProtocolsSection)
- if (options.debug):
- print ProtocolsSection
-
- # Print the PPI sections
- if (len(PpiCName) + len(PpiCNameIa32) + len(PpiCNameIPF) + len(PpiCNameX64) + len(PpiCNameEBC)) > 0:
-## PpiSection = "\n" + "#"*80 + "\n#\n"
-## PpiSection += "# PPI C Name Section - list of PPI and PPI Notify C Names that this module\n"
-## PpiSection += "# uses or produces.\n"
-## PpiSection += "#\n" + "#"*80 + "\n\n"
-
- PpiSection = "\n"
- if (len(PpiCName) > 0):
- PpiSection += "[Ppis]\n"
- for Guid in PpiCName[:]:
- PpiSection += Guid + "\n"
- PpiSection += "\n"
-
- if (len(PpiCNameIa32) > 0):
- PpiSection += "[Ppis.IA32]\n"
- for Guid in PpiCNameIa32[:]:
- PpiSection += Guid + "\n"
- PpiSection += "\n"
-
- if (len(PpiCNameX64) > 0):
- PpiSection += "[Ppis.X64]\n"
- for Guid in PpiCNameX64[:]:
- PpiSection += Guid + "\n"
- PpiSection += "\n"
-
- if (len(PpiCNameIPF) > 0):
- PpiSection += "[Ppis.IPF]\n"
- for Guid in PpiCNameIPF[:]:
- PpiSection += Guid + "\n"
- PpiSection += "\n"
-
- if (len(PpiCNameEBC) > 0):
- PpiSection += "[Ppis.EBC]\n"
- for Guid in PpiCNameEBC[:]:
- PpiSection += Guid + "\n"
- PpiSection += "\n"
-
- Output.append(PpiSection)
- if (options.debug):
- print PpiSection
-
- # Print the PCD sections
- if ((len(PcdFF)+len(PcdFFIa32)+len(PcdFFX64)+len(PcdFFIpf)+len(PcdFFEbc)) > 0):
-## FeatureFlagSection = "\n" + "#"*80 + "\n#\n"
-## FeatureFlagSection += "# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\n"
-## FeatureFlagSection += "#\n" + "#"*80 + "\n\n"
-
- FeatureFlagSection = "\n"
- if (len(PcdFF) > 0):
- FeatureFlagSection += "[FeaturePcd.common]\n"
- for Entry in PcdFF[:]:
- FeatureFlagSection += " " + Entry + "\n"
- FeatureFlagSection += "\n"
- if (len(PcdFFIa32) > 0):
- FeatureFlagSection += "[FeaturePcd.IA32]\n"
- for Entry in PcdFFIa32[:]:
- FeatureFlagSection += " " + Entry + "\n"
- FeatureFlagSection += "\n"
- if (len(PcdFFX64) > 0):
- FeatureFlagSection += "[FeaturePcd.X64]\n"
- for Entry in PcdFFX64[:]:
- FeatureFlagSection += " " + Entry + "\n"
- FeatureFlagSection += "\n"
- if (len(PcdFFIpf) > 0):
- FeatureFlagSection += "[PcdsFeatureFlag.IPF]\n"
- for Entry in PcdFFIpf[:]:
- FeatureFlagSection += " " + Entry + "\n"
- FeatureFlagSection += "\n"
- if (len(PcdFFEbc) > 0):
- FeatureFlagSection += "[FeaturePcd.EBC]\n"
- for Entry in PcdFFEbc[:]:
- FeatureFlagSection += " " + Entry + "\n"
- FeatureFlagSection += "\n"
-
- Output.append(FeatureFlagSection)
- if (options.debug):
- print FeatureFlagSection
-
- if ((len(PcdFAB)+len(PcdFABIa32)+len(PcdFABX64)+len(PcdFABIpf)+len(PcdFABEbc)) > 0):
-## FixedAtBuildSection = "\n" + "#"*80 + "\n#\n"
-## FixedAtBuildSection += "# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\n"
-## FixedAtBuildSection += "#\n" + "#"*80 + "\n\n"
-
- FixedAtBuildSection = "\n"
- if (len(PcdFAB) > 0):
- FixedAtBuildSection += "[FixedPcd.common]\n"
- for Entry in PcdFAB[:]:
- FixedAtBuildSection += " " + Entry + "\n"
- FixedAtBuildSection += "\n"
- if (len(PcdFABIa32) > 0):
- FixedAtBuildSection += "[FixedPcd.IA32]\n"
- for Entry in PcdFABIa32[:]:
- FixedAtBuildSection += " " + Entry + "\n"
- FixedAtBuildSection += "\n"
- if (len(PcdFABX64) > 0):
- FixedAtBuildSection += "[FixedPcd.X64]\n"
- for Entry in PcdFABX64[:]:
- FixedAtBuildSection += " " + Entry + "\n"
- FixedAtBuildSection += "\n"
- if (len(PcdFABIpf) > 0):
- FixedAtBuildSection += "[FixedPcd.IPF]\n"
- for Entry in PcdFABIpf[:]:
- FixedAtBuildSection += " " + Entry + "\n"
- FixedAtBuildSection += "\n"
- if (len(PcdFABEbc) > 0):
- FixedAtBuildSection += "[FixedPcd.EBC]\n"
- for Entry in PcdFABEbc[:]:
- FixedAtBuildSection += " " + Entry + "\n"
- FixedAtBuildSection += "\n"
-
- Output.append(FixedAtBuildSection)
- if (options.debug):
- print FixedAtBuildSection
-
- if ((len(PcdPIM)+len(PcdPIMIa32)+len(PcdPIMX64)+len(PcdPIMIpf)+len(PcdPIMEbc)) > 0):
-## PatchableInModuleSection = "\n" + "#"*80 + "\n#\n"
-## PatchableInModuleSection += "# Pcd PATCHABLE_IN_MODULE - list of PCDs that this module is coded for.\n"
-## PatchableInModuleSection += "#\n" + "#"*80 + "\n\n"
-
- PatchableInModuleSection = "\n"
- if (len(PcdPIM) > 0):
- PatchableInModuleSection += "[PatchPcd.common]\n"
- for Entry in PcdPIM[:]:
- PatchableInModuleSection += " " + Entry + "\n"
- PatchableInModuleSection += "\n"
- if (len(PcdPIMIa32) > 0):
- PatchableInModuleSection += "[PatchPcd.IA32]\n"
- for Entry in PcdPIMIa32[:]:
- PatchableInModuleSection += " " + Entry + "\n"
- PatchableInModuleSection += "\n"
- if (len(PcdPIMX64) > 0):
- PatchableInModuleSection += "[PatchPcd.X64]\n"
- for Entry in PcdPIMX64[:]:
- PatchableInModuleSection += " " + Entry + "\n"
- PatchableInModuleSection += "\n"
- if (len(PcdPIMIpf) > 0):
- PatchableInModuleSection += "[PatchPcd.IPF]\n"
- for Entry in PcdPIMIpf[:]:
- PatchableInModuleSection += " " + Entry + "\n"
- PatchableInModuleSection += "\n"
- if (len(PcdPIMEbc) > 0):
- PatchableInModuleSection += "[PatchPcd.EBC]\n"
- for Entry in PcdPIMEbc[:]:
- PatchableInModuleSection += " " + Entry + "\n"
- PatchableInModuleSection += "\n"
-
- Output.append(PatchableInModuleSection)
- if (options.debug):
- print PatchableInModuleSection
-
- if ((len(PcdDYE)+len(PcdDYEIa32)+len(PcdDYEX64)+len(PcdDYEIpf)+len(PcdDYEEbc)) > 0):
-## DynamicExSection = "\n" + "#"*80 + "\n#\n"
-## DynamicExSection += "# Pcd DYNAMIC_EX - list of PCDs that this module is coded for.\n"
-## DynamicExSection += "#\n" + "#"*80 + "\n\n"
-
- DynamicExSection = "\n"
- if (len(PcdDYE) > 0):
- DynamicExSection += "[PcdEx.common]\n"
- for Entry in PcdDYE[:]:
- DynamicExSection += " " + Entry + "\n"
- DynamicExSection += "\n"
- if (len(PcdDYEIa32) > 0):
- DynamicExSection += "[PcdEx.IA32]\n"
- for Entry in PcdDYEIa32[:]:
- DynamicExSection += " " + Entry + "\n"
- DynamicExSection += "\n"
- if (len(PcdDYEX64) > 0):
- DynamicExSection += "[PcdEx.X64]\n"
- for Entry in PcdDYEX64[:]:
- DynamicExSection += " " + Entry + "\n"
- DynamicExSection += "\n"
- if (len(PcdDYEIpf) > 0):
- DynamicExSection += "[PcdEx.IPF]\n"
- for Entry in PcdDYEIpf[:]:
- DynamicExSection += " " + Entry + "\n"
- DynamicExSection += "\n"
- if (len(PcdDYEEbc) > 0):
- DynamicExSection += "[PcdEx.EBC]\n"
- for Entry in PcdDYEEbc[:]:
- DynamicExSection += " " + Entry + "\n"
- DynamicExSection += "\n"
-
- Output.append(DynamicExSection)
- if (options.debug):
- print DynamicExSection
-
- if ((len(PcdDY)+len(PcdDYIa32)+len(PcdDYX64)+len(PcdDYIpf)+len(PcdDYEbc)) > 0):
-## DynamicSection = "\n" + "#"*80 + "\n#\n"
-## DynamicSection += "# Pcd DYNAMIC - list of PCDs that this module is coded for.\n"
-## DynamicSection += "#\n" + "#"*80 + "\n\n"
-
- DynamicSection = "\n"
- if (len(PcdDY) > 0):
- DynamicSection += "[Pcd.common]\n"
- for Entry in PcdDY[:]:
- DynamicSection += " " + Entry + "\n"
- DynamicSection += "\n"
- if (len(PcdDYIa32) > 0):
- DynamicSection += "[Pcd.IA32]\n"
- for Entry in PcdDYIa32[:]:
- DynamicSection += " " + Entry + "\n"
- DynamicSection += "\n"
- if (len(PcdDYX64) > 0):
- DynamicSection += "[Pcd.X64]\n"
- for Entry in PcdDYX64[:]:
- DynamicSection += " " + Entry + "\n"
- DynamicSection += "\n"
- if (len(PcdDYIpf) > 0):
- DynamicSection += "[Pcd.IPF]\n"
- for Entry in PcdDYIpf[:]:
- DynamicSection += " " + Entry + "\n"
- DynamicSection += "\n"
- if (len(PcdDYEbc) > 0):
- DynamicSection += "[Pcd.EBC]\n"
- for Entry in PcdDYEbc[:]:
- DynamicSection += " " + Entry + "\n"
- DynamicSection += "\n"
-
- Output.append(DynamicSection)
- if (options.debug):
- print DynamicSection
-
- if ((len(Depex) + len(DepexIa32) + len(DepexX64) + len(DepexIpf) + len(DepexEbc)) > 0):
- """ We do this if and only if we have Package Dependencies """
-## Dpx = "\n" + "#"*80 + "\n#\n"
-## Dpx += "# Dependency Expression Section - list of Dependency expressions that are required for\n"
-## Dpx += "# this module.\n"
-## Dpx += "#\n" + "#"*80 + "\n\n"
- Dpx = "\n"
- if (len(Depex) > 0):
- Dpx += "[Depex]\n"
- for lc in Depex[:]:
- Dpx += " " + lc + "\n"
- Dpx += "\n"
-
- if (len(DepexIa32) > 0):
- Dpx += "[Depex.IA32]\n"
- for lc in DepexIa32[:]:
- Dpx += " " + lc + "\n"
- Dpx += "\n"
-
- if (len(DepexX64) > 0):
- Dpx += "[Depex.X64]\n"
- for lc in DepexX64[:]:
- Dpx += " " + lc + "\n"
- Dpx += "\n"
-
- if (len(DepexIpf) > 0):
- Dpx += "[Depex.IPF]\n"
- for lc in DepexIpf[:]:
- Dpx += " " + lc + "\n"
- Dpx += "\n"
-
- if (len(DepexEbc) > 0):
- Dpx += "[Depex.EBC]\n"
- for lc in DepexEbc[:]:
- Dpx += " " + lc + "\n"
- Dpx += "\n"
-
- Output.append(Dpx)
- if (options.debug):
- print Dpx
-
- if (len(MBOlines) > 0):
- BuildSection = ""
-## BuildSection = "\n" + "#"*80 + "\n#\n"
-## BuildSection += "# Build Options - list of custom build options for this module.\n"
-## BuildSection += "#\n" + "#"*80 + "\n\n"
- BuildSection += "\n[BuildOptions]\n"
- for mbo in MBOlines:
- tool, targs = mbo.split("=",2)
- BuildSection += " %-40s = %s\n" % (tool.strip(), targs.strip())
-
- Output.append(BuildSection)
- if (options.debug):
- print BuildSection
-
-
- if (len(UEList) > 0):
- UserExtensionSection = ""
- for UE in UEList[:]:
- UserExtensionSection += "[UserExtensions." + UE[0] + '."' + UE[1] + '"]\n'
- if (len(UE[2]) > 0):
- UserExtensionSection += '"' + UE[2] + '"\n'
- else:
- UserExtensionSection += "\n"
-
- Output.append(UserExtensionSection)
- if (options.debug):
- print UserExtensionSection
-
- print "write file", outputFile
- if (options.autowrite):
- fo = open(outputFile, "w")
- for Section in Output[:]:
- fo.writelines(Section)
- if (options.verbose > 1):
- print Section
- fo.close()
- elif (options.outfile):
- fo = open(outputFile, "w")
- for Section in Output[:]:
- fo.writelines(Section)
- fo.close()
- else:
- for Section in Output[:]:
- print Section
-
-
-if __name__ == '__main__':
-
- global options
- global args
- options,args = myOptionParser()
-
- main()
- sys.exit(0)
-
diff --git a/BaseTools/Source/Python/MigrationMsa2Inf/__init__.py b/BaseTools/Source/Python/MigrationMsa2Inf/__init__.py
deleted file mode 100644
index 4c44c24731..0000000000
--- a/BaseTools/Source/Python/MigrationMsa2Inf/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-## @file
-# Python 'MigrationMsa2Inf' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
diff --git a/BaseTools/Source/Python/MkBOM/__init__.py b/BaseTools/Source/Python/MkBOM/__init__.py
deleted file mode 100644
index 86ef629584..0000000000
--- a/BaseTools/Source/Python/MkBOM/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-## @file
-# Python 'MkBOM' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source/Python/UPT/BuildVersion.py
index bd5876dd5c..1510430fe5 100644
--- a/BaseTools/Source/Python/UPT/BuildVersion.py
+++ b/BaseTools/Source/Python/UPT/BuildVersion.py
@@ -17,4 +17,4 @@
Build version information
'''
-gBUILD_VERSION = "Build 2474"
+gBUILD_VERSION = "Build 2518"
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index e26b558de0..a6668774b5 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -340,6 +340,7 @@ class MetaFileParser(object):
## [BuildOptions] section parser
@ParseMacro
def _BuildOptionParser(self):
+ self._CurrentLine = CleanString(self._CurrentLine, BuildOption=True)
TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)
TokenList2 = GetSplitValueList(TokenList[0], ':', 1)
if len(TokenList2) == 2:
@@ -913,6 +914,9 @@ class DscParser(MetaFileParser):
ExtraData=self._CurrentLine)
ItemType = self.DataType[DirectiveName]
+ Scope = [['COMMON', 'COMMON']]
+ if ItemType == MODEL_META_DATA_INCLUDE:
+ Scope = self._Scope
if ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF:
# Remove all directives between !if and !endif, including themselves
while self._DirectiveStack:
@@ -945,21 +949,22 @@ class DscParser(MetaFileParser):
# Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1,
# LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1
#
- self._LastItem = self._Store(
- ItemType,
- self._ValueList[0],
- self._ValueList[1],
- self._ValueList[2],
- 'COMMON',
- 'COMMON',
- self._Owner[-1],
- self._From,
- self._LineIndex+1,
- -1,
- self._LineIndex+1,
- -1,
- 0
- )
+ for Arch, ModuleType in Scope:
+ self._LastItem = self._Store(
+ ItemType,
+ self._ValueList[0],
+ self._ValueList[1],
+ self._ValueList[2],
+ Arch,
+ ModuleType,
+ self._Owner[-1],
+ self._From,
+ self._LineIndex+1,
+ -1,
+ self._LineIndex+1,
+ -1,
+ 0
+ )
## [defines] section parser
@ParseMacro
@@ -1065,6 +1070,7 @@ class DscParser(MetaFileParser):
## [BuildOptions] section parser
@ParseMacro
def _BuildOptionParser(self):
+ self._CurrentLine = CleanString(self._CurrentLine, BuildOption=True)
TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)
TokenList2 = GetSplitValueList(TokenList[0], ':', 1)
if len(TokenList2) == 2:
@@ -1154,6 +1160,21 @@ class DscParser(MetaFileParser):
self._ContentIndex += 1
self._Scope = [[S1, S2]]
+ #
+ # For !include directive, handle it specially,
+ # merge arch and module type in case of duplicate items
+ #
+ while self._ItemType == MODEL_META_DATA_INCLUDE:
+ if self._ContentIndex >= len(self._Content):
+ break
+ Record = self._Content[self._ContentIndex]
+ if LineStart == Record[9] and LineEnd == Record[11]:
+ if [Record[5], Record[6]] not in self._Scope:
+ self._Scope.append([Record[5], Record[6]])
+ self._ContentIndex += 1
+ else:
+ break
+
self._LineIndex = LineStart - 1
self._ValueList = [V1, V2, V3]
@@ -1164,9 +1185,23 @@ class DscParser(MetaFileParser):
# Only catch expression evaluation error here. We need to report
# the precise number of line on which the error occurred
#
- EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
- File=self._FileWithError, ExtraData=' '.join(self._ValueList),
- Line=self._LineIndex+1)
+ if hasattr(Excpt, 'Pcd'):
+ if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
+ Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd]
+ EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as"
+ " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
+ " of the DSC file, and it is currently defined in this section:"
+ " %s, line #: %d." % (Excpt.Pcd, Info[0], Info[1]),
+ File=self._FileWithError, ExtraData=' '.join(self._ValueList),
+ Line=self._LineIndex+1)
+ else:
+ EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s) is not defined in DSC file" % Excpt.Pcd,
+ File=self._FileWithError, ExtraData=' '.join(self._ValueList),
+ Line=self._LineIndex+1)
+ else:
+ EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
+ File=self._FileWithError, ExtraData=' '.join(self._ValueList),
+ Line=self._LineIndex+1)
except MacroException, Excpt:
EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),
File=self._FileWithError, ExtraData=' '.join(self._ValueList),
@@ -1225,6 +1260,20 @@ class DscParser(MetaFileParser):
Name = TokenSpaceGuid + '.' + PcdName
self._Symbols[Name] = Value
+ Content = open(str(self.MetaFile), 'r').readlines()
+ GlobalData.gPlatformOtherPcds['DSCFILE'] = str(self.MetaFile)
+ for PcdType in (MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_HII,
+ MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII,
+ MODEL_PCD_DYNAMIC_EX_VPD):
+ Records = self._RawTable.Query(PcdType, BelongsToItem=-1.0)
+ for TokenSpaceGuid,PcdName,Value,Dummy2,Dummy3,ID,Line in Records:
+ Name = TokenSpaceGuid + '.' + PcdName
+ if Name not in GlobalData.gPlatformOtherPcds:
+ PcdLine = Line
+ while not Content[Line - 1].lstrip().startswith(TAB_SECTION_START):
+ Line -= 1
+ GlobalData.gPlatformOtherPcds[Name] = (CleanString(Content[Line - 1]), PcdLine, PcdType)
+
def __ProcessDefine(self):
if not self._Enabled:
return
@@ -1386,7 +1435,8 @@ class DscParser(MetaFileParser):
try:
ValueList[0] = ValueExpression(PcdValue, self._Macros)(True)
except WrnExpression, Value:
- ValueList[0] = Value.result
+ ValueList[0] = Value.result
+ PcdValue = ValueList[0]
else:
#
# Int*/Boolean VPD PCD
@@ -1412,8 +1462,10 @@ class DscParser(MetaFileParser):
if ValueList[-1] == 'True':
ValueList[-1] = '1'
if ValueList[-1] == 'False':
- ValueList[-1] = '0'
-
+ ValueList[-1] = '0'
+ PcdValue = ValueList[-1]
+ if PcdValue and self._ItemType in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]:
+ GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue
self._ValueList[2] = '|'.join(ValueList)
def __ProcessComponent(self):
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py
index f20eab9688..088a118de1 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
@@ -50,11 +50,13 @@ class MetaFileTable(Table):
def IsIntegrity(self):
try:
+ TimeStamp = self.MetaFile.TimeStamp
Result = self.Cur.execute("select ID from %s where ID<0" % (self.Table)).fetchall()
if not Result:
+ # update the timestamp in database
+ self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)
return False
- TimeStamp = self.MetaFile.TimeStamp
if TimeStamp != self._FileIndexTable.GetFileTimeStamp(self.IdBase):
# update the timestamp in database
self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 6ff33db329..16766d32dc 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -262,7 +262,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Header == None:
self._GetHeaderInfo()
if self._Guid == None:
- EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No FILE_GUID", File=self.MetaFile)
+ EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_GUID", File=self.MetaFile)
return self._Guid
## Retrieve platform version
@@ -271,7 +271,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Header == None:
self._GetHeaderInfo()
if self._Version == None:
- self._Version = ''
+ EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_VERSION", File=self.MetaFile)
return self._Version
## Retrieve platform description file version
@@ -280,7 +280,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Header == None:
self._GetHeaderInfo()
if self._DscSpecification == None:
- self._DscSpecification = ''
+ EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No DSC_SPECIFICATION", File=self.MetaFile)
return self._DscSpecification
## Retrieve OUTPUT_DIRECTORY
@@ -298,7 +298,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Header == None:
self._GetHeaderInfo()
if self._SupArchList == None:
- self._SupArchList = ARCH_LIST
+ EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No SUPPORTED_ARCHITECTURES", File=self.MetaFile)
return self._SupArchList
## Retrieve BUILD_TARGETS
@@ -307,7 +307,7 @@ class DscBuildData(PlatformBuildClassObject):
if self._Header == None:
self._GetHeaderInfo()
if self._BuildTargets == None:
- self._BuildTargets = ['DEBUG', 'RELEASE', 'NOOPT']
+ EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BUILD_TARGETS", File=self.MetaFile)
return self._BuildTargets
## Retrieve SKUID_IDENTIFIER
@@ -463,7 +463,8 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,
ExtraData=ErrorInfo)
# Check duplication
- if ModuleFile in self._Modules:
+ # If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected
+ if self._Arch != 'COMMON' and ModuleFile in self._Modules:
EdkLogger.error('build', FILE_DUPLICATED, File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo)
Module = ModuleBuildClassObject()
@@ -841,6 +842,17 @@ class DscBuildData(PlatformBuildClassObject):
self.Pcds[Name, Guid] = PcdClassObject(Name, Guid, '', '', '', '', '', {}, False, None)
self.Pcds[Name, Guid].DefaultValue = Value
+ def IsPlatformPcdDeclared(self, DecPcds):
+ for PcdType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_FEATURE_FLAG,
+ MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_VPD,
+ MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII, MODEL_PCD_DYNAMIC_EX_VPD):
+ RecordList = self._RawData[PcdType, self._Arch]
+ for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
+ if (PcdCName, TokenSpaceGuid) not in DecPcds:
+ EdkLogger.error('build', PARSER_ERROR,
+ "Pcd (%s.%s) defined in DSC is not declared in DEC files." % (TokenSpaceGuid, PcdCName),
+ File=self.MetaFile, Line=Dummy4)
+
_Macros = property(_GetMacros)
Arch = property(_GetArch, _SetArch)
Platform = property(_GetPlatformName)
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index f3555d705d..e20131a312 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -33,7 +33,12 @@ from Common.Misc import GuidStructureStringToGuidString
from Common.InfClassObject import gComponentType2ModuleType
from Common.BuildToolError import FILE_WRITE_FAILURE
from Common.BuildToolError import CODE_ERROR
-
+from Common.DataType import TAB_LINE_BREAK
+from Common.DataType import TAB_DEPEX
+from Common.DataType import TAB_SLASH
+from Common.DataType import TAB_SPACE_SPLIT
+from Common.DataType import TAB_BRG_PCD
+from Common.DataType import TAB_BRG_LIBRARY
## Pattern to extract contents in EDK DXS files
gDxsDependencyPattern = re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL)
@@ -63,15 +68,19 @@ gIncludePattern2 = re.compile(r"#include\s+EFI_([A-Z_]+)\s*[(]\s*(\w+)\s*[)]")
## Pattern to find the entry point for EDK module using EDKII Glue library
gGlueLibEntryPoint = re.compile(r"__EDKII_GLUE_MODULE_ENTRY_POINT__\s*=\s*(\w+)")
+## Tags for MaxLength of line in report
+gLineMaxLength = 120
+
## Tags for section start, end and separator
-gSectionStart = ">" + "=" * 118 + "<"
-gSectionEnd = "<" + "=" * 118 + ">" + "\n"
-gSectionSep = "=" * 120
+gSectionStart = ">" + "=" * (gLineMaxLength-2) + "<"
+gSectionEnd = "<" + "=" * (gLineMaxLength-2) + ">" + "\n"
+gSectionSep = "=" * gLineMaxLength
## Tags for subsection start, end and separator
-gSubSectionStart = ">" + "-" * 118 + "<"
-gSubSectionEnd = "<" + "-" * 118 + ">"
-gSubSectionSep = "-" * 120
+gSubSectionStart = ">" + "-" * (gLineMaxLength-2) + "<"
+gSubSectionEnd = "<" + "-" * (gLineMaxLength-2) + ">"
+gSubSectionSep = "-" * gLineMaxLength
+
## The look up table to map PCD type to pair of report display type and DEC type
gPcdTypeMap = {
@@ -166,6 +175,37 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFiles):
IncludeFiles[FullFileName.lower().replace("\\", "/")] = FullFileName
break
+## Split each lines in file
+#
+# This method is used to split the lines in file to make the length of each line
+# less than MaxLength.
+#
+# @param Content The content of file
+# @param MaxLength The Max Length of the line
+#
+def FileLinesSplit(Content=None, MaxLength=None):
+ ContentList = Content.split(TAB_LINE_BREAK)
+ NewContent = ''
+ NewContentList = []
+ for Line in ContentList:
+ while len(Line.rstrip()) > MaxLength:
+ LineSpaceIndex = Line.rfind(TAB_SPACE_SPLIT, 0, MaxLength)
+ LineSlashIndex = Line.rfind(TAB_SLASH, 0, MaxLength)
+ LineBreakIndex = MaxLength
+ if LineSpaceIndex > LineSlashIndex:
+ LineBreakIndex = LineSpaceIndex
+ elif LineSlashIndex > LineSpaceIndex:
+ LineBreakIndex = LineSlashIndex
+ NewContentList.append(Line[:LineBreakIndex])
+ Line = Line[LineBreakIndex:]
+ if Line:
+ NewContentList.append(Line)
+ for NewLine in NewContentList:
+ NewContent += NewLine + TAB_LINE_BREAK
+ return NewContent
+
+
+
##
# Parse binary dependency expression section
#
@@ -263,7 +303,7 @@ class LibraryReport(object):
#
def GenerateReport(self, File):
FileWrite(File, gSubSectionStart)
- FileWrite(File, "Library")
+ FileWrite(File, TAB_BRG_LIBRARY)
if len(self.LibraryList) > 0:
FileWrite(File, gSubSectionSep)
for LibraryItem in self.LibraryList:
@@ -355,8 +395,10 @@ class DepexReport(object):
#
def GenerateReport(self, File, GlobalDepexParser):
if not self.Depex:
+ FileWrite(File, gSubSectionStart)
+ FileWrite(File, TAB_DEPEX)
+ FileWrite(File, gSubSectionEnd)
return
-
FileWrite(File, gSubSectionStart)
if os.path.isfile(self._DepexFileName):
try:
@@ -685,7 +727,7 @@ class PcdReport(object):
# For module PCD sub-section
#
FileWrite(File, gSubSectionStart)
- FileWrite(File, "PCD")
+ FileWrite(File, TAB_BRG_PCD)
FileWrite(File, gSubSectionSep)
for Key in self.AllPcds:
@@ -1511,7 +1553,8 @@ class BuildReport(object):
File = StringIO('')
for (Wa, MaList) in self.ReportList:
PlatformReport(Wa, MaList, self.ReportType).GenerateReport(File, BuildDuration, self.ReportType)
- SaveFileOnChange(self.ReportFile, File.getvalue(), False)
+ Content = FileLinesSplit(File.getvalue(), gLineMaxLength)
+ SaveFileOnChange(self.ReportFile, Content, True)
EdkLogger.quiet("Build report can be found at %s" % os.path.abspath(self.ReportFile))
except IOError:
EdkLogger.error(None, FILE_WRITE_FAILURE, ExtraData=self.ReportFile)
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index ef52162ea1..a463c527be 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -59,6 +59,9 @@ gBuildConfiguration = "Conf/target.txt"
gBuildCacheDir = "Conf/.cache"
gToolsDefinition = "Conf/tools_def.txt"
+TemporaryTablePattern = re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$')
+TmpTableDict = {}
+
## Check environment PATH variable to make sure the specified tool is found
#
# If the tool is found in the PATH, then True is returned
@@ -1449,6 +1452,14 @@ class Build():
EdkLogger.error("build", BUILD_ERROR, "Failed to build module", ExtraData=GlobalData.gBuildingModule)
#
+ # Save temp tables to a TmpTableDict.
+ #
+ for Key in Wa.BuildDatabase._CACHE_:
+ if Wa.BuildDatabase._CACHE_[Key]._RawData and Wa.BuildDatabase._CACHE_[Key]._RawData._Table and Wa.BuildDatabase._CACHE_[Key]._RawData._Table.Table:
+ if TemporaryTablePattern.match(Wa.BuildDatabase._CACHE_[Key]._RawData._Table.Table):
+ TmpTableDict[Wa.BuildDatabase._CACHE_[Key]._RawData._Table.Table] = Wa.BuildDatabase._CACHE_[Key]._RawData._Table.Cur
+ #
+ #
# All modules have been put in build tasks queue. Tell task scheduler
# to exit if all tasks are completed
#
@@ -1651,8 +1662,8 @@ def MyOptionParser():
help="Build the platform specified by the DSC file name argument, overriding target.txt's ACTIVE_PLATFORM definition.")
Parser.add_option("-m", "--module", action="callback", type="string", dest="ModuleFile", callback=SingleCheckCallback,
help="Build the module specified by the INF file name argument.")
- Parser.add_option("-b", "--buildtarget", action="append", type="choice", choices=['DEBUG','RELEASE','NOOPT'], dest="BuildTarget",
- help="BuildTarget is one of list: DEBUG, RELEASE, NOOPT, which overrides target.txt's TARGET definition. To specify more TARGET, please repeat this option.")
+ Parser.add_option("-b", "--buildtarget", type="string", dest="BuildTarget", help="Using the TARGET to build the platform, overriding target.txt's TARGET definition.",
+ action="append")
Parser.add_option("-t", "--tagname", action="append", type="string", dest="ToolChain",
help="Using the Tool Chain Tagname to build the platform, overriding target.txt's TOOL_CHAIN_TAG definition.")
Parser.add_option("-x", "--sku-id", action="callback", type="string", dest="SkuId", callback=SingleCheckCallback,
@@ -1809,7 +1820,12 @@ def Main():
EdkLogger.error("build", OPTION_VALUE_INVALID, "UNI flag must be one of -c or -s")
MyBuild = Build(Target, Workspace, Option)
+ GlobalData.gCommandLineDefines['ARCH'] = ' '.join(MyBuild.ArchList)
MyBuild.Launch()
+ # Drop temp tables to avoid database locked.
+ for TmpTableName in TmpTableDict:
+ SqlCommand = """drop table IF EXISTS %s""" % TmpTableName
+ TmpTableDict[TmpTableName].execute(SqlCommand)
#MyBuild.DumpBuildData()
except FatalError, X:
if MyBuild != None:
diff --git a/BaseTools/Source/Python/fpd2dsc/EdkIIWorkspaceGuidsInfo.py b/BaseTools/Source/Python/fpd2dsc/EdkIIWorkspaceGuidsInfo.py
deleted file mode 100644
index 68fa79e7a4..0000000000
--- a/BaseTools/Source/Python/fpd2dsc/EdkIIWorkspaceGuidsInfo.py
+++ /dev/null
@@ -1,327 +0,0 @@
-## @file
-# Collects the Guid Information in current workspace.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-import fnmatch
-from Common.EdkIIWorkspace import EdkIIWorkspace
-from Common.MigrationUtilities import *
-
-## A class for EdkII work space to resolve Guids
-#
-# This class inherits from EdkIIWorkspace and collects the Guids information
-# in current workspace. The Guids information is important to translate the
-# package Guids and recommended library instances Guids to relative file path
-# (to workspace directory) in MSA files.
-#
-class EdkIIWorkspaceGuidsInfo(EdkIIWorkspace):
-
- ## The classconstructor
- #
- # The constructor initialize workspace directory. It does not collect
- # pakage and module Guids info at initialization; instead, it collects them
- # on the fly.
- #
- # @param self The object pointer
- #
- def __init__(self):
- # Initialize parent class.
- EdkIIWorkspace.__init__(self)
- # The internal map from Guid to FilePath.
- self.__GuidToFilePath = {}
- # The internal package directory list.
- self.__PackageDirList = []
- # The internal flag to indicate whether package Guids info has been initialized
- # to avoid re-collection collected.
- self.__PackageGuidInitialized = False
- # The internal flag to indicate whether module Guids info has been initialized
- # to avoid re-collection collected.
- self.__ModuleGuidInitialized = False
-
- ## Add Guid, Version and FilePath to Guids database
- #
- # Add Guid, Version and FilePath to Guids database. It constructs a map
- # table from Guid, Version to FilePath internally. If also detects possible
- # Guid collision. For now, the version information is simply ignored and
- # Guid value itself acts as master key.
- #
- # @param self The object pointer
- # @param Guid The Guid Value
- # @param Version The version information
- # @param FilePath The Guid related file path
- #
- # @retval True The Guid value is successfully added to map table
- # @retval False The Guid is an empty string or the map table
- # already contains a same Guid
- #
- def __AddGuidToFilePath(self, Guid, Version, FilePath):
- if Guid == "":
- EdkLogger.info("Cannot find Guid in file %s" % FilePath)
- return False
- #Add the Guid value to map table to ensure case insensitive comparison.
- OldFilePath = self.__GuidToFilePath.setdefault(Guid.lower(), FilePath)
- if OldFilePath == FilePath:
- EdkLogger.verbose("File %s has new Guid '%s'" % (FilePath, Guid))
- return True
- else:
- EdkLogger.info("File %s has duplicate Guid with & %s" % (FilePath, OldFilePath))
- return False
-
-
- ## Gets file information from a module description file
- #
- # Extracts Module Name, File Guid and Version number from INF, MSA and NMSA
- # file. It supports to exact such information from text based INF file or
- # XML based (N)MSA file.
- #
- # @param self The object pointer
- # @param FileName The input module file name
- #
- # @retval True This module file represents a new module discovered
- # in current workspace
- # @retval False This module file is not regarded as a valid module
- # The File Guid cannot be extracted or the another
- # file with the same Guid already exists
- #
- def __GetModuleFileInfo(self, FileName):
- if fnmatch.fnmatch(FileName, "*.inf"):
- TagTuple = ("BASE_NAME", "FILE_GUID", "VERSION_STRING")
- (Name, Guid, Version) = GetTextFileInfo(FileName, TagTuple)
- else :
- XmlTag1 = "ModuleSurfaceArea/MsaHeader/ModuleName"
- XmlTag2 = "ModuleSurfaceArea/MsaHeader/GuidValue"
- XmlTag3 = "ModuleSurfaceArea/MsaHeader/Version"
- TagTuple = (XmlTag1, XmlTag2, XmlTag3)
- (Name, Guid, Version) = GetXmlFileInfo(FileName, TagTuple)
-
- return self.__AddGuidToFilePath(Guid, Version, FileName)
-
-
- ## Gets file information from a package description file
- #
- # Extracts Package Name, File Guid and Version number from INF, SPD and NSPD
- # file. It supports to exact such information from text based DEC file or
- # XML based (N)SPD file. EDK Compatibility Package is hardcoded to be
- # ignored since no EDKII INF file depends on that package.
- #
- # @param self The object pointer
- # @param FileName The input package file name
- #
- # @retval True This package file represents a new package
- # discovered in current workspace
- # @retval False This package is not regarded as a valid package
- # The File Guid cannot be extracted or the another
- # file with the same Guid already exists
- #
- def __GetPackageFileInfo(self, FileName):
- if fnmatch.fnmatch(FileName, "*.dec"):
- TagTuple = ("PACKAGE_NAME", "PACKAGE_GUID", "PACKAGE_VERSION")
- (Name, Guid, Version) = GetTextFileInfo(FileName, TagTuple)
- else:
- XmlTag1 = "PackageSurfaceArea/SpdHeader/PackageName"
- XmlTag2 = "PackageSurfaceArea/SpdHeader/GuidValue"
- XmlTag3 = "PackageSurfaceArea/SpdHeader/Version"
- TagTuple = (XmlTag1, XmlTag2, XmlTag3)
- (Name, Guid, Version) = GetXmlFileInfo(FileName, TagTuple)
-
- if Name == "EdkCompatibilityPkg":
- # Do not scan EDK compatibitilty package to avoid Guid collision
- # with those in EDK Glue Library.
- EdkLogger.verbose("Bypass EDK Compatibility Pkg")
- return False
-
- return self.__AddGuidToFilePath(Guid, Version, FileName)
-
- ## Iterate on all package files listed in framework database file
- #
- # Yields all package description files listed in framework database files.
- # The framework database file describes the packages current workspace
- # includes.
- #
- # @param self The object pointer
- #
- def __FrameworkDatabasePackageFiles(self):
- XmlFrameworkDb = XmlParseFile(self.WorkspaceFile)
- XmlTag = "FrameworkDatabase/PackageList/Filename"
- for PackageFile in XmlElementList(XmlFrameworkDb, XmlTag):
- yield os.path.join(self.WorkspaceDir, PackageFile)
-
-
- ## Iterate on all package files in current workspace directory
- #
- # Yields all package description files listed in current workspace
- # directory. This happens when no framework database file exists.
- #
- # @param self The object pointer
- #
- def __TraverseAllPackageFiles(self):
- for Path, Dirs, Files in os.walk(self.WorkspaceDir):
- # Ignore svn version control directory.
- if ".svn" in Dirs:
- Dirs.remove(".svn")
- if "Build" in Dirs:
- Dirs.remove("Build")
- # Assume priority from high to low: DEC, NSPD, SPD.
- PackageFiles = fnmatch.filter(Files, "*.dec")
- if len(PackageFiles) == 0:
- PackageFiles = fnmatch.filter(Files, "*.nspd")
- if len(PackageFiles) == 0:
- PackageFiles = fnmatch.filter(Files, "*.spd")
-
- for File in PackageFiles:
- # Assume no more package decription file in sub-directory.
- del Dirs[:]
- yield os.path.join(Path, File)
-
- ## Iterate on all module files in current package directory
- #
- # Yields all module description files listed in current package
- # directory.
- #
- # @param self The object pointer
- #
- def __TraverseAllModuleFiles(self):
- for PackageDir in self.__PackageDirList:
- for Path, Dirs, Files in os.walk(PackageDir):
- # Ignore svn version control directory.
- if ".svn" in Dirs:
- Dirs.remove(".svn")
- # Assume priority from high to low: INF, NMSA, MSA.
- ModuleFiles = fnmatch.filter(Files, "*.inf")
- if len(ModuleFiles) == 0:
- ModuleFiles = fnmatch.filter(Files, "*.nmsa")
- if len(ModuleFiles) == 0:
- ModuleFiles = fnmatch.filter(Files, "*.msa")
-
- for File in ModuleFiles:
- yield os.path.join(Path, File)
-
- ## Initialize package Guids info mapping table
- #
- # Collects all package guids map to package decription file path. This
- # function is invokes on demand to avoid unnecessary directory scan.
- #
- # @param self The object pointer
- #
- def __InitializePackageGuidInfo(self):
- if self.__PackageGuidInitialized:
- return
-
- EdkLogger.verbose("Start to collect Package Guids Info.")
-
- WorkspaceFile = os.path.join("Conf", "FrameworkDatabase.db")
- self.WorkspaceFile = os.path.join(self.WorkspaceDir, WorkspaceFile)
-
- # Try to find the frameworkdatabase file to discover package lists
- if os.path.exists(self.WorkspaceFile):
- TraversePackage = self.__FrameworkDatabasePackageFiles
- EdkLogger.verbose("Package list bases on: %s" % self.WorkspaceFile)
- else:
- TraversePackage = self.__TraverseAllPackageFiles
- EdkLogger.verbose("Package list in: %s" % self.WorkspaceDir)
-
- for FileName in TraversePackage():
- if self.__GetPackageFileInfo(FileName):
- PackageDir = os.path.dirname(FileName)
- EdkLogger.verbose("Find new package directory %s" % PackageDir)
- self.__PackageDirList.append(PackageDir)
-
- self.__PackageGuidInitialized = True
-
- ## Initialize module Guids info mapping table
- #
- # Collects all module guids map to module decription file path. This
- # function is invokes on demand to avoid unnecessary directory scan.
- #
- # @param self The object pointer
- #
- def __InitializeModuleGuidInfo(self):
- if self.__ModuleGuidInitialized:
- return
- EdkLogger.verbose("Start to collect Module Guids Info")
-
- self.__InitializePackageGuidInfo()
- for FileName in self.__TraverseAllModuleFiles():
- if self.__GetModuleFileInfo(FileName):
- EdkLogger.verbose("Find new module %s" % FileName)
-
- self.__ModuleGuidInitialized = True
-
- ## Get Package file path by Package Guid and Version
- #
- # Translates the Package Guid and Version to a file path relative
- # to workspace directory. If no package in current workspace match the
- # input Guid, an empty file path is returned. For now, the version
- # value is simply ignored.
- #
- # @param self The object pointer
- # @param Guid The Package Guid value to look for
- # @param Version The Package Version value to look for
- #
- def ResolvePackageFilePath(self, Guid, Version = ""):
- self.__InitializePackageGuidInfo()
-
- EdkLogger.verbose("Resolve Package Guid '%s'" % Guid)
- FileName = self.__GuidToFilePath.get(Guid.lower(), "")
- if FileName == "":
- EdkLogger.info("Cannot resolve Package Guid '%s'" % Guid)
- else:
- FileName = self.WorkspaceRelativePath(FileName)
- FileName = os.path.splitext(FileName)[0] + ".dec"
- FileName = FileName.replace("\\", "/")
- return FileName
-
- ## Get Module file path by Module Guid and Version
- #
- # Translates the Module Guid and Version to a file path relative
- # to workspace directory. If no module in current workspace match the
- # input Guid, an empty file path is returned. For now, the version
- # value is simply ignored.
- #
- # @param self The object pointer
- # @param Guid The Module Guid value to look for
- # @param Version The Module Version value to look for
- #
- def ResolveModuleFilePath(self, Guid, Version = ""):
- self.__InitializeModuleGuidInfo()
-
- EdkLogger.verbose("Resolve Module Guid '%s'" % Guid)
- FileName = self.__GuidToFilePath.get(Guid.lower(), "")
- if FileName == "":
- EdkLogger.info("Cannot resolve Module Guid '%s'" % Guid)
- else:
- FileName = self.WorkspaceRelativePath(FileName)
- FileName = os.path.splitext(FileName)[0] + ".inf"
- FileName = FileName.replace("\\", "/")
- return FileName
-
-# A global class object of EdkIIWorkspaceGuidsInfo for external reference.
-gEdkIIWorkspaceGuidsInfo = EdkIIWorkspaceGuidsInfo()
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- # Test the translation of package Guid.
-# MdePkgGuid = "1E73767F-8F52-4603-AEB4-F29B510B6766"
-# OldMdePkgGuid = "5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
-# print gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(MdePkgGuid)
-# print gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(OldMdePkgGuid)
-
- # Test the translation of module Guid.
-# UefiLibGuid = "3a004ba5-efe0-4a61-9f1a-267a46ae5ba9"
-# UefiDriverModelLibGuid = "52af22ae-9901-4484-8cdc-622dd5838b09"
-# print gEdkIIWorkspaceGuidsInfo.ResolvePlatformFilePath(UefiLibGuid)
-# print gEdkIIWorkspaceGuidsInfo.ResolvePlatformFilePath(UefiDriverModelLibGuid)
- pass \ No newline at end of file
diff --git a/BaseTools/Source/Python/fpd2dsc/LoadFpd.py b/BaseTools/Source/Python/fpd2dsc/LoadFpd.py
deleted file mode 100644
index fe271ac85b..0000000000
--- a/BaseTools/Source/Python/fpd2dsc/LoadFpd.py
+++ /dev/null
@@ -1,1039 +0,0 @@
-## @file
-# Open an FPD file and load all its contents to a PlatformClass object.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-from CommonDataClass.PlatformClass import *
-from CommonDataClass.FdfClass import *
-from Common.XmlRoutines import *
-from Common.MigrationUtilities import *
-from EdkIIWorkspaceGuidsInfo import gEdkIIWorkspaceGuidsInfo
-
-## Load Platform Header
-#
-# Read an input Platform XML DOM object and return Platform Header class object
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-# @param FpdFileName The file path of FPD File
-#
-# @retvel PlatformHeader A new Platform Header object loaded from XmlFpd
-#
-def LoadPlatformHeader(XmlFpd, FpdFileName):
- PlatformHeader = PlatformHeaderClass()
-
- XmlTag = "PlatformSurfaceArea/PlatformHeader"
- FpdHeader = XmlNode(XmlFpd, XmlTag)
-
- SetIdentification(PlatformHeader, FpdHeader, "PlatformName", FpdFileName)
- SetCommonHeader(PlatformHeader, FpdHeader)
-
- XmlTag = "PlatformSurfaceArea/PlatformHeader/Specification"
- List = XmlElement(XmlFpd, XmlTag).split()
- SpecificationName = List[0]
- SpecificationValue = List[1]
- PlatformHeader.Specification = {SpecificationName:SpecificationValue}
-
- XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SupportedArchitectures"
- PlatformHeader.SupArchList = XmlElement(XmlFpd, XmlTag).split()
-
- XmlTag = "PlatformSurfaceArea/PlatformDefinitions/BuildTargets"
- PlatformHeader.BuildTargets = XmlElement(XmlFpd, XmlTag).split()
-
- XmlTag = "PlatformSurfaceArea/PlatformDefinitions/IntermediateDirectories"
- PlatformHeader.IntermediateDirectories = XmlElement(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/PlatformDefinitions/OutputDirectory"
- PlatformHeader.OutputDirectory = XmlElement(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SkuInfo"
- List = map(LoadSkuId, XmlList(XmlFpd, XmlTag))
- if List != []:
- PlatformHeader.SkuIdName = List[0]
-
- return PlatformHeader
-
-## Load a Platform SkuId
-#
-# Read an input Platform XML DOM object and return a list of Platform SkuId
-# contained in the DOM object.
-#
-# @param XmlPlatformSkuInfo An XML DOM object read from FPD file
-#
-# @retvel PlatformSkuInfo A SkuInfo loaded from XmlFpd
-#
-def LoadPlatformSkuInfo(XmlPlatformSkuInfo):
- XmlTag = "SkuInfo/SkuId"
- SkuInfo = []
- SkuId = XmlElement(XmlPlatformSkuInfo, XmlTag)
- SkuInfo.append(SkuId)
-
- XmlTag = "SkuInfo/Value"
- Value = XmlElement(XmlPlatformSkuInfo, XmlTag)
- SkuInfo.append(Value)
- return SkuInfo
-
-## Load a Platform SkuId
-#
-# Read an input Platform XML DOM object and return a list of Platform SkuId
-# contained in the DOM object.
-#
-# @param XmlSkuInfo An XML DOM object read from FPD file
-#
-# @retvel List A list of SkuId and SkuValue loaded from XmlFpd
-#
-def LoadSkuId(XmlSkuInfo):
- XmlTag = "SkuInfo/UiSkuName"
- SkuValue = XmlElement(XmlSkuInfo, XmlTag)
-
- XmlTag = "SkuInfo/UiSkuName"
- List = map(LoadSkuID, XmlList(XmlSkuInfo, XmlTag))
- if List != []:
- SkuID = List[0]
- #SkuID = XmlAttribute(XmlSkuInfo, XmlTag)
- List = []
- List.append(SkuID)
- List.append(SkuValue)
- return List
-
-def LoadSkuID(XmlUiSkuName):
- XmlTag = "SkuID"
- SkuID = XmlAttribute(XmlUiSkuName, XmlTag)
- return SkuID
-
-## Load a list of Platform SkuIds
-#
-# Read an input Platform XML DOM object and return a list of Platform SkuId
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel PlatformSkuIds A platform SkuIds object loaded from XmlFpd
-#
-def LoadPlatformSkuInfos(XmlFpd):
- PlatformSkuIds = SkuInfoListClass()
-
- SkuInfoList = []
-
- XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SkuInfo"
- List = map(LoadSkuId, XmlList(XmlFpd, XmlTag))
- SkuInfoList = List
-
- XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SkuInfo/UiSkuName"
- Value = XmlElement(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/DynamicPcdBuildDefinitions/PcdBuildData/SkuInfo"
- # here return a List
- List = map(LoadPlatformSkuInfo, XmlList(XmlFpd, XmlTag))
-
- for SkuInfo in List:
- SkuId = SkuInfo[0]
- Value = SkuInfo[1]
-
- SkuInfoList.append(SkuInfo)
-
- PlatformSkuIds.SkuInfoList = SkuInfoList
-
- return PlatformSkuIds
-
-## Load Platform Module Build Option
-#
-# Read an input Platform XML DOM object and return Platform Module Build Option class object
-# contained in the DOM object.
-#
-# @param XmlModuleBuildOption An XML DOM object read from FPD file
-#
-# @retvel PlatformBuildOption A Platform Build Option object loaded from XmlFpd
-#
-def LoadModuleBuildOption(XmlModuleBuildOption):
- PlatformBuildOption = PlatformBuildOptionClass()
- PlatformBuildOption.UserDefinedAntTasks = {}
-
- XmlTag = "BuildOptions/Options/Option"
- PlatformBuildOption.Options = map(LoadBuildOption, XmlList(XmlModuleBuildOption, XmlTag))
-
- PlatformBuildOption.UserExtensions = {}
- PlatformBuildOption.FfsKeyList = {}
- return PlatformBuildOption
-
-## Load Platform Module Extern
-#
-# Read an input Platform XML DOM object and return Platform Module Extern class object
-# contained in the DOM object.
-#
-# @param XmlModuleExtern An XML DOM object read from FPD file
-#
-# @retvel PlatformModuleExtern A Platform Module Extern object loaded from XmlFpd
-#
-def LoadModuleExtern(XmlModuleExtern):
- PlatformModuleExtern = []
-
- XmlTag = "Externs/PcdIsDriver"
- PcdIsDriver = XmlElement(XmlModuleExtern, XmlTag)
- PlatformModuleExtern.append(PcdIsDriver)
-
- XmlTag = "Externs/Specification"
- Specification = XmlElement(XmlModuleExtern, XmlTag)
- PlatformModuleExtern.append(Specification)
-
- XmlTag = "Externs/Extern"
-
- return PlatformModuleExtern
-
-## Load Platform ModuleSaBuildOptions
-#
-# Read an input Platform XML DOM object and return Platform ModuleSaBuildOptions class object
-# contained in the DOM object.
-#
-# @param XmlModuleSaBuildOptions An XML DOM object read from FPD file
-#
-# @retvel PlatformBuildOptions A list of Platform ModuleSaBuildOption object loaded from XmlFpd
-#
-def LoadPlatformModuleSaBuildOption(XmlModuleSA):
- PlatformModuleSaBuildOption = PlatformBuildOptionClasses()
-
- XmlTag = "ModuleSA/ModuleSaBuildOptions/FvBinding"
- PlatformModuleSaBuildOption.FvBinding = XmlElement(XmlModuleSA, XmlTag)
-
- XmlTag = "ModuleSA/ModuleSaBuildOptions/FfsFormatKey"
- PlatformModuleSaBuildOption.FfsFormatKey = XmlElement(XmlModuleSA, XmlTag)
-
- XmlTag = "ModuleSA/ModuleSaBuildOptions/FfsFileNameGuid"
- PlatformModuleSaBuildOption.FfsFileNameGuid = XmlElement(XmlModuleSA, XmlTag)
-
- XmlTag = "ModuleSA/ModuleSaBuildOptions/Options/Option"
- PlatformModuleSaBuildOption.BuildOptionList = map(LoadBuildOption, XmlList(XmlModuleSA, XmlTag))
-
- return PlatformModuleSaBuildOption
-
-## Load a list of Platform Library Classes
-#
-# Read an input Platform XML DOM object and return a list of Library Classes
-# contained in the DOM object.
-#
-# @param XmlLibraryInstance An XML DOM object read from FPD file
-#
-# @retvel LibraryInstance A Library Instance loaded from XmlFpd
-#
-def LoadPlatformModuleLibraryInstance(XmlLibraryInstance):
- LibraryInstance = []
-
- XmlTag = "ModuleGuid"
- ModuleGuid = XmlAttribute(XmlLibraryInstance, XmlTag)
-
- ModulePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(ModuleGuid)
- ModuleMSAFile = ModulePath.replace('.inf', '.msa')
- WorkSpace = os.getenv('WORKSPACE')
- ModuleMSAFileName = os.path.join(WorkSpace, ModuleMSAFile)
- XmlMsa = XmlParseFile(ModuleMSAFileName)
-
- XmlTag = "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass/Keyword"
- Name = XmlElement(XmlMsa, XmlTag)
- LibraryInstance.append(Name)
- LibraryInstance.append(ModulePath)
-
- #XmlTag = "PackageGuid"
- #PackageGuid = XmlAttribute(XmlLibraryInstance, XmlTag)
- #LibraryInstance.append(PackageGuid)
- return LibraryInstance
-
-## Load a Library Class
-#
-# Read an input Platform XML DOM object and return a library class object
-# contained in the DOM object.
-#
-# @param XmlLibraryClass An XML DOM object read from FPD file
-#
-# @retvel SupModuleList A Library Class Supported Module List object loaded from XmlFpd
-#
-def LoadLibraryClassSupModuleList(XmlLibraryClass):
- XmlTag = "Usage"
- Usage = XmlAttribute(XmlLibraryClass, XmlTag)
- if Usage == "ALWAYS_PRODUCED":
- XmlTag = "SupModuleList"
- SupModuleList = XmlAttribute(XmlLibraryClass, XmlTag).split()
- return SupModuleList
-
-## Load Platform Library Class
-#
-# Read an input Platform XML DOM object and return Platform module class object
-# contained in the DOM object.
-#
-# @param XmlLibraries An XML DOM object read from FPD file
-#
-# @retvel PlatformLibraryClass A Platform Library Class object loaded from XmlFpd
-#
-def LoadPlatformLibraryClass(XmlPlatformLibraryClass):
- PlatformLibraryInstance = PlatformLibraryClass()
-
- XmlTag = "ModuleGuid"
- LibraryInstanceModuleGuid = XmlAttribute(XmlPlatformLibraryClass, XmlTag)
-
- XmlTag = "PackageGuid"
- LibraryInstancePackageGuid = XmlAttribute(XmlPlatformLibraryClass, XmlTag)
-
- LibraryInstancePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(LibraryInstanceModuleGuid)
-
- if LibraryInstancePath != "": # if LibraryInstancePath == "" that's because the module guid cannot be resolved
- PlatformLibraryInstance.FilePath = LibraryInstancePath
- # replace *.inf to *.msa
- LibraryInstanceMSAName = LibraryInstancePath.replace('.inf', '.msa')
- WorkSpace = os.getenv('WORKSPACE')
- LibraryInstanceMSAPath = os.path.join(WorkSpace, LibraryInstanceMSAName)
-
- PlatformLibraryInstance.FilePath = LibraryInstancePath
-
- XmlMsa = XmlParseFile(LibraryInstanceMSAPath)
-
- XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleName"
- PlatformLibraryInstance.Name = XmlElement(XmlMsa, XmlTag)
-
- XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleType"
- PlatformLibraryInstance.ModuleType = XmlElement(XmlMsa, XmlTag)
-
- if PlatformLibraryInstance.ModuleType != "BASE":
- XmlTag = "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
- List = map(LoadLibraryClassSupModuleList, XmlList(XmlMsa, XmlTag))
- if List != []:
- PlatformLibraryInstance.SupModuleList = List[0]
- XmlTag = "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"
- PlatformLibraryInstance.SupArchList = XmlElement(XmlMsa, XmlTag).split()
-
- PlatformLibraryInstance.ModuleGuid = LibraryInstanceModuleGuid
-
- XmlTag = "ModuleSurfaceArea/MsaHeader/Version"
- PlatformLibraryInstance.ModuleVersion = XmlElement(XmlMsa, XmlTag)
-
- PlatformLibraryInstance.PackageGuid = LibraryInstancePackageGuid
- PlatformLibraryInstance.PackageVersion = ''
-
- return PlatformLibraryInstance
-
-## Load Platform Library Classes
-#
-# Read an input Platform XML DOM object and return Platform module class object
-# contained in the DOM object.
-#
-# @param XmlLibraries An XML DOM object read from FPD file
-#
-# @retvel PlatformLibraryClasses A list of Platform Library Class object loaded from XmlFpd
-#
-def LoadPlatformLibraryClasses(XmlFpd):
- PlatformLibraryInstances = PlatformLibraryClasses()
- PlatformLibraryInstances.LibraryList = []
-
- List = []
- XmlTag = "PlatformSurfaceArea/FrameworkModules/ModuleSA/Libraries/Instance"
- List = map(LoadPlatformLibraryClass, XmlList(XmlFpd, XmlTag))
- #List.sort()
- if List == []:
- print "Error"
- else:
- PlatformLibraryInstances.LibraryList = List
-
- return PlatformLibraryInstances
-
-## Load Platform module
-#
-# Read an input Platform XML DOM object and return Platform module class object
-# contained in the DOM object.
-#
-# @param XmlModuleSA An XML DOM object read from FPD file
-#
-# @retvel PlatformModule A Platform module object loaded from XmlFpd
-#
-def LoadModuleSA(XmlModuleSA):
- PlatformModule = PlatformModuleClass()
-
- # three parts: Libraries instances, PcdBuildDefinition, ModuleSaBuildOptions
- XmlTag = "ModuleSA/Libraries/Instance"
-
- PlatformModule.LibraryClasses = map(LoadPlatformModuleLibraryInstance, XmlList(XmlModuleSA, XmlTag))
-
- XmlTag = "ModuleSA/PcdBuildDefinition/PcdData"
- PlatformModule.PcdBuildDefinitions = map(LoadPlatformPcdData, XmlList(XmlModuleSA, XmlTag))
-
- XmlTag = "ModuleSA/ModuleSaBuildOptions"
- PlatformModule.ModuleSaBuildOption = LoadPlatformModuleSaBuildOption(XmlModuleSA)
-
- XmlTag = "ModuleSA/BuildOptions"
- PlatformModule.BuildOptions = map(LoadModuleBuildOption, XmlList(XmlModuleSA, XmlTag)) #bugbug fix me
-
- XmlTag = "ModuleSA/Externs"
- PlatformModule.Externs = map(LoadModuleExtern, XmlList(XmlModuleSA, XmlTag)) #bugbug fix me
-
- XmlTag = "SupArchList"
- PlatformModule.SupArchList = XmlAttribute(XmlModuleSA, XmlTag).split()
-
- # the package guid which the module depends on, do not care for now
- XmlTag = "PackageGuid"
- PlatformModule.PackageGuid = XmlAttribute(XmlModuleSA, XmlTag)
-
- # the module guid, use this guid to get the module *.msa file and convert it to *.inf file with path
- XmlTag = "ModuleGuid"
- PlatformModule.ModuleGuid = XmlAttribute(XmlModuleSA, XmlTag)
- # use this guid to find the *.msa file path or FilePath $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.msa
- # then convert $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.msa to $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.inf, it's FilePath
- PlatformModulePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(PlatformModule.ModuleGuid)
-
- PlatformModule.FilePath = PlatformModulePath # *.inf file path
- # *.inf back to *.msa
- ModuleMSAFileName = PlatformModulePath.replace('.inf', '.msa')
- WorkSpace = os.getenv('WORKSPACE')
- ModuleMSAFileName = os.path.join(WorkSpace, ModuleMSAFileName)
- # Open this module
- #ModuleMSA = open(ModuleMSAFileName, "r")
- XmlMsa = XmlParseFile(ModuleMSAFileName)
-
- XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleName"
- PlatformModule.Name = XmlElement(XmlMsa, XmlTag) # ModuleName
-
- XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleType"
- PlatformModule.ModuleType = XmlElement(XmlMsa, XmlTag)
-
- # IA32, X64, IPF and EBC which the module support arch
- #XmlTag = "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"
- #PlatformModule.SupArchList = XmlElement(XmlMsa, XmlTag).split()
-
- #XmlTag = "ModuleSurfaceArea/MsaHeader/"
- PlatformModule.Type = '' #LIBRARY | LIBRARY_CLASS | MODULE, used by dsc. New in DSC spec
-
- PlatformModule.ExecFilePath = '' # New in DSC spec
-
- XmlTag = "ModuleSurfaceArea/MsaHeader/Specification"
- PlatformModule.Specifications = XmlElement(XmlMsa, XmlTag).split()
-
- return PlatformModule
-
-## Load Platform modules
-#
-# Read an input Platform XML DOM object and return a list of Platform modules class object
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel PlatformModules A list of Platform modules object loaded from XmlFpd
-#
-def LoadPlatformModules(XmlFpd):
- PlatformModules = PlatformModuleClasses()
-
- XmlTag = "PlatformSurfaceArea/FrameworkModules/ModuleSA"
- PlatformModules.ModuleList = map(LoadModuleSA, XmlList(XmlFpd, XmlTag))
-
- return PlatformModules
-
-## Load Platform Flash Definition File
-#
-# Read an input Platform XML DOM object and return Platform Flash Definition File class object
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-# @param FpdFileName The file path of FPD File
-#
-# @retvel PlatformFlashDefinitionFile A new Platform Flash Definition File object loaded from XmlFpd
-#
-def LoadPlatformFlashDefinitionFile(XmlFpd, FpdFileName):
- PlatformFlashDefinitionFile = PlatformFlashDefinitionFileClass()
-
- XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile"
- PlatformFlashDefinitionFile.FilePath = XmlElement(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile/Id"
- PlatformFlashDefinitionFile.Id = XmlAttribute(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile/UiName"
- PlatformFlashDefinitionFile.UiName = XmlAttribute(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile/Preferred"
- PlatformFlashDefinitionFile.Preferred = XmlAttribute(XmlFpd, XmlTag)
-
- return PlatformFlashDefinitionFile
-
-## Load Platform User Defined Ant Tasks
-#
-# Read an input Platform XML DOM object and return platform
-# User Defined Ant Tasks contained in the DOM object.
-#
-# @param XmlUserDefinedAntTasks An XML DOM object read from FPD file
-#
-# @retvel AntTask An Ant Task loaded from XmlFpd
-#
-def LoadUserDefinedAntTasks(XmlFpd):
- Dict = {}
- AntTask = PlatformAntTaskClass()
-
- XmlTag = "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/Id"
- AntTask.Id = XmlAttribute(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/AntCmdOptions"
- AntTask.AntCmdOptions = XmlElement(XmlFpd, XmlTag)
-
- XmlTag = "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/Filename"
- AntTask.FilePath = XmlElement(XmlFpd, XmlTag)
-
- Dict[AntTask.Id] = AntTask
- return Dict
-
-## Load Platform Build Options
-#
-# Read an input Platform XML DOM object and return a list of platform
-# Build Option contained in the DOM object.
-#
-# @param XmlBuildOptions An XML DOM object read from FPD file
-#
-# @retvel PlatformBuildOptions A list of platform Build Options loaded from XmlFpd
-#
-def LoadBuildOptions(XmlBuildOptions):
- XmlTag = "Option"
- return map(LoadBuildOption, XmlList(XmlBuildOptions, XmlTag)) # LoadBuildOption is a method in MigrationUtilities.py
-
-## Load Platform Build Option
-#
-# Read an input Platform XML DOM object and return a Build Option
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel PlatformBuildOption A Build Options loaded from XmlFpd
-#
-def LoadPlatformBuildOption(XmlBuildOptions):
- PlatformBuildOption = PlatformBuildOptionClass()
-
- # handle UserDefinedAntTasks
- XmlTag = "BuildOptions/UserDefinedAntTasks/AntTask"
- PlatformBuildOption.UserDefinedAntTasks = LoadUserDefinedAntTasks(XmlTag)
-
- # handle Options
- XmlTag = "BuildOptions/Options/Option"
- PlatformBuildOption.Options = map(LoadBuildOption, XmlList(XmlBuildOptions, XmlTag))
-
- # handle UserExtensions
- XmlTag = "BuildOptions/UserExtensions"
- PlatformBuildOption.UserExtensions = LoadUserExtensions(XmlTag) # from MigrationUtilities.py LoadUserExtensions
-
- # handle Ffs
- XmlTag = "BuildOptions/Ffs/FfsKey"
- PlatformBuildOption.FfsKeyList = map(LoadPlatformFfs, XmlList(XmlBuildOptions, XmlTag))
-
- return PlatformBuildOption
-
-## Load Platform Ffs Dictionary
-#
-# Read an input Platform XML DOM object and return a platform Ffs Dictionary
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel Dict A platform Ffs Dict loaded from XmlFpd
-#
-def LoadPlatformFfsDict(XmlFpd):
- Dict = {}
- XmlTag = "PlatformSurfaceArea/BuildOptions/Ffs"
- List = map(LoadPlatformFfs, XmlList(XmlFpd, XmlTag))
- if List != []:
- for Ffs in List:
- Dict[Ffs.Key] = Ffs
- return Dict
-
-## Load Platform Ffs Section
-#
-# Read an input Platform XML DOM object and return a platform Ffs Section
-# contained in the DOM object.
-#
-# @param XmlFfs An XML DOM object read from FPD file
-#
-# @retvel PlatformFfsSection A platform Ffs Section loaded from XmlFpd
-#
-def LoadPlatformFfsSection(XmlFfsSection):
- PlatformFfsSection = PlatformFfsSectionClass()
-
- XmlTag = ""
- PlatformFfsSection.BindingOrder = ''
-
- XmlTag = ""
- PlatformFfsSection.Compressible = ''
-
- XmlTag = "SectionType"
- PlatformFfsSection.SectionType = XmlAttribute(XmlFfsSection, XmlTag)
-
- XmlTag = ""
- PlatformFfsSection.EncapsulationType = ''
-
- XmlTag = ""
- PlatformFfsSection.ToolName = ''
-
- XmlTag = ""
- PlatformFfsSection.Filenames = []
-
- XmlTag = ""
- PlatformFfsSection.Args = ''
-
- XmlTag = ""
- PlatformFfsSection.OutFile = ''
-
- XmlTag = ""
- PlatformFfsSection.OutputFileExtension = ''
-
- XmlTag = ""
- PlatformFfsSection.ToolNameElement = ''
-
- return PlatformFfsSection
-
-## Load Platform Ffs Sections
-#
-# Read an input Platform XML DOM object and return a platform Ffs Sections
-# contained in the DOM object.
-#
-# @param XmlFfs An XML DOM object read from FPD file
-#
-# @retvel PlatformFfsSections A platform Ffs Sections loaded from XmlFpd
-#
-def LoadFfsSections():
- PlatformFfsSections = PlatformFfsSectionsClass()
- PlatformFfsSections.BindingOrder = ''
- PlatformFfsSections.Compressible = ''
- PlatformFfsSections.SectionType = ''
- PlatformFfsSections.EncapsulationType = ''
- PlatformFfsSections.ToolName = ''
- PlatformFfsSections.Section = []
- PlatformFfsSections.Sections = []
-
- return PlatformFfsSections
-
-## Load Platform Ffs Sections
-#
-# Read an input Platform XML DOM object and return a platform Ffs Sections
-# contained in the DOM object.
-#
-# @param XmlFfs An XML DOM object read from FPD file
-#
-# @retvel PlatformFfsSections A platform Ffs Sections loaded from XmlFpd
-#
-def LoadPlatformFfsSections(XmlFfsSections):
- PlatformFfsSections = PlatformFfsSectionsClass()
-
- XmlTag = ""
- PlatformFfsSections.BindingOrder = ''
-
- XmlTag = ""
- Compressible = ''
-
- XmlTag = ""
- SectionType = ''
-
- XmlTag = "EncapsulationType"
- EncapsulationType = XmlAttribute(XmlFfsSections, XmlTag)
-
- XmlTag = ""
- ToolName = ''
-
- XmlTag = "Sections/Section"
- Section = [] #[ PlatformFfsSectionClass, ... ]
- Section = map(LoadPlatformFfsSection, XmlList(XmlFfsSections, XmlTag))
-
-
- XmlTag = "Sections/Sections"
- Sections = map(LoadFfsSections, XmlList(XmlFfsSections, XmlTag)) #[ PlatformFfsSectionsClass, ...]
-
- return PlatformFfsSections
-
-## Load Platform Ffs Attribute
-#
-# Read an input Platform XML DOM object and return a platform Ffs Attribute
-# contained in the DOM object.
-#
-# @param XmlFfs An XML DOM object read from FPD file
-#
-# @retvel List A platform Ffs Attribute loaded from XmlFpd
-#
-def LoadFfsAttribute(XmlFfs):
- List = []
- XmlTag = "Ffs/Attribute"
- for XmlAttr in XmlList(XmlFfs, XmlTag):
- XmlTag = "Name"
- Name = XmlAttribute(XmlAttr, XmlTag)
- XmlTag = "Value"
- Value = XmlAttribute(XmlAttr, XmlTag)
- List.append([Name,Value])
- return List
-
-## Load a list of Platform Build Options
-#
-# Read an input Platform XML DOM object and return a list of Build Options
-# contained in the DOM object.
-#
-# @param XmlFfs An XML DOM object read from FPD file
-#
-# @retvel PlatformFfsKey A platform Ffs key loaded from XmlFpd
-#
-def LoadPlatformFfs(XmlFfs):
- PlatformFfs = PlatformFfsClass()
-
- PlatformFfs.Attribute = {}
- Dict = {}
-
- List = LoadFfsAttribute(XmlFfs)
-
- XmlTag = "Ffs/Sections/Sections"
- PlatformFfs.Sections = map(LoadPlatformFfsSections, XmlList(XmlFfs, XmlTag)) #[PlatformFfsSectionsClass, ...]
-
- for Item in List:
- Name = Item[0]
- Value = Item[1]
- for Item in PlatformFfs.Sections:
- Dict[(Name, Item)] = Value
- PlatformFfs.Attribute = Dict
-
- XmlTag = "Ffs/FfsKey"
- PlatformFfs.Key = XmlAttribute(XmlFfs, XmlTag)
-
- return PlatformFfs
-
-## Load a list of Platform Build Options
-#
-# Read an input Platform XML DOM object and return a list of Build Options
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel PlatformBuildOptions A list of Build Options loaded from XmlFpd
-#
-def LoadPlatformBuildOptions(XmlFpd):
- PlatformBuildOptions = PlatformBuildOptionClass()
-
- PlatformBuildOptions.UserDefinedAntTasks = LoadUserDefinedAntTasks(XmlFpd)
-
- XmlTag = "PlatformSurfaceArea/BuildOptions/Options/Option"
- PlatformBuildOptions.Options = map(LoadBuildOption, XmlList(XmlFpd, XmlTag))
-
- PlatformBuildOptions.UserExtensions = LoadPlatformUserExtension(XmlFpd)
-
- PlatformBuildOptions.FfsKeyList = LoadPlatformFfsDict(XmlFpd)
-
- return PlatformBuildOptions
-
-## Load Platform Pcd Data
-#
-# Read an input Platform XML DOM object and return Platform module class object
-# contained in the DOM object.
-#
-# @param XmlPcd An XML DOM object read from FPD file
-#
-# @retvel PlatformPcdData A Platform Pcd object loaded from XmlFpd
-#
-def LoadPlatformPcdData(XmlPcdData):
- PcdData = PcdClass() # defined in CommonDataClass.CommonClass.py
-
- XmlTag = "ItemType"
- PcdData.ItemType = XmlAttribute(XmlPcdData, XmlTag) #DYNAMIC
-
- XmlTag = "PcdData/C_Name"
- PcdData.C_NAME = XmlElement(XmlPcdData, XmlTag)
-
- XmlTag = "PcdData/Token"
- PcdData.Token = XmlElement(XmlPcdData, XmlTag)
-
- XmlTag = "PcdData/TokenSpaceGuidCName"
- PcdData.TokenSpaceGuidCName = XmlElement(XmlPcdData, XmlTag)
-
- XmlTag = "PcdData/DatumType"
- PcdData.DatumType = XmlElement(XmlPcdData, XmlTag)
-
- XmlTag = "PcdData/MaxDatumSize"
- PcdData.MaxDatumSize = XmlElement(XmlPcdData, XmlTag)
-
- XmlTag = "PcdData/Value"
- PcdData.Value = XmlElement(XmlPcdData, XmlTag)
-
- return PcdData
-
-## Load a Platform Pcd Build Data
-#
-# Read an input Platform XML DOM object and return a list of Pcd Dynamic
-# contained in the DOM object.
-#
-# @param XmlPcdBuildData An XML DOM object read from FPD file
-#
-# @retvel PcdBuildData A Platform Pcd Build Data loaded from XmlFpd
-#
-def LoadPlatformPcdBuildData(XmlPcdBuildData):
- PcdBuildData = PcdClass() # defined in CommonDataClass.CommonClass.py
-
- XmlTag = "ItemType"
- PcdBuildData.ItemType = XmlAttribute(XmlPcdBuildData, XmlTag) #DYNAMIC
-
- XmlTag = "PcdBuildData/C_Name"
- PcdBuildData.C_NAME = XmlElement(XmlPcdBuildData, XmlTag)
-
- XmlTag = "PcdBuildData/Token"
- PcdBuildData.Token = XmlElement(XmlPcdBuildData, XmlTag)
-
- XmlTag = "PcdBuildData/TokenSpaceGuidCName"
- PcdBuildData.TokenSpaceGuidCName = XmlElement(XmlPcdBuildData, XmlTag)
-
- XmlTag = "PcdBuildData/DatumType"
- PcdBuildData.DatumType = XmlElement(XmlPcdBuildData, XmlTag)
-
- XmlTag = "PcdBuildData/MaxDatumSize"
- PcdBuildData.MaxDatumSize = XmlElement(XmlPcdBuildData, XmlTag)
-
- #XmlTag = "PcdBuildData/Value"
- #PcdBuildData.Value = XmlElement(XmlPcdBuildData, XmlTag)
-
- return PcdBuildData
-
-## Load a list of Platform Pcd Dynamic
-#
-# Read an input Platform XML DOM object and return a list of Pcd Dynamic
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel PcdDynamic A list of Pcd Dynamic loaded from XmlFpd
-#
-def LoadDynamicPcdBuildDefinitions(XmlFpd):
- DynamicPcdBuildDefinitions = []
- XmlTag = "PlatformSurfaceArea/DynamicPcdBuildDefinitions/PcdBuildData"
- return map(LoadPlatformPcdBuildData, XmlList(XmlFpd, XmlTag))
-
-## Load a Platform NameValue object
-#
-# Read an input Platform XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlNameValue An XML DOM object read from FPD file
-#
-# @retvel NameValue A Platform NameValue object
-#
-def LoadNameValue(XmlNameValue):
- NameValue = []
-
- XmlTag = "Name"
- Name = XmlAttribute(XmlNameValue, XmlTag)
- NameValue.append(Name)
-
- XmlTag = "Value"
- Value = XmlAttribute(XmlNameValue, XmlTag)
- NameValue.append(Value)
-
- return NameValue
-
-## Load a Platform Fv Image Name object
-#
-# Read an input Platform XML DOM object and return a platform Fv Image
-# Name contained in the DOM object.
-#
-# @param XmlFvImageNames An XML DOM object read from FPD file
-#
-# @retvel FvImageNames A Platform Fv Image Name object
-#
-def LoadFvImageNames(XmlFvImageNames):
- XmlTag = "FvImageNames"
- FvImageNames = XmlElement(XmlFvImageNames, XmlTag)
- return FvImageNames
-
-## Load a Platform Fv Image option object
-#
-# Read an input Platform XML DOM object and return a platform Fv Image
-# Option contained in the DOM object.
-#
-# @param XmlFvImageOptions An XML DOM object read from FPD file
-#
-# @retvel PlatformFvImageOption A Platform Fv Image Option object
-#
-def LoadFvImageOptions(XmlFvImageOptions):
- PlatformFvImageOption = PlatformFvImageOptionClass()
-
- XmlTag = ""
- PlatformFvImageOption.FvImageOptionName = ''
-
- XmlTag = ""
- PlatformFvImageOption.FvImageOptionValues = []
-
- XmlTag = "FvImageOptions/NameValue"
- List = map(LoadNameValue, XmlList(XmlFvImageOptions, XmlTag))
-
- return PlatformFvImageOption
-
-## Load a Platform Fv Image object
-#
-# Read an input Platform XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlFvImage An XML DOM object read from Fpd file
-#
-# @retvel PlatformFvImage A Platform Fv Image object
-#
-def LoadPlatformFvImage(XmlFvImage):
- PlatformFvImage = PlatformFvImageClass()
-
- XmlTag = "Name"
- PlatformFvImage.Name = XmlAttribute(XmlFvImage, XmlTag)
-
- XmlTag = "Value"
- PlatformFvImage.Value = XmlAttribute(XmlFvImage, XmlTag)
-
- XmlTag = "Type"
- PlatformFvImage.Type = XmlAttribute(XmlFvImage, XmlTag)
-
- XmlTag = "FvImage/FvImageNames"
- PlatformFvImage.FvImageNames = map(LoadFvImageNames, XmlList(XmlFvImage, XmlTag))
-
- XmlTag = "FvImage/FvImageOptions"
- PlatformFvImage.FvImageOptions = map(LoadFvImageOptions, XmlList(XmlFvImage, XmlTag))
-
- return PlatformFvImage
-
-## Load a Platform fdf object
-#
-# Read an input Platform XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlFvImages An XML DOM object read from FPD file
-#
-# @retvel PlatformFdf A Platform fdf object
-#
-def LoadPlatformFvImages(XmlFvImages):
- List = []
-
- XmlTag = "FvImages/NameValue"
- NameValues = map(LoadNameValue, XmlList(XmlFvImages, XmlTag))
- List.append(NameValues)
-
- XmlTag = "FvImages/FvImage"
- FvImages = map(LoadPlatformFvImage, XmlList(XmlFvImages, XmlTag))
- List.append(FvImages)
-
- XmlTag = "FvImages/FvImageName"
- FvImageNames = map(LoadPlatformFvImageName, XmlList(XmlFvImages, XmlTag))
- List.append(FvImageNames)
-
- return List
-
-## Load a Platform Fv Image Name object
-#
-# Read an input Platform XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlFvImageName An XML DOM object read from FPD file
-#
-# @retvel PlatformFvImageName A Platform Fv Image Name object
-#
-def LoadPlatformFvImageName(XmlFvImageName):
- PlatformFvImageName = PlatformFvImageNameClass()
-
- XmlTag = "Name"
- PlatformFvImageName.Name = XmlAttribute(XmlFvImageName, XmlTag)
-
- XmlTag = "Type"
- PlatformFvImageName.Type = XmlAttribute(XmlFvImageName, XmlTag)
-
- XmlTag = "FvImageOptions"
- PlatformFvImageName.FvImageOptions = map(LoadFvImageOptions, XmlList(XmlFvImageName, XmlTag))
-
- return PlatformFvImageName
-
-## Load a list of Platform fdf objects
-#
-# Read an input Platform XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel PlatformFdfs A list of Platform fdf object
-#
-def LoadPlatformFdfs(XmlFpd):
- PlatformFvImages = PlatformFvImagesClass()
-
- XmlTag = "PlatformSurfaceArea/Flash/FvImages"
- PlatformFvImages.FvImages = map(LoadPlatformFvImages, XmlList(XmlFpd, XmlTag))
-
- return PlatformFvImages
-
-## Load a Platform User Extensions
-#
-# Read an input Platform XML DOM object and return an User Extension
-# contained in the DOM object.
-#
-# @param XmlUserExtension An XML DOM object read from FPD file
-#
-# @retvel PlatformUserExtensions A platform User Extension loaded from XmlFpd
-#
-def LoadPlatformUserExtension(XmlFpd):
- Dict = {}
-
- PlatformUserExtensions = UserExtensionsClass()
-
- XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions"
- List = map(LoadUserExtensions, XmlList(XmlFpd, XmlTag))
- if List != []:
- for Item in List:
- UserID = Item.UserID
- Identifier = Item.Identifier
- Dict[(UserID, Identifier)] = Item
- #XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions/UserID"
- #PlatformUserExtensions.UserID = XmlAttribute(XmlFpd, XmlTag)
-
- #XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions/Identifier"
- #PlatformUserExtensions.Identifier = XmlAttribute(XmlFpd, XmlTag)
-
- #PlatformUserExtensions.Content = XmlElementData(XmlFpd)
- #Dict[(PlatformUserExtensions.UserID,PlatformUserExtensions.Identifier)] = PlatformUserExtensions
- #return PlatformUserExtensions
- return Dict
-
-## Load a list of Platform User Extensions
-#
-# Read an input Platform XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlFpd An XML DOM object read from FPD file
-#
-# @retvel UserExtensions A list of platform User Extensions loaded from XmlFpd
-#
-def LoadPlatformUserExtensions(XmlFpd):
- XmlTag = "PlatformSurfaceArea/UserExtensions"
- return map(LoadUserExtensions, XmlList(XmlFpd, XmlTag)) # from MigrationUtilities.py LoadUserExtensions
-
-## Load a new Platform class object
-#
-# Read an input FPD File and return a new Platform class Object.
-#
-# @param FpdFileName An XML DOM object read from FPD file
-#
-# @retvel Platform A new Platform class object loaded from FPD File
-#
-def LoadFpd(FpdFileName):
- XmlFpd = XmlParseFile(FpdFileName)
- EdkLogger.verbose("Load FPD File: %s" % FpdFileName)
-
- Platform = PlatformClass()
- Platform.Header = LoadPlatformHeader(XmlFpd, FpdFileName)
- Platform.SkuInfos = LoadPlatformSkuInfos(XmlFpd)
- Platform.Libraries = [] #New in dsc spec, do not handle for now
- Platform.LibraryClasses = LoadPlatformLibraryClasses(XmlFpd)
- Platform.Modules = LoadPlatformModules(XmlFpd)
- Platform.FlashDefinitionFile = LoadPlatformFlashDefinitionFile(XmlFpd, FpdFileName)
- Platform.BuildOptions = LoadPlatformBuildOptions(XmlFpd)
- Platform.DynamicPcdBuildDefinitions = LoadDynamicPcdBuildDefinitions(XmlFpd)
- Platform.Fdf = LoadPlatformFdfs(XmlFpd)
- Platform.UserExtensions = LoadPlatformUserExtensions(XmlFpd)
-
- return Platform
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- pass \ No newline at end of file
diff --git a/BaseTools/Source/Python/fpd2dsc/MigrationUtilities.py b/BaseTools/Source/Python/fpd2dsc/MigrationUtilities.py
deleted file mode 100644
index 8e360b9b5b..0000000000
--- a/BaseTools/Source/Python/fpd2dsc/MigrationUtilities.py
+++ /dev/null
@@ -1,563 +0,0 @@
-## @file
-# Contains several utilitities shared by migration tools.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-import re
-import EdkLogger
-from optparse import OptionParser
-from Common.BuildToolError import *
-from XmlRoutines import *
-from CommonDataClass.CommonClass import *
-
-## Set all fields of CommonClass object.
-#
-# Set all attributes of CommonClass object from XML Dom object of XmlCommon.
-#
-# @param Common The destine CommonClass object.
-# @param XmlCommon The source XML Dom object.
-#
-def SetCommon(Common, XmlCommon):
- XmlTag = "Usage"
- Common.Usage = XmlAttribute(XmlCommon, XmlTag).split()
-
- XmlTag = "FeatureFlag"
- Common.FeatureFlag = XmlAttribute(XmlCommon, XmlTag)
-
- XmlTag = "SupArchList"
- Common.SupArchList = XmlAttribute(XmlCommon, XmlTag).split()
-
- XmlTag = XmlNodeName(XmlCommon) + "/" + "HelpText"
- Common.HelpText = XmlElement(XmlCommon, XmlTag)
-
-
-## Set some fields of CommonHeaderClass object.
-#
-# Set Name, Guid, FileName and FullPath fields of CommonHeaderClass object from
-# XML Dom object of XmlCommonHeader, NameTag and FileName.
-#
-# @param CommonHeader The destine CommonClass object.
-# @param XmlCommonHeader The source XML Dom object.
-# @param NameTag The name tag in XML Dom object.
-# @param FileName The file name of the XML file.
-#
-def SetIdentification(CommonHeader, XmlCommonHeader, NameTag, FileName):
- XmlParentTag = XmlNodeName(XmlCommonHeader)
-
- XmlTag = XmlParentTag + "/" + NameTag
- CommonHeader.Name = XmlElement(XmlCommonHeader, XmlTag)
-
- XmlTag = XmlParentTag + "/" + "GuidValue"
- CommonHeader.Guid = XmlElement(XmlCommonHeader, XmlTag)
-
- XmlTag = XmlParentTag + "/" + "Version"
- CommonHeader.Version = XmlElement(XmlCommonHeader, XmlTag)
-
- CommonHeader.FileName = os.path.basename(FileName)
- CommonHeader.FullPath = os.path.abspath(FileName)
-
-
-## Regular expression to match specification and value.
-mReSpecification = re.compile(r"(?P<Specification>\w+)\s+(?P<Value>\w*)")
-
-## Add specification to specification dictionary.
-#
-# Abstract specification name, value pair from Specification String and add them
-# to specification dictionary.
-#
-# @param SpecificationDict The destine Specification dictionary.
-# @param SpecificationString The source Specification String from which the
-# specification name and value pair is abstracted.
-#
-def AddToSpecificationDict(SpecificationDict, SpecificationString):
- """Abstract specification name, value pair from Specification String"""
- for SpecificationMatch in mReSpecification.finditer(SpecificationString):
- Specification = SpecificationMatch.group("Specification")
- Value = SpecificationMatch.group("Value")
- SpecificationDict[Specification] = Value
-
-## Set all fields of CommonHeaderClass object.
-#
-# Set all attributes of CommonHeaderClass object from XML Dom object of
-# XmlCommonHeader, NameTag and FileName.
-#
-# @param CommonHeader The destine CommonClass object.
-# @param XmlCommonHeader The source XML Dom object.
-# @param NameTag The name tag in XML Dom object.
-# @param FileName The file name of the XML file.
-#
-def SetCommonHeader(CommonHeader, XmlCommonHeader):
- """Set all attributes of CommonHeaderClass object from XmlCommonHeader"""
- XmlParent = XmlNodeName(XmlCommonHeader)
-
- XmlTag = XmlParent + "/" + "Abstract"
- CommonHeader.Abstract = XmlElement(XmlCommonHeader, XmlTag)
-
- XmlTag = XmlParent + "/" + "Description"
- CommonHeader.Description = XmlElement(XmlCommonHeader, XmlTag)
-
- XmlTag = XmlParent + "/" + "Copyright"
- CommonHeader.Copyright = XmlElement(XmlCommonHeader, XmlTag)
-
- XmlTag = XmlParent + "/" + "License"
- CommonHeader.License = XmlElement(XmlCommonHeader, XmlTag)
-
- XmlTag = XmlParent + "/" + "Specification"
- Specification = XmlElement(XmlCommonHeader, XmlTag)
-
- AddToSpecificationDict(CommonHeader.Specification, Specification)
-
- XmlTag = XmlParent + "/" + "ModuleType"
- CommonHeader.ModuleType = XmlElement(XmlCommonHeader, XmlTag)
-
-
-## Load a new Cloned Record class object.
-#
-# Read an input XML ClonedRecord DOM object and return an object of Cloned Record
-# contained in the DOM object.
-#
-# @param XmlCloned A child XML DOM object in a Common XML DOM.
-#
-# @retvel ClonedRecord A new Cloned Record object created by XmlCloned.
-#
-def LoadClonedRecord(XmlCloned):
- ClonedRecord = ClonedRecordClass()
-
- XmlTag = "Id"
- ClonedRecord.Id = int(XmlAttribute(XmlCloned, XmlTag))
-
- XmlTag = "FarGuid"
- ClonedRecord.FarGuid = XmlAttribute(XmlCloned, XmlTag)
-
- XmlTag = "Cloned/PackageGuid"
- ClonedRecord.PackageGuid = XmlElement(XmlCloned, XmlTag)
-
- XmlTag = "Cloned/PackageVersion"
- ClonedRecord.PackageVersion = XmlElement(XmlCloned, XmlTag)
-
- XmlTag = "Cloned/ModuleGuid"
- ClonedRecord.ModuleGuid = XmlElement(XmlCloned, XmlTag)
-
- XmlTag = "Cloned/ModuleVersion"
- ClonedRecord.ModuleVersion = XmlElement(XmlCloned, XmlTag)
-
- return ClonedRecord
-
-
-## Load a new Guid/Protocol/Ppi common class object.
-#
-# Read an input XML Guid/Protocol/Ppi DOM object and return an object of
-# Guid/Protocol/Ppi contained in the DOM object.
-#
-# @param XmlGuidProtocolPpiCommon A child XML DOM object in a Common XML DOM.
-#
-# @retvel GuidProtocolPpiCommon A new GuidProtocolPpiCommon class object
-# created by XmlGuidProtocolPpiCommon.
-#
-def LoadGuidProtocolPpiCommon(XmlGuidProtocolPpiCommon):
- GuidProtocolPpiCommon = GuidProtocolPpiCommonClass()
-
- XmlTag = "Name"
- GuidProtocolPpiCommon.Name = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
-
- XmlParent = XmlNodeName(XmlGuidProtocolPpiCommon)
- if XmlParent == "Entry":
- XmlTag = "%s/C_Name" % XmlParent
- elif XmlParent == "GuidCNames":
- XmlTag = "%s/GuidCName" % XmlParent
- else:
- XmlTag = "%s/%sCName" % (XmlParent, XmlParent)
-
- GuidProtocolPpiCommon.CName = XmlElement(XmlGuidProtocolPpiCommon, XmlTag)
-
- XmlTag = XmlParent + "/" + "GuidValue"
- GuidProtocolPpiCommon.Guid = XmlElement(XmlGuidProtocolPpiCommon, XmlTag)
-
- if XmlParent.endswith("Notify"):
- GuidProtocolPpiCommon.Notify = True
-
- XmlTag = "GuidTypeList"
- GuidTypes = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
- GuidProtocolPpiCommon.GuidTypeList = GuidTypes.split()
-
- XmlTag = "SupModuleList"
- SupModules = XmlAttribute(XmlGuidProtocolPpiCommon, XmlTag)
- GuidProtocolPpiCommon.SupModuleList = SupModules.split()
-
- SetCommon(GuidProtocolPpiCommon, XmlGuidProtocolPpiCommon)
-
- return GuidProtocolPpiCommon
-
-
-## Load a new Pcd class object.
-#
-# Read an input XML Pcd DOM object and return an object of Pcd
-# contained in the DOM object.
-#
-# @param XmlPcd A child XML DOM object in a Common XML DOM.
-#
-# @retvel Pcd A new Pcd object created by XmlPcd.
-#
-def LoadPcd(XmlPcd):
- """Return a new PcdClass object equivalent to XmlPcd"""
- Pcd = PcdClass()
-
- XmlTag = "PcdEntry/C_Name"
- Pcd.CName = XmlElement(XmlPcd, XmlTag)
-
- XmlTag = "PcdEntry/Token"
- Pcd.Token = XmlElement(XmlPcd, XmlTag)
-
- XmlTag = "PcdEntry/TokenSpaceGuidCName"
- Pcd.TokenSpaceGuidCName = XmlElement(XmlPcd, XmlTag)
-
- XmlTag = "PcdEntry/DatumType"
- Pcd.DatumType = XmlElement(XmlPcd, XmlTag)
-
- XmlTag = "PcdEntry/MaxDatumSize"
- Pcd.MaxDatumSize = XmlElement(XmlPcd, XmlTag)
-
- XmlTag = "PcdEntry/DefaultValue"
- Pcd.DefaultValue = XmlElement(XmlPcd, XmlTag)
-
- XmlTag = "PcdItemType"
- Pcd.ItemType = XmlAttribute(XmlPcd, XmlTag)
-
- XmlTag = "PcdEntry/ValidUsage"
- Pcd.ValidUsage = XmlElement(XmlPcd, XmlTag).split()
-
- XmlTag = "SupModuleList"
- Pcd.SupModuleList = XmlAttribute(XmlPcd, XmlTag).split()
-
- SetCommon(Pcd, XmlPcd)
-
- return Pcd
-
-
-## Load a new LibraryClass class object.
-#
-# Read an input XML LibraryClass DOM object and return an object of LibraryClass
-# contained in the DOM object.
-#
-# @param XmlLibraryClass A child XML DOM object in a Common XML DOM.
-#
-# @retvel LibraryClass A new LibraryClass object created by XmlLibraryClass.
-#
-def LoadLibraryClass(XmlLibraryClass):
- LibraryClass = LibraryClassClass()
-
- XmlTag = "LibraryClass/Keyword"
- LibraryClass.LibraryClass = XmlElement(XmlLibraryClass, XmlTag)
- if LibraryClass.LibraryClass == "":
- XmlTag = "Name"
- LibraryClass.LibraryClass = XmlAttribute(XmlLibraryClass, XmlTag)
-
- XmlTag = "LibraryClass/IncludeHeader"
- LibraryClass.IncludeHeader = XmlElement(XmlLibraryClass, XmlTag)
-
- XmlTag = "RecommendedInstanceVersion"
- RecommendedInstanceVersion = XmlAttribute(XmlLibraryClass, XmlTag)
- LibraryClass.RecommendedInstanceVersion = RecommendedInstanceVersion
-
- XmlTag = "RecommendedInstanceGuid"
- RecommendedInstanceGuid = XmlAttribute(XmlLibraryClass, XmlTag)
- LibraryClass.RecommendedInstanceGuid = RecommendedInstanceGuid
-
- XmlTag = "SupModuleList"
- SupModules = XmlAttribute(XmlLibraryClass, XmlTag)
- LibraryClass.SupModuleList = SupModules.split()
-
- SetCommon(LibraryClass, XmlLibraryClass)
-
- return LibraryClass
-
-
-## Load a new Build Option class object.
-#
-# Read an input XML BuildOption DOM object and return an object of Build Option
-# contained in the DOM object.
-#
-# @param XmlBuildOption A child XML DOM object in a Common XML DOM.
-#
-# @retvel BuildOption A new Build Option object created by XmlBuildOption.
-#
-def LoadBuildOption(XmlBuildOption):
- """Return a new BuildOptionClass object equivalent to XmlBuildOption"""
- BuildOption = BuildOptionClass()
-
- BuildOption.Option = XmlElementData(XmlBuildOption)
-
- XmlTag = "BuildTargets"
- BuildOption.BuildTargetList = XmlAttribute(XmlBuildOption, XmlTag).split()
-
- XmlTag = "ToolChainFamily"
- BuildOption.ToolChainFamily = XmlAttribute(XmlBuildOption, XmlTag)
-
- XmlTag = "TagName"
- BuildOption.TagName = XmlAttribute(XmlBuildOption, XmlTag)
-
- XmlTag = "ToolCode"
- BuildOption.ToolCode = XmlAttribute(XmlBuildOption, XmlTag)
-
- XmlTag = "SupArchList"
- BuildOption.SupArchList = XmlAttribute(XmlBuildOption, XmlTag).split()
-
- return BuildOption
-
-
-## Load a new User Extensions class object.
-#
-# Read an input XML UserExtensions DOM object and return an object of User
-# Extensions contained in the DOM object.
-#
-# @param XmlUserExtensions A child XML DOM object in a Common XML DOM.
-#
-# @retvel UserExtensions A new User Extensions object created by
-# XmlUserExtensions.
-#
-def LoadUserExtensions(XmlUserExtensions):
- UserExtensions = UserExtensionsClass()
-
- XmlTag = "UserId"
- UserExtensions.UserID = XmlAttribute(XmlUserExtensions, XmlTag)
-
- XmlTag = "Identifier"
- UserExtensions.Identifier = XmlAttribute(XmlUserExtensions, XmlTag)
-
- UserExtensions.Content = XmlElementData(XmlUserExtensions)
-
- return UserExtensions
-
-
-## Store content to a text file object.
-#
-# Write some text file content to a text file object. The contents may echo
-# in screen in a verbose way.
-#
-# @param TextFile The text file object.
-# @param Content The string object to be written to a text file.
-#
-def StoreTextFile(TextFile, Content):
- EdkLogger.verbose(Content)
- TextFile.write(Content)
-
-
-## Add item to a section.
-#
-# Add an Item with specific CPU architecture to section dictionary.
-# The possible duplication is ensured to be removed.
-#
-# @param Section Section dictionary indexed by CPU architecture.
-# @param Arch CPU architecture: Ia32, X64, Ipf, Ebc or Common.
-# @param Item The Item to be added to section dictionary.
-#
-def AddToSection(Section, Arch, Item):
- SectionArch = Section.get(Arch, [])
- if Item not in SectionArch:
- SectionArch.append(Item)
- Section[Arch] = SectionArch
-
-
-## Get section contents.
-#
-# Return the content of section named SectionName.
-# the contents is based on Methods and ObjectLists.
-#
-# @param SectionName The name of the section.
-# @param Method A function returning a string item of an object.
-# @param ObjectList The list of object.
-#
-# @retval Section The string content of a section.
-#
-def GetSection(SectionName, Method, ObjectList):
- SupportedArches = ["common", "Ia32", "X64", "Ipf", "Ebc"]
- SectionDict = {}
- for Object in ObjectList:
- Item = Method(Object)
- if Item == "":
- continue
- Item = " %s" % Item
- Arches = Object.SupArchList
- if len(Arches) == 0:
- AddToSection(SectionDict, "common", Item)
- else:
- for Arch in SupportedArches:
- if Arch.upper() in Arches:
- AddToSection(SectionDict, Arch, Item)
-
- Section = ""
- for Arch in SupportedArches:
- SectionArch = "\n".join(SectionDict.get(Arch, []))
- if SectionArch != "":
- Section += "[%s.%s]\n%s\n" % (SectionName, Arch, SectionArch)
- Section += "\n"
- if Section != "":
- Section += "\n"
- return Section
-
-
-## Store file header to a text file.
-#
-# Write standard file header to a text file. The content includes copyright,
-# abstract, description and license extracted from CommonHeader class object.
-#
-# @param TextFile The text file object.
-# @param CommonHeader The source CommonHeader class object.
-#
-def StoreHeader(TextFile, CommonHeader):
- CopyRight = CommonHeader.Copyright
- Abstract = CommonHeader.Abstract
- Description = CommonHeader.Description
- License = CommonHeader.License
-
- Header = "#/** @file\n#\n"
- Header += "# " + Abstract + "\n#\n"
- Header += "# " + Description.strip().replace("\n", "\n# ") + "\n"
- Header += "# " + CopyRight + "\n#\n"
- Header += "# " + License.replace("\n", "\n# ").replace(" ", " ")
- Header += "\n#\n#**/\n\n"
-
- StoreTextFile(TextFile, Header)
-
-## Store file header to a text file.
-#
-# Write Defines section to a text file. DefinesTupleList determines the content.
-#
-# @param TextFile The text file object.
-# @param DefinesTupleList The list of (Tag, Value) to be added as one item.
-#
-def StoreDefinesSection(TextFile, DefinesTupleList):
- Section = "[Defines]\n"
- for DefineItem in DefinesTupleList:
- Section += " %-30s = %s\n" % DefineItem
-
- Section += "\n\n"
- StoreTextFile(TextFile, Section)
-
-
-## Add item to PCD dictionary.
-#
-# Add an PcdClass object to PCD dictionary. The key is generated from
-# PcdItemType.
-#
-# @param PcdDict PCD dictionary indexed by Pcd Item Type.
-# @param Arch CPU architecture: Ia32, X64, Ipf, Ebc or Common.
-# @param Item The Item to be added to section dictionary.
-#
-def AddToPcdsDict(PcdDict, PcdItemType, PcdCode):
- PcdSectionName = PcdItemType
- PcdSectionName = PcdSectionName.title()
- PcdSectionName = PcdSectionName.replace("_", "")
- PcdSectionName = "Pcds" + PcdSectionName
- PcdDict.setdefault(PcdSectionName, []).append(PcdCode)
-
-## Regular expression to match an equation.
-mReEquation = re.compile(r"\s*(\S+)\s*=\s*(\S*)\s*")
-
-## Return a value tuple matching information in a text fle.
-#
-# Parse the text file and return a value tuple corresponding to an input tag
-# tuple. In case of any error, an tuple of empty strings is returned.
-#
-# @param FileName The file name of the text file.
-# @param TagTuple A tuple of tags as the key to the value.
-#
-# @param ValueTupe The returned tuple corresponding to the tag tuple.
-#
-def GetTextFileInfo(FileName, TagTuple):
- ValueTuple = [""] * len(TagTuple)
- try:
- for Line in open(FileName):
- Line = Line.split("#", 1)[0]
- MatchEquation = mReEquation.match(Line)
- if MatchEquation:
- Tag = MatchEquation.group(1).upper()
- Value = MatchEquation.group(2)
- for Index in range(len(TagTuple)):
- if TagTuple[Index] == Tag:
- ValueTuple[Index] = Value
- except:
- EdkLogger.info("IO Error in reading file %s" % FileName)
-
- return ValueTuple
-
-## Return a value tuple matching information in an XML fle.
-#
-# Parse the XML file and return a value tuple corresponding to an input tag
-# tuple. In case of any error, an tuple of empty strings is returned.
-#
-# @param FileName The file name of the XML file.
-# @param TagTuple A tuple of tags as the key to the value.
-#
-# @param ValueTupe The returned tuple corresponding to the tag tuple.
-#
-def GetXmlFileInfo(FileName, TagTuple):
- XmlDom = XmlParseFile(FileName)
- return tuple([XmlElement(XmlDom, XmlTag) for XmlTag in TagTuple])
-
-# Version and Copyright
-__version_number__ = "1.0"
-__version__ = "%prog Version " + __version_number__
-__copyright__ = "Copyright (c) 2007, Intel Corporation. All rights reserved."
-
-## Parse migration command line options
-#
-# Use standard Python module optparse to parse command line option of this tool.
-#
-# @param Source The source file type.
-# @param Destinate The destinate file type.
-#
-# @retval Options A optparse object containing the parsed options.
-# @retval InputFile Path of an source file to be migrated.
-#
-def MigrationOptionParser(Source, Destinate):
- # use clearer usage to override default usage message
- UsageString = "%prog [-a] [-o <output_file>] <input_file>"
-
- Parser = OptionParser(description=__copyright__, version=__version__, usage=UsageString)
-
- HelpText = "The name of the %s file to be created." % Destinate
- Parser.add_option("-o", "--output", dest="OutputFile", help=HelpText)
-
- HelpText = "Automatically create the %s file using the name of the %s file and replacing file extension" % (Source, Destinate)
- Parser.add_option("-a", "--auto", dest="AutoWrite", action="store_true", default=False, help=HelpText)
-
- Options, Args = Parser.parse_args()
-
- # error check
- if len(Args) == 0:
- raise MigrationError(OPTION_MISSING, name="Input file", usage=Parser.get_usage())
- if len(Args) > 1:
- raise MigrationError(OPTION_NOT_SUPPORTED, name="Too many input files", usage=Parser.get_usage())
-
- InputFile = Args[0]
- if not os.path.exists(InputFile):
- raise MigrationError(FILE_NOT_FOUND, name=InputFile)
-
- if Options.OutputFile:
- if Options.AutoWrite:
- raise MigrationError(OPTION_CONFLICT, arg1="-o", arg2="-a", usage=Parser.get_usage())
- else:
- if Options.AutoWrite:
- Options.OutputFile = os.path.splitext(InputFile)[0] + "." + Destinate.lower()
- else:
- raise MigrationError(OPTION_MISSING, name="-o", usage=Parser.get_usage())
-
- return Options, InputFile
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- pass
diff --git a/BaseTools/Source/Python/fpd2dsc/StoreDsc.py b/BaseTools/Source/Python/fpd2dsc/StoreDsc.py
deleted file mode 100644
index f8123a2f97..0000000000
--- a/BaseTools/Source/Python/fpd2dsc/StoreDsc.py
+++ /dev/null
@@ -1,765 +0,0 @@
-## @file
-# Store a Platform class object to an INF file.
-#
-# Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-from LoadFpd import LoadFpd
-from CommonDataClass.PlatformClass import *
-from CommonDataClass.FdfClass import *
-from Common.MigrationUtilities import *
-from Common.ToolDefClassObject import *
-from Common.TargetTxtClassObject import *
-
-## Store Defines section
-#
-# Write [Defines] section to the DscFile based on Platform class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the Defines section
-# @param Platform An input Platform class object
-#
-def StorePlatformDefinesSection(DscFile, Platform):
- PlatformHeader = Platform.Header
-
- DefinesTupleList = []
-
- if PlatformHeader.Name != "":
- DefinesTupleList.append(("PLATFORM_NAME", PlatformHeader.Name))
-
- if PlatformHeader.Guid != "":
- DefinesTupleList.append(("PLATFORM_GUID", PlatformHeader.Guid))
-
- if PlatformHeader.Version != "":
- DefinesTupleList.append(("PLATFORM_VERSION", PlatformHeader.Version))
- for key in PlatformHeader.Specification.keys():
- SpecificationValue = PlatformHeader.Specification.get(key)
- DefinesTupleList.append(("DSC_ SPECIFICATION", SpecificationValue))
-
- if PlatformHeader.OutputDirectory != "":
- DefinesTupleList.append(("OUTPUT_DIRECTORY", PlatformHeader.OutputDirectory))
-
- if PlatformHeader.SupArchList != "":
- String = "|".join(PlatformHeader.SupArchList)
- DefinesTupleList.append(("SUPPORTED_ARCHITECTURES", String))
-
- if PlatformHeader.BuildTargets != "":
- String = "|".join(PlatformHeader.BuildTargets)
- DefinesTupleList.append(("BUILD_TARGETS", String))
-
- if PlatformHeader.SkuIdName != "":
- #DefinesTupleList.append(("SKUID_IDENTIFIER", PlatformHeader.SkuIdName))
- String = "|".join(PlatformHeader.SkuIdName)
- if String != "":
- DefinesTupleList.append(("SKUID_IDENTIFIER", String))
-
- String = Platform.FlashDefinitionFile.FilePath
- if String != "":
- DefinesTupleList.append(("FLASH_DEFINITION", String))
-
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# Defines Section - statements that will be processed to create a Makefile.")
- List.append("#")
- List.append("################################################################################")
- Section = "\n".join(List)
- Section += "\n"
- StoreTextFile(DscFile, Section)
-
- StoreDefinesSection(DscFile, DefinesTupleList)
-
-## Store SkuIds section
-#
-# Write [SkuIds] section to the DscFile based on Platform class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the Library Classes section
-# @param Platform An input Platform class object
-#
-def StorePlatformSkuIdsSection(DscFile, Platform):
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# SKU Identification section - list of all SKU IDs supported by this Platform.")
- List.append("#")
- List.append("################################################################################")
- Section = "\n".join(List)
- Section += "\n"
-
- Section += "[SkuIds]" + '\n'
-
- List = Platform.SkuInfos.SkuInfoList
- for Item in List:
- Section = Section + "%s" % Item[0] + '|' + "%s" % Item[1] + '\n'
- Section = Section + '\n'
-
- StoreTextFile(DscFile, Section)
-
-## Store Build Options section
-#
-# Write [BuildOptions] section to the DscFile based on Platform class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the Build Options section
-# @param Platform An input Platform class object
-#
-def StorePlatformBuildOptionsSection(DscFile, Platform):
- # which is from tools_def.txt
- StandardBuildTargets = ["DEBUG", "RELEASE"]
- SupportedArches = ["COMMON", "IA32", "X64", "IPF", "EBC", "ARM"]
- Target = TargetTxtClassObject()
- WorkSpace = os.getenv('WORKSPACE')
- Target.LoadTargetTxtFile(WorkSpace + '\\Conf\\target.txt')
- ToolDef = ToolDefClassObject()
- ToolDef.LoadToolDefFile(WorkSpace + '\\' + Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF])
- # Now we have got ToolDef object
- #ToolDef.ToolsDefTxtDictionary
- Dict = ToolDef.ToolsDefTxtDatabase
-
- Dict1 = ToolDef.ToolsDefTxtDictionary # we care the info in this Dict
- #
- # We only support *(DEBUG/RELEASE) and *(All Arch: IA32, X64, IPF and EBC) for now
- #
- SectionWINDDK = ''
- SectionVS2003 = ''
- SectionVS2005EXP = ''
- SectionVS2005STD = ''
- SectionVS2005PRO = ''
- SectionVS2005TEAMSUITE = ''
- SectionUNIXGCC = ''
- SectionCYGWINGCC = ''
- SectionELFGCC = ''
- SectionICC = ''
- SectionMYTOOLS = ''
- for key in Dict1.keys():
- if key.find("_CC_FLAGS") != -1:
- if key.find('WINDDK3790x1830') != -1:
- SectionWINDDK = " = " + Dict1.get(key) + "\n"
- elif key.find('VS2003') != -1:
- SectionVS2003 = " = " + Dict1.get(key)+ "\n"
- elif key.find('VS2005EXP') != -1:
- SectionVS2005EXP = " = " + Dict1.get(key) + "\n"
- elif key.find('VS2005STD') != -1:
- SectionVS2005STD = " = " + Dict1.get(key) + "\n"
- elif key.find('VS2005PRO') != -1:
- SectionVS2005PRO = " = " + Dict1.get(key) + "\n"
- elif key.find('VS2005TEAMSUITE') != -1:
- SectionVS2005TEAMSUITE = " = " + Dict1.get(key) + "\n"
- elif key.find('UNIXGCC') != -1:
- SectionUNIXGCC = " = " + Dict1.get(key) + "\n"
- elif key.find('CYGWINGCC') != -1:
- SectionCYGWINGCC = " = " + Dict1.get(key) + "\n"
- elif key.find('ELFGCC') != -1:
- SectionELFGCC = " = " + Dict1.get(key) + "\n"
- elif key.find('ICC') != -1:
- SectionICC = " = " + Dict1.get(key) + "\n"
- elif key.find('MYTOOLS') != -1:
- SectionMYTOOLS = " = " + Dict1.get(key) + "\n"
- else:
- print "Error!"
-
- #
- # First need to check which arch
- #
- Archs = Platform.Header.SupArchList
- BuildTargets = Platform.Header.BuildTargets
- #if BuildTargets == StandardBuildTargets:
- #print "Debug and Release both support" # skip debug/release string search
- #else:
- #print "need to search debug/release string"
-
- if len(Archs) == 4:
- Arch = "*"
- SectionName = "[BuildOptions.Common]\n"
- else:
- for Arch in Archs:
- if Arch == 'IA32':
- SectionName = "[BuildOptions.IA32]\n"
- elif Arch == 'X64':
- SectionName = "[BuildOptions.X64]\n"
- elif Arch == 'IPF':
- SectionName = "[BuildOptions.IPF]\n"
- elif Arch == 'EBC':
- SectionName = "[BuildOptions.EBC]\n"
- else:
- print 'Error!'
- Section = ""
- if SectionWINDDK != "":
- SectionWINDDK = "*_WINDDK3790x1830_" + Arch + "_CC_FLAGS" + SectionWINDDK
- Section += SectionWINDDK
- if SectionVS2003 != "":
- SectionVS2003 = "*_VS2003_" + Arch + "_CC_FLAGS" + SectionVS2003
- Section += SectionVS2003
- if SectionVS2005EXP != "":
- SectionVS2005EXP = "*_VS2005EXP_" + Arch + "_CC_FLAGS" + SectionVS2005EXP
- Section += SectionVS2005EXP
- if SectionVS2005STD != "":
- SectionVS2005STD = "*_VS2005STD_" + Arch + "_CC_FLAGS" + SectionVS2005STD
- Section += SectionVS2005STD
- if SectionVS2005PRO != "":
- SectionVS2005PRO = "*_VS2005PRO_" + Arch + "_CC_FLAGS" + SectionVS2005PRO
- Section += SectionVS2005PRO
- if SectionVS2005TEAMSUITE != "":
- SectionVS2005TEAMSUITE = "*_VS2005TEAMSUITE_" + Arch + "_CC_FLAGS" + SectionVS2005TEAMSUITE
- Section += SectionVS2005TEAMSUITE
- if SectionUNIXGCC != "":
- SectionUNIXGCC = "*_UNIXGCC_" + Arch + "_CC_FLAGS" + SectionUNIXGCC
- Section += SectionUNIXGCC
- if SectionCYGWINGCC != "":
- SectionCYGWINGCC = "*_CYGWINGCC_" + Arch + "_CC_FLAGS" + SectionCYGWINGCC
- Section += SectionCYGWINGCC
- if SectionELFGCC != "":
- SectionELFGCC = "*_ELFGCC_" + Arch + "_CC_FLAGS" + SectionELFGCC
- Section += SectionELFGCC
- if SectionICC != "":
- SectionICC = "*_ICC_" + Arch + "_CC_FLAGS" + SectionICC
- Section += SectionICC
- if SectionMYTOOLS != "":
- SectionMYTOOLS = "*_MYTOOLS_" + Arch + "_CC_FLAGS" + SectionMYTOOLS
- Section += SectionMYTOOLS
-
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# Build Options section - list of all Build Options supported by this Platform.")
- List.append("#")
- List.append("################################################################################")
- SectionHeader = "\n".join(List)
- SectionHeader += "\n"
-
- Section = SectionHeader + SectionName + Section
- Section += "\n"
- StoreTextFile(DscFile, Section)
-
-## Store Libraries section
-#
-# Write [Libraries] section to the DscFile based on Platform class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the Library Classes section
-# @param Platform An input Platform class object
-#
-def StorePlatformLibrariesSection(DscFile,Platform):
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# Libraries section - list of all Libraries needed by this Platform.")
- List.append("#")
- List.append("################################################################################")
- SectionHeader = "\n".join(List)
- SectionHeader += "\n"
-
- Section = SectionHeader + '[Libraries]\n\n'
- StoreTextFile(DscFile, Section)
-
-## Return a Platform Library Class Item
-#
-# Read the input LibraryClass class object and return one line of Library Class Item.
-#
-# @param LibraryClass An input LibraryClass class object
-#
-# @retval LibraryClassItem A Module Library Class Item
-#
-def GetPlatformLibraryClassItem(LibraryClass):
- LibraryClassList = []
- LibraryClassList.append(LibraryClass.Name)
- LibraryClassList.append(LibraryClass.FilePath)
-
- return "|$(WORKSPACE)/".join(LibraryClassList).rstrip("|")
-
-## Add item to a LibraryClass section
-#
-# Add an Item with specific Module Type to section dictionary.
-# The possible duplication is ensured to be removed.
-#
-# @param Section Section dictionary indexed by CPU architecture
-# @param SupModuleList LibraryClass SupModuleList: BASE, SEC, PEI_CORE, PEIM, etc
-# @param Item The Item to be added to section dictionary
-#
-def AddToLibraryClassSection(Section, SupModuleList, Item):
- for ModuleType in SupModuleList:
- SectionModule = Section.get(ModuleType, [])
- if Item not in SectionModule:
- SectionModule.append(Item)
- Section[ModuleType] = SectionModule
-
-## Get Library Classes section contents
-#
-# Return the content of section named SectionName.
-# the contents is based on Methods and ObjectLists.
-#
-# @param SectionName The name of the section
-# @param Method A function returning a string item of an object
-# @param ObjectList The list of object
-#
-# @retval Section The string content of a section
-#
-def GetLibraryClassesSection(SectionName, Method, ObjectList):
- SupportedArches = ["COMMON", "IA32", "X64", "IPF", "EBC"]
- ModuleTypes = ["BASE","SEC","PEI_CORE","PEIM","DXE_CORE","DXE_DRIVER","DXE_SMM_DRIVER","DXE_SAL_DRIVER","DXE_RUNTIME_DRIVER","UEFI_DRIVER","UEFI_APPLICATION"]
- SectionCommonDict = {}
- SectionIA32Dict = {}
- SectionX64Dict = {}
- SectionIPFDict = {}
- SectionEBCDict = {}
- #ObjectList = list(set(ObjectList)) # delete the same element in the list
- for Object in ObjectList:
- if Object == None:
- continue
- Item = Method(Object)
- if Item == "":
- continue
- Item = " %s" % Item
- Arches = Object.SupArchList
- if len(Arches) == 4:
- ModuleType = Object.ModuleType
- # [LibraryClasses.Common.ModuleType]
- if ModuleType == "BASE":
- SupModuleList = ["BASE"]
- AddToLibraryClassSection(SectionCommonDict, SupModuleList, Item)
- else:
- #
- SupModuleList = Object.SupModuleList
- #AddToSection(SectionDict, "|".join(SupModuleList), Item)
- AddToLibraryClassSection(SectionCommonDict, SupModuleList, Item)
- else:
- # Arch
- for Arch in SupportedArches:
- if Arch.upper() in Arches:
- if Arch == "IA32":
- # [LibraryClasses.IA32.ModuleType]
- ModuleType = Object.ModuleType
- if ModuleType == "BASE":
- SupModuleList = ["BASE"]
- AddToLibraryClassSection(SectionIA32Dict, SupModuleList, Item)
- else:
- SupModuleList = Object.SupModuleList
- AddToLibraryClassSection(SectionIA32Dict, SupModuleList, Item)
- elif Arch == "X64":
- # [LibraryClasses.X64.ModuleType]
- ModuleType = Object.ModuleType
- if ModuleType == "BASE":
- SupModuleList = ["BASE"]
- AddToLibraryClassSection(SectionX64Dict, SupModuleList, Item)
- else:
- SupModuleList = Object.SupModuleList
- AddToLibraryClassSection(SectionX64Dict, SupModuleList, Item)
- elif Arch == "IPF":
- # [LibraryClasses.IPF.ModuleType]
- ModuleType = Object.ModuleType
- if ModuleType == "BASE":
- SupModuleList = ["BASE"]
- AddToLibraryClassSection(SectionIPFDict, SupModuleList, Item)
- else:
- SupModuleList = Object.SupModuleList
- AddToLibraryClassSection(SectionIPFDict, SupModuleList, Item)
- elif Arch == "EBC":
- # [LibraryClasses.EBC.ModuleType]
- ModuleType = Object.ModuleType
- if ModuleType == "BASE":
- SupModuleList = ["BASE"]
- AddToLibraryClassSection(SectionEBCDict, SupModuleList, Item)
- else:
- SupModuleList = Object.SupModuleList
- AddToLibraryClassSection(SectionEBCDict, SupModuleList, Item)
-
- Section = ""
- for ModuleType in ModuleTypes:
- SectionCommonModule = "\n".join(SectionCommonDict.get(ModuleType, []))
- if SectionCommonModule != "":
- Section += "[%s.Common.%s]\n%s\n" % (SectionName, ModuleType, SectionCommonModule)
- Section += "\n"
- for ModuleType in ModuleTypes:
- ListIA32 = SectionIA32Dict.get(ModuleType, [])
- if ListIA32 != []:
- SectionIA32Module = "\n".join(SectionIA32Dict.get(ModuleType, []))
- if SectionIA32Module != "":
- Section += "[%s.IA32.%s]\n%s\n" % (SectionName, ModuleType, SectionIA32Module)
- Section += "\n"
- ListX64 = SectionX64Dict.get(ModuleType, [])
- if ListX64 != []:
- SectionX64Module = "\n".join(SectionX64Dict.get(ModuleType, []))
- if SectionX64Module != "":
- Section += "[%s.X64.%s]\n%s\n" % (SectionName, ModuleType, SectionX64Module)
- Section += "\n"
- ListIPF = SectionIPFDict.get(ModuleType, [])
- if ListIPF != []:
- SectionIPFModule = "\n".join(SectionIPFDict.get(ModuleType, []))
- if SectionIPFModule != "":
- Section += "[%s.IPF.%s]\n%s\n" % (SectionName, ModuleType, SectionIPFModule)
- Section += "\n"
- ListEBC = SectionEBCDict.get(ModuleType, [])
- if ListEBC != []:
- SectionEBCModule = "\n".join(SectionEBCDict.get(ModuleType, []))
- if SectionEBCModule != "":
- Section += "[%s.EBC.%s]\n%s\n" % (SectionName, ModuleType, SectionEBCModule)
- Section += "\n"
-
- if Section != "":
- Section += "\n"
- return Section
-
-## Store Library Classes section
-#
-# Write [LibraryClasses] section to the DscFile based on Platform class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the Library Classes section
-# @param Platform An input Platform class object
-#
-def StorePlatformLibraryClassesSection(DscFile, Platform):
- Section = GetLibraryClassesSection("LibraryClasses", GetPlatformLibraryClassItem, Platform.LibraryClasses.LibraryList)
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# Library Class section - list of all Library Classes needed by this Platform.")
- List.append("#")
- List.append("################################################################################")
- SectionHeader = "\n".join(List)
- SectionHeader += "\n"
- Section = SectionHeader + Section
- StoreTextFile(DscFile, Section)
-
-## Store Pcd section
-#
-# Write [Pcd] section to the DscFile based on Platform class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the Build Options section
-# @param Platform An input Platform class object
-#
-def StorePlatformPcdSection(DscFile, Platform):
- # {PcdsFixedAtBuild:String1, PcdsFixedAtBuild:String2, PcdsPatchableInModule:String3}
- SectionDict = {}
- #
- # [PcdsFixedAtBuild], [PcdsPatchableInModule] and [PcdsFeatureFlag] are from platform.modules
- # [PcdsDynamic] is from platform.DynamicPcdBuildDefinitions
- #
- Modules = Platform.Modules.ModuleList # it's a list of modules
- for Module in Modules:
- PcdBuildDefinitions = Module.PcdBuildDefinitions # it's a list of PcdData
- for PcdData in PcdBuildDefinitions:
- if PcdData.ItemType == "FEATURE_FLAG":
- List = []
- List.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)
- List.append(PcdData.Value)
- String = "|".join(List)
- ItemType = PcdData.ItemType
- SectionPcdsFeatureFlag = SectionDict.get(ItemType, [])
- if String not in SectionPcdsFeatureFlag:
- SectionPcdsFeatureFlag.append(String)
- SectionDict[ItemType] = SectionPcdsFeatureFlag
- else:
- List = []
- List.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)
- List.append(PcdData.Value)
- List.append(PcdData.Token)
- List.append(PcdData.DatumType)
- List.append(PcdData.MaxDatumSize)
- String = "|".join(List)
- ItemType = PcdData.ItemType
- if PcdData.ItemType == "FIXED_AT_BUILD":
- SectionPcdsFixedAtBuild = SectionDict.get(ItemType, [])
- if String not in SectionPcdsFixedAtBuild:
- SectionPcdsFixedAtBuild.append(String)
- SectionDict[ItemType] = SectionPcdsFixedAtBuild
- #elif PcdData.ItemType == "FEATURE_FLAG":
- #SectionPcdsFeatureFlag = SectionDict.get(ItemType, [])
- #if String not in SectionPcdsFeatureFlag:
- #SectionPcdsFeatureFlag.append(String)
- #SectionDict[ItemType] = SectionPcdsFeatureFlag
- elif PcdData.ItemType == "PATCHABLE_IN_MODULE":
- SectionPcdsPatchableInModule = SectionDict.get(ItemType, [])
- if String not in SectionPcdsPatchableInModule:
- SectionPcdsPatchableInModule.append(String)
- SectionDict[ItemType] = SectionPcdsPatchableInModule
- elif PcdData.ItemType == "DYNAMIC":
- SectionPcdsDynamic = SectionDict.get(ItemType, [])
- if String not in SectionPcdsDynamic:
- SectionPcdsDynamic.append(String)
- SectionDict[ItemType] = SectionPcdsDynamic
-
- DynamicPcdBuildDefinitions = Platform.DynamicPcdBuildDefinitions # It's a list
- for PcdBuildData in DynamicPcdBuildDefinitions:
- List = []
- List.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)
- List.append(PcdData.Token)
- List.append(PcdData.DatumType)
- List.append(PcdData.MaxDatumSize)
- String = "|".join(List)
- if PcdBuildData.ItemType == "DYNAMIC":
- ItemType = PcdBuildData.ItemType
- SectionPcdsDynamic = SectionDict.get(ItemType, [])
- if String not in SectionPcdsDynamic:
- SectionPcdsDynamic.append(String)
- SectionDict[ItemType] = SectionPcdsDynamic
- ItemType = "FIXED_AT_BUILD"
- Section = "[PcdsFixedAtBuild]\n " + "\n ".join(SectionDict.get(ItemType, []))
- ItemType = "FEATURE_FLAG"
- Section += "\n\n[PcdsFeatureFlag]\n " + "\n ".join(SectionDict.get(ItemType, []))
- ItemType = "PATCHABLE_IN_MODULE"
- Section += "\n\n[PcdsPatchableInModule]\n " + "\n ".join(SectionDict.get(ItemType, []))
- Section += "\n\n"
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform.")
- List.append("#")
- List.append("################################################################################")
- String = "\n".join(List)
- Section += String
- ItemType = "DYNAMIC"
- Section += "\n\n[PcdsDynamic]\n " + "\n ".join(SectionDict.get(ItemType, []))
- Section += "\n\n"
-
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# Pcd Section - list of all EDK II PCD Entries defined by this Platform.")
- List.append("#")
- List.append("################################################################################")
- SectionHeader = "\n".join(List)
- SectionHeader += "\n"
- Section = SectionHeader + Section
- StoreTextFile(DscFile, Section)
-
-## Add item to a section
-#
-# Add an Item with specific CPU architecture to section dictionary.
-# The possible duplication is ensured to be removed.
-#
-# @param Section Section dictionary indexed by CPU architecture
-# @param Arch CPU architecture: Ia32, X64, Ipf, Ebc or Common
-# @param Item The Item to be added to section dictionary
-#
-def AddToSection(Section, Arch, Item):
- SectionArch = Section.get(Arch, [])
- if Item not in SectionArch:
- SectionArch.append(Item)
- Section[Arch] = SectionArch
-
-## Get section contents
-#
-# Return the content of section named SectionName.
-# the contents is based on Methods and ObjectLists.
-#
-# @param SectionName The name of the section
-# @param Method A function returning a string item of an object
-# @param ObjectList The list of object
-#
-# @retval Section The string content of a section
-#
-def GetSection(SectionName, Method, ObjectList):
- SupportedArches = ["COMMON", "IA32", "X64", "IPF", "EBC"]
- SectionDict = {}
- for Object in ObjectList:
- if Object.FilePath == "":
- continue
- Item = Method(Object)
- if Item == "":
- continue
- Item = " %s" % Item
- Arches = Object.SupArchList
- if len(Arches) == 4:
- AddToSection(SectionDict, "common", Item)
- else:
- for Arch in SupportedArches:
- if Arch.upper() in Arches:
- AddToSection(SectionDict, Arch, Item)
-
- Section = ""
- for Arch in SupportedArches:
- SectionArch = "\n".join(SectionDict.get(Arch, []))
- if SectionArch != "":
- Section += "[%s.%s]\n%s\n" % (SectionName, Arch, SectionArch)
- Section += "\n"
- if Section != "":
- Section += "\n"
- return Section
-
-## Return a Platform Component Item
-#
-# Read the input Platform Component object and return one line of Platform Component Item.
-#
-# @param Component An input Platform Component class object
-#
-# @retval ComponentItem A Platform Component Item
-#
-def GetPlatformComponentItem(Component):
- List = []
- Section = {}
-
- List.append("$(WORKSPACE)/" + Component.FilePath)
-
- LibraryClasses = Component.LibraryClasses
- if LibraryClasses != []:
- List = []
- List.append("$(WORKSPACE)/" + Component.FilePath + " {")
- List.append("<LibraryClasses>")
- for LibraryClass in LibraryClasses:
- if LibraryClass == ["", ""]:
- continue
- List.append(" " + LibraryClass[0] + "|$(WORKSPACE)/" + LibraryClass[1])
-
- PcdBuildDefinitions = Component.PcdBuildDefinitions
- for PcdData in PcdBuildDefinitions:
- if PcdData.ItemType == "FEATURE_FLAG":
- List1 = []
- List1.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)
- List1.append(PcdData.Value)
- String = "|".join(List1)
- ItemType = PcdData.ItemType
- SectionPcd = Section.get(ItemType, [])
- if String not in SectionPcd:
- SectionPcd.append(String)
- Section[ItemType] = SectionPcd
- else:
- List1 = []
- List1.append(PcdData.TokenSpaceGuidCName + "." + PcdData.C_NAME)
- List1.append(PcdData.Value)
- List1.append(PcdData.Token)
- List1.append(PcdData.DatumType)
- List1.append(PcdData.MaxDatumSize)
- String = "|".join(List1)
- ItemType = PcdData.ItemType
- if ItemType == "FIXED_AT_BUILD":
- SectionPcd = Section.get(ItemType, [])
- if String not in SectionPcd:
- SectionPcd.append(String)
- Section[ItemType] = SectionPcd
- #elif ItemType == "FEATURE_FLAG":
- #SectionPcd = Section.get(ItemType, [])
- #if String not in SectionPcd:
- #SectionPcd.append(String)
- #Section[ItemType] = SectionPcd
- elif ItemType == "PATCHABLE_IN_MODULE":
- SectionPcd = Section.get(ItemType, [])
- if String not in SectionPcd:
- SectionPcd.append(String)
- Section[ItemType] = SectionPcd
- elif ItemType == "DYNAMIC":
- SectionPcd = Section.get(ItemType, [])
- if String not in SectionPcd:
- SectionPcd.append(String)
- Section[ItemType] = SectionPcd
-
- ItemType = "FIXED_AT_BUILD"
- if Section.get(ItemType, []) != []:
- List.append("<PcdsFixedAtBuild>")
- List.append(" " + "\n ".join(Section.get(ItemType,[])))
- ItemType = "FEATURE_FLAG"
- if Section.get(ItemType, []) != []:
- List.append("<PcdsFeatureFlag>")
- List.append(" " + "\n ".join(Section.get(ItemType,[])))
- ItemType = "PATCHABLE_IN_MODULE"
- if Section.get(ItemType, []) != []:
- List.append("<PcdsPatchableInModule>")
- List.append(" " + "\n ".join(Section.get(ItemType,[])))
- ItemType = "DYNAMIC"
- if Section.get(ItemType, []) != []:
- List.append("<PcdsDynamic>")
- List.append(" " + "\n ".join(Section.get(ItemType,[])))
-
- ListOption = []
- SectionOption = ""
- ListBuildOptions = Component.BuildOptions # a list
- if ListBuildOptions != []:
- SectionOption += "\n <BuildOptions>\n"
- for BuildOptions in ListBuildOptions:
- Options = BuildOptions.Options
- for Option in Options:
- for Item in Option.BuildTargetList:
- ListOption.append(Item)
- List.append(Option.ToolChainFamily)
- for Item in Option.SupArchList:
- ListOption.append(Item)
- ListOption.append(Option.ToolCode)
- ListOption.append("FLAGS")
- #print ListOption
- SectionOption += " " + "_".join(List) + " = " + Option.Option + "\n"
- ListOption = []
- if SectionOption != "":
- List.append(SectionOption)
- if List != ["$(WORKSPACE)/" + Component.FilePath]:
- List.append("}\n")
-
- return "\n ".join(List)
-
-## Store Components section.
-#
-# Write [Components] section to the DscFile based on Platform class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the Components section
-# @param Platform An input Platform class object
-#
-def StorePlatformComponentsSection(DscFile, Platform):
- Section = GetSection("Components", GetPlatformComponentItem, Platform.Modules.ModuleList)
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# Components Section - list of all EDK II Modules needed by this Platform.")
- List.append("#")
- List.append("################################################################################")
- SectionHeader = "\n".join(List)
- SectionHeader += "\n"
- Section = SectionHeader + Section
- StoreTextFile(DscFile, Section)
-
-## Store User Extensions section.
-#
-# Write [UserExtensions] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DscFile The output DSC file to store the User Extensions section
-# @param Platform An input Platform class object
-#
-def StorePlatformUserExtensionsSection(DscFile, Platform):
- Section = "".join(map(GetUserExtensions, Platform.UserExtensions))
- List = []
- List.append("################################################################################")
- List.append("#")
- List.append("# User Extensions Section - list of all User Extensions specified by user.")
- List.append("#")
- List.append("################################################################################")
- SectionHeader = "\n".join(List)
- SectionHeader += "\n"
- Section = SectionHeader + Section
- StoreTextFile(DscFile, Section)
-
-## Store a Platform class object to a new DSC file.
-#
-# Read an input Platform class object and save the contents to a new DSC file.
-#
-# @param DSCFileName The output DSC file
-# @param Platform An input Platform class object
-#
-def StoreDsc(DscFileName, Platform):
- DscFile = open(DscFileName, "w+")
- EdkLogger.info("Save file to %s" % DscFileName)
-
- StoreHeader(DscFile, Platform.Header)
- StorePlatformDefinesSection(DscFile, Platform)
- StorePlatformBuildOptionsSection(DscFile,Platform)
- StorePlatformSkuIdsSection(DscFile,Platform)
- StorePlatformLibrariesSection(DscFile,Platform) # new in dsc, Edk I components, list of INF files
- StorePlatformLibraryClassesSection(DscFile, Platform) # LibraryClasses are from Modules
- StorePlatformPcdSection(DscFile, Platform)
- #StorePlatformPcdDynamicSection(DscFile, Platform)
- StorePlatformComponentsSection(DscFile,Platform)
- StorePlatformUserExtensionsSection(DscFile,Platform)
- DscFile.close()
-
-if __name__ == '__main__':
- pass
diff --git a/BaseTools/Source/Python/fpd2dsc/__init__.py b/BaseTools/Source/Python/fpd2dsc/__init__.py
deleted file mode 100644
index f9d3a2197f..0000000000
--- a/BaseTools/Source/Python/fpd2dsc/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-## @file
-# Python 'fpd2dsc' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
diff --git a/BaseTools/Source/Python/fpd2dsc/fpd2dsc.py b/BaseTools/Source/Python/fpd2dsc/fpd2dsc.py
deleted file mode 100644
index 4a65e615a4..0000000000
--- a/BaseTools/Source/Python/fpd2dsc/fpd2dsc.py
+++ /dev/null
@@ -1,117 +0,0 @@
-## @file
-# Convert an XML-based FPD file to a text-based DSC file.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os, re, sys, xml.dom.minidom #XmlRoutines, EdkIIWorkspace
-from LoadFpd import LoadFpd
-from StoreDsc import StoreDsc
-from optparse import OptionParser
-from Common.BuildVersion import gBUILD_VERSION
-
-# Version and Copyright
-__version_number__ = ("1.0" + " " + gBUILD_VERSION)
-__version__ = "%prog Version " + __version_number__
-__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
-
-## Parse command line options
-#
-# Using standard Python module optparse to parse command line option of this tool.
-#
-# @retval Options A optparse.Values object containing the parsed options
-# @retval Args All the arguments got from the command line
-#
-def MyOptionParser():
- """ Argument Parser """
- usage = "%prog [options] input_filename"
- parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(__version_number__))
- parser.add_option("-o", "--output", dest="outfile", help="Specific Name of the DSC file to create, otherwise it is the FPD filename with the extension repalced.")
- parser.add_option("-a", "--auto", action="store_true", dest="autowrite", default=False, help="Automatically create output files and write the DSC file")
- parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")
- parser.add_option("-v", "--verbose", action="count", dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")
- parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Enable printing of debug messages.")
- parser.add_option("-w", "--workspace", dest="workspace", default=str(os.environ.get('WORKSPACE')), help="Specify workspace directory.")
- (options, args) = parser.parse_args(sys.argv[1:])
-
- return options,args
-
-## Entrance method
-#
-# This method mainly dispatch specific methods per the command line options.
-# If no error found, return zero value so the caller of this tool can know
-# if it's executed successfully or not.
-#
-# @retval 0 Tool was successful
-# @retval 1 Tool failed
-#
-def Main():
- global Options
- global Args
- global WorkSpace
- Options,Args = MyOptionParser()
-
- WorkSpace = ""
- #print Options.workspace
- if (Options.workspace == None):
- print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory."
- sys.exit(1)
- else:
- WorkSpace = Options.workspace
- if (Options.debug):
- print "Using Workspace:", WorkSpace
- try:
- Options.verbose +=1
- except:
- Options.verbose = 1
- pass
-
- InputFile = ""
- if Args == []:
- print "usage:" "%prog [options] input_filename"
- else:
- InputFile = Args[0]
- #print InputFile
- if InputFile != "":
- FileName = InputFile
- if ((Options.verbose > 1) | (Options.autowrite)):
- print "FileName:",InputFile
- else:
- print "ERROR: E0001 - You must specify an input filename"
- sys.exit(1)
-
- if (Options.outfile):
- OutputFile = Options.outfile
- else:
- OutputFile = FileName.replace('.fpd', '.dsc')
-
- if ((Options.verbose > 2) or (Options.debug)):
- print "Output Filename:", OutputFile
-
- try:
- Platform = LoadFpd(FileName)
- StoreDsc(OutputFile, Platform)
- return 0
- except Exception, e:
- print e
- return 1
-
-if __name__ == '__main__':
- sys.exit(Main())
- #pass
- #global Options
- #global Args
- #Options,Args = MyOptionParser()
-
- #Main()
- #sys.exit(0) \ No newline at end of file
diff --git a/BaseTools/Source/Python/msa2inf/ConvertModule.py b/BaseTools/Source/Python/msa2inf/ConvertModule.py
deleted file mode 100644
index 2a118ae51e..0000000000
--- a/BaseTools/Source/Python/msa2inf/ConvertModule.py
+++ /dev/null
@@ -1,112 +0,0 @@
-## @file
-# Convert an MSA Module class object ot an INF Module class object by filling
-# several info required by INF file.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-from LoadMsa import LoadMsa
-from StoreInf import StoreInf
-from Common.MigrationUtilities import *
-from EdkIIWorkspaceGuidsInfo import gEdkIIWorkspaceGuidsInfo
-
-#The default INF version number tool generates.
-gInfVersion = "0x00010005"
-
-## Add required version information.
-#
-# Add the default INF version, EFI specificiation version and EDK release
-# version to Module class object.
-#
-# @param Module An input Module class object.
-#
-def AddModuleMiscVersion(Module):
- Version = gInfVersion
- Module.Header.InfVersion = Version
-
- Version = Module.Header.Specification.get("EFI_SPECIFICATION_VERSION", "")
- Module.Header.UefiSpecificationVersion = Version
-
- Version = Module.Header.Specification.get("EDK_RELEASE_VERSION", "")
- Module.Header.EdkReleaseVersion = Version
-
-
-## Add Module produced library class.
-#
-# Add the produced library class from library class list whose usage type is
-# always produced.
-#
-# @param Module An input Module class object.
-#
-def AddModuleProducedLibraryClass(Module):
- for LibraryClass in Module.LibraryClasses:
- if "ALWAYS_PRODUCED" in LibraryClass.Usage:
- Module.Header.LibraryClass.append(LibraryClass)
-
-
-## Add Module Package Dependency path.
-#
-# Translate Package Dependency Guid to a file path relative to workspace.
-#
-# @param Module An input Module class object.
-#
-def AddModulePackageDependencyPath(Module):
- for PackageDependency in Module.PackageDependencies:
- PackageGuid = PackageDependency.PackageGuid
- PackageVersion = PackageDependency.PackageVersion
-
- GuidToFilePath = gEdkIIWorkspaceGuidsInfo.ResolvePackageFilePath
- PackageFilePath = GuidToFilePath(PackageGuid, PackageVersion)
- PackageDependency.FilePath = PackageFilePath
-
-
-## Add Module Recommended Library Instance path.
-#
-# Translate Module Recommened Library Instance Guid to a file path relative to
-# workspace.
-#
-# @param Module An input Module class object.
-#
-def AddModuleRecommonedLibraryInstancePath(Module):
- for LibraryClass in Module.LibraryClasses:
- if "ALWAYS_PRODUCED" in LibraryClass.Usage:
- continue
-
- if LibraryClass.RecommendedInstanceGuid == "":
- continue
-
- LibraryGuid = LibraryClass.RecommendedInstanceGuid
- LibraryVersion = LibraryClass.RecommendedIntanceVersion
-
- GuidToFilePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath
- LibraryInstance = GuidToFilePath(LibraryGuid, LibraryVersion)
- LibraryClass.RecommendedIntance = LibraryInstance
-
-
-## Convert MSA Module class object to INF Module class object.
-#
-# Convert MSA module class ojbect to INF Module class object by filling in
-# several information required by INF file.
-#
-# @param Module An input Module class object.
-#
-def ConvertMsaModuleToInfModule(Module):
- AddModuleMiscVersion(Module)
- AddModuleProducedLibraryClass(Module)
- AddModulePackageDependencyPath(Module)
- AddModuleRecommonedLibraryInstancePath(Module)
-
-
-if __name__ == '__main__':
- pass
- \ No newline at end of file
diff --git a/BaseTools/Source/Python/msa2inf/EdkIIWorkspaceGuidsInfo.py b/BaseTools/Source/Python/msa2inf/EdkIIWorkspaceGuidsInfo.py
deleted file mode 100644
index 6d6633b893..0000000000
--- a/BaseTools/Source/Python/msa2inf/EdkIIWorkspaceGuidsInfo.py
+++ /dev/null
@@ -1,325 +0,0 @@
-## @file
-# Collects the Guid Information in current workspace.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-import fnmatch
-from Common.EdkIIWorkspace import EdkIIWorkspace
-from Common.MigrationUtilities import *
-
-## A class for EdkII work space to resolve Guids.
-#
-# This class inherits from EdkIIWorkspace and collects the Guids information
-# in current workspace. The Guids information is important to translate the
-# package Guids and recommended library instances Guids to relative file path
-# (to workspace directory) in MSA files.
-#
-class EdkIIWorkspaceGuidsInfo(EdkIIWorkspace):
-
- ## The classconstructor.
- #
- # The constructor initialize workspace directory. It does not collect
- # pakage and module Guids info at initialization; instead, it collects them
- # on the fly.
- #
- # @param self The object pointer.
- #
- def __init__(self):
- # Initialize parent class.
- EdkIIWorkspace.__init__(self)
- # The internal map from Guid to FilePath.
- self.__GuidToFilePath = {}
- # The internal package directory list.
- self.__PackageDirList = []
- # The internal flag to indicate whether package Guids info has been
- # to avoid re-collection collected.
- self.__PackageGuidInitialized = False
- # The internal flag to indicate whether module Guids info has been
- # to avoid re-collection collected.
- self.__ModuleGuidInitialized = False
-
- ## Add Guid, Version and FilePath to Guids database.
- #
- # Add Guid, Version and FilePath to Guids database. It constructs a map
- # table from Guid, Version to FilePath internally. If also detects possible
- # Guid collision. For now, the version information is simply ignored and
- # Guid value itself acts as master key.
- #
- # @param self The object pointer.
- # @param Guid The Guid Value.
- # @param Version The version information
- #
- # @retval True The Guid value is successfully added to map table.
- # @retval False The Guid is an empty string or the map table
- # already contains a same Guid.
- #
- def __AddGuidToFilePath(self, Guid, Version, FilePath):
- if Guid == "":
- EdkLogger.info("Cannot find Guid in file %s" % FilePath)
- return False
- #Add the Guid value to map table to ensure case insensitive comparison.
- OldFilePath = self.__GuidToFilePath.setdefault(Guid.lower(), FilePath)
- if OldFilePath == FilePath:
- EdkLogger.verbose("File %s has new Guid '%s'" % (FilePath, Guid))
- return True
- else:
- EdkLogger.info("File %s has duplicate Guid with & %s" % (FilePath, OldFilePath))
- return False
-
-
- ## Gets file information from a module description file.
- #
- # Extracts Module Name, File Guid and Version number from INF, MSA and NMSA
- # file. It supports to exact such information from text based INF file or
- # XML based (N)MSA file.
- #
- # @param self The object pointer.
- # @param FileName The input module file name.
- #
- # @retval True This module file represents a new module discovered
- # in current workspace.
- # @retval False This module file is not regarded as a valid module.
- # The File Guid cannot be extracted or the another
- # file with the same Guid already exists
- #
- def __GetModuleFileInfo(self, FileName):
- if fnmatch.fnmatch(FileName, "*.inf"):
- TagTuple = ("BASE_NAME", "FILE_GUID", "VERSION_STRING")
- (Name, Guid, Version) = GetTextFileInfo(FileName, TagTuple)
- else :
- XmlTag1 = "ModuleSurfaceArea/MsaHeader/ModuleName"
- XmlTag2 = "ModuleSurfaceArea/MsaHeader/GuidValue"
- XmlTag3 = "ModuleSurfaceArea/MsaHeader/Version"
- TagTuple = (XmlTag1, XmlTag2, XmlTag3)
- (Name, Guid, Version) = GetXmlFileInfo(FileName, TagTuple)
-
- return self.__AddGuidToFilePath(Guid, Version, FileName)
-
-
- ## Gets file information from a package description file.
- #
- # Extracts Package Name, File Guid and Version number from INF, SPD and NSPD
- # file. It supports to exact such information from text based DEC file or
- # XML based (N)SPD file. EDK Compatibility Package is hardcoded to be
- # ignored since no EDKII INF file depends on that package.
- #
- # @param self The object pointer.
- # @param FileName The input package file name.
- #
- # @retval True This package file represents a new package
- # discovered in current workspace.
- # @retval False This package is not regarded as a valid package.
- # The File Guid cannot be extracted or the another
- # file with the same Guid already exists
- #
- def __GetPackageFileInfo(self, FileName):
- if fnmatch.fnmatch(FileName, "*.dec"):
- TagTuple = ("PACKAGE_NAME", "PACKAGE_GUID", "PACKAGE_VERSION")
- (Name, Guid, Version) = GetTextFileInfo(FileName, TagTuple)
- else:
- XmlTag1 = "PackageSurfaceArea/SpdHeader/PackageName"
- XmlTag2 = "PackageSurfaceArea/SpdHeader/GuidValue"
- XmlTag3 = "PackageSurfaceArea/SpdHeader/Version"
- TagTuple = (XmlTag1, XmlTag2, XmlTag3)
- (Name, Guid, Version) = GetXmlFileInfo(FileName, TagTuple)
-
- if Name == "EdkCompatibilityPkg":
- # Do not scan EDK compatibitilty package to avoid Guid collision
- # with those in EDK Glue Library.
- EdkLogger.verbose("Bypass EDK Compatibility Pkg")
- return False
-
- return self.__AddGuidToFilePath(Guid, Version, FileName)
-
- ## Iterate on all package files listed in framework database file.
- #
- # Yields all package description files listed in framework database files.
- # The framework database file describes the packages current workspace
- # includes.
- #
- # @param self The object pointer.
- #
- def __FrameworkDatabasePackageFiles(self):
- XmlFrameworkDb = XmlParseFile(self.WorkspaceFile)
- XmlTag = "FrameworkDatabase/PackageList/Filename"
- for PackageFile in XmlElementList(XmlFrameworkDb, XmlTag):
- yield os.path.join(self.WorkspaceDir, PackageFile)
-
-
- ## Iterate on all package files in current workspace directory.
- #
- # Yields all package description files listed in current workspace
- # directory. This happens when no framework database file exists.
- #
- # @param self The object pointer.
- #
- def __TraverseAllPackageFiles(self):
- for Path, Dirs, Files in os.walk(self.WorkspaceDir):
- # Ignore svn version control directory.
- if ".svn" in Dirs:
- Dirs.remove(".svn")
- if "Build" in Dirs:
- Dirs.remove("Build")
- # Assume priority from high to low: DEC, NSPD, SPD.
- PackageFiles = fnmatch.filter(Files, "*.dec")
- if len(PackageFiles) == 0:
- PackageFiles = fnmatch.filter(Files, "*.nspd")
- if len(PackageFiles) == 0:
- PackageFiles = fnmatch.filter(Files, "*.spd")
-
- for File in PackageFiles:
- # Assume no more package decription file in sub-directory.
- del Dirs[:]
- yield os.path.join(Path, File)
-
- ## Iterate on all module files in current package directory.
- #
- # Yields all module description files listed in current package
- # directory.
- #
- # @param self The object pointer.
- #
- def __TraverseAllModuleFiles(self):
- for PackageDir in self.__PackageDirList:
- for Path, Dirs, Files in os.walk(PackageDir):
- # Ignore svn version control directory.
- if ".svn" in Dirs:
- Dirs.remove(".svn")
- # Assume priority from high to low: INF, NMSA, MSA.
- ModuleFiles = fnmatch.filter(Files, "*.inf")
- if len(ModuleFiles) == 0:
- ModuleFiles = fnmatch.filter(Files, "*.nmsa")
- if len(ModuleFiles) == 0:
- ModuleFiles = fnmatch.filter(Files, "*.msa")
-
- for File in ModuleFiles:
- yield os.path.join(Path, File)
-
- ## Initialize package Guids info mapping table.
- #
- # Collects all package guids map to package decription file path. This
- # function is invokes on demand to avoid unnecessary directory scan.
- #
- # @param self The object pointer.
- #
- def __InitializePackageGuidInfo(self):
- if self.__PackageGuidInitialized:
- return
-
- EdkLogger.verbose("Start to collect Package Guids Info.")
-
- WorkspaceFile = os.path.join("Conf", "FrameworkDatabase.db")
- self.WorkspaceFile = os.path.join(self.WorkspaceDir, WorkspaceFile)
-
- # Try to find the frameworkdatabase file to discover package lists
- if os.path.exists(self.WorkspaceFile):
- TraversePackage = self.__FrameworkDatabasePackageFiles
- EdkLogger.verbose("Package list bases on: %s" % self.WorkspaceFile)
- else:
- TraversePackage = self.__TraverseAllPackageFiles
- EdkLogger.verbose("Package list in: %s" % self.WorkspaceDir)
-
- for FileName in TraversePackage():
- if self.__GetPackageFileInfo(FileName):
- PackageDir = os.path.dirname(FileName)
- EdkLogger.verbose("Find new package directory %s" % PackageDir)
- self.__PackageDirList.append(PackageDir)
-
- self.__PackageGuidInitialized = True
-
- ## Initialize module Guids info mapping table.
- #
- # Collects all module guids map to module decription file path. This
- # function is invokes on demand to avoid unnecessary directory scan.
- #
- # @param self The object pointer.
- #
- def __InitializeModuleGuidInfo(self):
- if self.__ModuleGuidInitialized:
- return
- EdkLogger.verbose("Start to collect Module Guids Info")
-
- self.__InitializePackageGuidInfo()
- for FileName in self.__TraverseAllModuleFiles():
- if self.__GetModuleFileInfo(FileName):
- EdkLogger.verbose("Find new module %s" % FileName)
-
- self.__ModuleGuidInitialized = True
-
- ## Get Package file path by Package guid and Version.
- #
- # Translates the Package Guid and Version to a file path relative
- # to workspace directory. If no package in current workspace match the
- # input Guid, an empty file path is returned. For now, the version
- # value is simply ignored.
- #
- # @param self The object pointer.
- # @param Guid The Package Guid value to look for.
- # @param Version The Package Version value to look for.
- #
- def ResolvePackageFilePath(self, Guid, Version = ""):
- self.__InitializePackageGuidInfo()
-
- EdkLogger.verbose("Resolve Package Guid '%s'" % Guid)
- FileName = self.__GuidToFilePath.get(Guid.lower(), "")
- if FileName == "":
- EdkLogger.info("Cannot resolve Package Guid '%s'" % Guid)
- else:
- FileName = self.WorkspaceRelativePath(FileName)
- FileName = os.path.splitext(FileName)[0] + ".dec"
- FileName = FileName.replace("\\", "/")
- return FileName
-
- ## Get Module file path by Package guid and Version.
- #
- # Translates the Module Guid and Version to a file path relative
- # to workspace directory. If no module in current workspace match the
- # input Guid, an empty file path is returned. For now, the version
- # value is simply ignored.
- #
- # @param self The object pointer.
- # @param Guid The Module Guid value to look for.
- # @param Version The Module Version value to look for.
- #
- def ResolveModuleFilePath(self, Guid, Version = ""):
- self.__InitializeModuleGuidInfo()
-
- EdkLogger.verbose("Resolve Module Guid '%s'" % Guid)
- FileName = self.__GuidToFilePath.get(Guid.lower(), "")
- if FileName == "":
- EdkLogger.info("Cannot resolve Module Guid '%s'" % Guid)
- else:
- FileName = self.WorkspaceRelativePath(FileName)
- FileName = os.path.splitext(FileName)[0] + ".inf"
- FileName = FileName.replace("\\", "/")
- return FileName
-
-# A global class object of EdkIIWorkspaceGuidsInfo for external reference.
-gEdkIIWorkspaceGuidsInfo = EdkIIWorkspaceGuidsInfo()
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- # Test the translation of package Guid.
- MdePkgGuid = "1E73767F-8F52-4603-AEB4-F29B510B6766"
- OldMdePkgGuid = "5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
- print gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(MdePkgGuid)
- print gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(OldMdePkgGuid)
-
- # Test the translation of module Guid.
- UefiLibGuid = "3a004ba5-efe0-4a61-9f1a-267a46ae5ba9"
- UefiDriverModelLibGuid = "52af22ae-9901-4484-8cdc-622dd5838b09"
- print gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(UefiLibGuid)
- print gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(UefiDriverModelLibGuid)
diff --git a/BaseTools/Source/Python/msa2inf/LoadMsa.py b/BaseTools/Source/Python/msa2inf/LoadMsa.py
deleted file mode 100644
index 52f4b2d12f..0000000000
--- a/BaseTools/Source/Python/msa2inf/LoadMsa.py
+++ /dev/null
@@ -1,747 +0,0 @@
-## @file
-# Open an MSA file and load all its contents to a ModuleClass object.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-from CommonDataClass.ModuleClass import *
-from Common.XmlRoutines import *
-from Common.MigrationUtilities import *
-
-
-## Load a list of Module Cloned Records.
-#
-# Read an input Module XML DOM object and return a list of Cloned Records
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel ClonedRecords A list of Cloned Records loaded from XmlMsa.
-#
-def LoadModuleClonedRecords(XmlMsa):
- XmlTag = "ModuleSurfaceArea/ModuleDefinitions/ClonedFrom/Cloned"
- return map(LoadClonedRecord, XmlList(XmlMsa, XmlTag))
-
-## Load Module Header.
-#
-# Read an input Module XML DOM object and return Module Header class object
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-# @param MsaFileName The file path of MSA File.
-#
-# @retvel ModuleHeader A new Module Header object loaded from XmlMsa.
-#
-def LoadModuleHeader(XmlMsa, MsaFileName):
- ModuleHeader = ModuleHeaderClass()
-
- XmlTag = "ModuleSurfaceArea/MsaHeader"
- MsaHeader = XmlNode(XmlMsa, XmlTag)
-
- SetIdentification(ModuleHeader, MsaHeader, "ModuleName", MsaFileName)
- SetCommonHeader(ModuleHeader, MsaHeader)
-
- XmlTag = "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"
- ModuleHeader.SupArchList = XmlElement(XmlMsa, XmlTag).split()
-
- XmlTag = "ModuleSurfaceArea/ModuleDefinitions/BinaryModule"
- if XmlElement(XmlMsa, XmlTag).lower() == "true":
- ModuleHeader.BinaryModule = True
-
- XmlTag = "ModuleSurfaceArea/ModuleDefinitions/OutputFileBasename"
- ModuleHeader.OutputFileBasename = XmlElement(XmlMsa, XmlTag)
-
- XmlTag = "ModuleSurfaceArea/ModuleDefinitions/ClonedForm"
- ModuleHeader.ClonedFrom = LoadModuleClonedRecords(XmlMsa)
-
- XmlTag = "ModuleSurfaceArea/Externs/PcdDriverTypes"
- ModuleHeader.PcdIsDriver = XmlElement(XmlMsa, XmlTag)
-
- XmlTag = "ModuleSurfaceArea/Externs/TianoEdkFlashMap_h"
- if XmlElement(XmlMsa, XmlTag).lower() == "true":
- ModuleHeader.TianoEdkFlashMap_h = True
-
- XmlTag = "ModuleSurfaceArea/Externs/Specification"
- for Specification in XmlElementList(XmlMsa, XmlTag):
- AddToSpecificationDict(ModuleHeader.Specification, Specification)
-
- return ModuleHeader
-
-
-## Load a list of Module Library Classes.
-#
-# Read an input Module XML DOM object and return a list of Library Classes
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel LibraryClasses A list of Library Classes loaded from XmlMsa.
-#
-def LoadModuleLibraryClasses(XmlMsa):
- XmlTag = "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
- return map(LoadLibraryClass, XmlList(XmlMsa, XmlTag))
-
-
-## Load a new Module Source class object.
-#
-# Read an input XML Source DOM object and return an object of Source
-# contained in the DOM object.
-#
-# @param XmlFilename A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleSource A new Source object created by XmlFilename.
-#
-def LoadModuleSource(XmlFilename):
- ModuleSource = ModuleSourceFileClass()
-
- ModuleSource.SourceFile = XmlElementData(XmlFilename)
-
- XmlTag = "TagName"
- ModuleSource.TagName = XmlAttribute(XmlFilename, XmlTag)
-
- XmlTag = "ToolCode"
- ModuleSource.ToolCode = XmlAttribute(XmlFilename, XmlTag)
-
- XmlTag = "ToolChainFamily"
- ModuleSource.ToolChainFamily = XmlAttribute(XmlFilename, XmlTag)
-
- SetCommon(ModuleSource, XmlFilename)
-
- return ModuleSource
-
-
-## Load a list of Module Sources.
-#
-# Read an input Module XML DOM object and return a list of Sources
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Sources A list of Sources loaded from XmlMsa.
-#
-def LoadModuleSources(XmlMsa):
- XmlTag = "ModuleSurfaceArea/SourceFiles/Filename"
- return map(LoadModuleSource, XmlList(XmlMsa, XmlTag))
-
-
-## Load a new Module Binary class object.
-#
-# Read an input XML Binary DOM object and return an object of Binary
-# contained in the DOM object.
-#
-# @param XmlFilename A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleBinary A new Binary object created by XmlFilename.
-#
-def LoadModuleBinary(XmlFilename):
- ModuleBinary = ModuleBinaryFileClass()
-
- ModuleBinary.BinaryFile = XmlElementData(XmlFilename)
-
- XmlTag = "FileType"
- ModuleBinary.FileType = XmlElementAttribute(XmlFilename, XmlTag)
-
- SetCommon(ModuleBinary, XmlFilename)
-
-
-## Load a list of Module Binaries.
-#
-# Read an input Module XML DOM object and return a list of Binaries
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Binaries A list of Binaries loaded from XmlMsa.
-#
-def LoadModuleBinaries(XmlMsa):
- XmlTag = "ModuleSurfaceArea/BinaryFiles/Filename"
- return map(LoadModuleBinary, XmlList(XmlMsa, XmlTag))
-
-
-## Load a list of Module Non Processed Files.
-#
-# Read an input Module XML DOM object and return a list of Non Processed Files
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel NonProcessedFiles A list of Non Processed Files loaded from XmlMsa.
-#
-def LoadModuleNonProcessedFiles(XmlMsa):
- XmlTag = "ModuleSurfaceArea/NonProcessedFiles/Filename"
- return XmlElementList(XmlMsa, XmlTag)
-
-
-## Load a new Module Package Dependency class object.
-#
-# Read an input XML PackageDependency DOM object and return an object of Package Dependency
-# contained in the DOM object.
-#
-# @param XmlPackage A child XML DOM object in Module XML DOM.
-#
-# @retvel ModulePackageDependency A new Package Dependency object created by XmlPackage.
-#
-def LoadModulePackageDependency(XmlPackage):
- ModulePackageDependency = ModulePackageDependencyClass()
-
- XmlTag = "PackageGuid"
- PackageKey = XmlAttribute(XmlPackage, XmlTag)
-
- #
- #TODO: Add resolution for Package name, package Version
- #
- ModulePackageDependency.PackageGuid = PackageKey
- SetCommon(ModulePackageDependency, XmlPackage)
-
- return ModulePackageDependency
-
-
-## Load a list of Module Package Dependencies.
-#
-# Read an input Module XML DOM object and return a list of Package Dependencies
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel PackageDependencies A list of Package Dependencies loaded from XmlMsa.
-#
-def LoadModulePackageDependencies(XmlMsa):
- XmlTag = "ModuleSurfaceArea/PackageDependencies/Package"
- return map(LoadModulePackageDependency, XmlList(XmlMsa, XmlTag))
-
-
-## Load a list of Module Protocols.
-#
-# Read an input Module XML DOM object and return a list of Protocols
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Protocols A list of Protocols loaded from XmlMsa.
-#
-def LoadModuleProtocols(XmlMsa):
- XmlTag = "ModuleSurfaceArea/Protocols/Protocol"
- XmlProtocolList = XmlList(XmlMsa, XmlTag)
-
- XmlTag = "ModuleSurfaceArea/Protocols/ProtocolNotify"
- XmlProtocolList += XmlList(XmlMsa, XmlTag)
-
- return map(LoadGuidProtocolPpiCommon, XmlProtocolList)
-
-
-## Load a list of Module Ppis.
-#
-# Read an input Module XML DOM object and return a list of Ppis
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Ppis A list of Ppis loaded from XmlMsa.
-#
-def LoadModulePpis(XmlMsa):
- XmlTag = "ModuleSurfaceArea/PPIs/Ppi"
- XmlPpiList = XmlList(XmlMsa, XmlTag)
-
- XmlTag = "ModuleSurfaceArea/PPIs/PpiNotify"
- XmlPpiList += XmlList(XmlMsa, XmlTag)
-
- return map(LoadGuidProtocolPpiCommon, XmlPpiList)
-
-
-## Load a new Module Event class object.
-#
-# Read an input XML Event DOM object and return an object of Event
-# contained in the DOM object.
-#
-# @param XmlEvent A child XML DOM object in Module XML DOM.
-# @param Type Specify the event type: SIGNAL_EVENT or CREATE_EVENT.
-#
-# @retvel ModuleEvent A new Event object created by XmlEvent.
-#
-def LoadModuleEvent(XmlEvent, Type):
- ModuleEvent = ModuleEventClass()
-
- XmlTag = "EventTypes/EventType"
- ModuleEvent.CName = XmlElement(XmlEvent, XmlTag)
-
- XmlTag = "EventGuidCName"
- ModuleEvent.GuidCName = XmlAttribute(XmlEvent, XmlTag)
-
- ModuleEvent.Type = Type
-
- SetCommon(ModuleEvent, XmlEvent)
-
- return ModuleEvent
-
-
-## Load a list of Module Events.
-#
-# Read an input Module XML DOM object and return a list of Events
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Events A list of Events loaded from XmlMsa.
-#
-def LoadModuleEvents(XmlMsa):
- ModuleEvents = []
-
- XmlTag = "ModuleSurfaceArea/Events/CreateEvents/EventTypes"
- for XmlCreateEvent in XmlList(XmlMsa, XmlTag):
- ModuleEvent = LoadModuleEvent(XmlCreateEvent, "CREATE_EVENT")
- ModuleEvents.append(ModuleEvent)
-
- XmlTag = "ModuleSurfaceArea/Events/SignalEvents/EventTypes"
- for XmlCreateEvent in XmlList(XmlMsa, XmlTag):
- ModuleEvent = LoadModuleEvent(XmlCreateEvent, "SIGNAL_EVENT")
- ModuleEvents.append(ModuleEvent)
-
- return ModuleEvents
-
-
-## Load a new Module Hob class object.
-#
-# Read an input XML Hob DOM object and return an object of Hob
-# contained in the DOM object.
-#
-# @param XmlHob A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleHob A new Hob object created by XmlHob.
-#
-def LoadModuleHob(XmlHob):
- ModuleHob = ModuleHobClass()
-
- XmlTag = "HobTypes/HobType"
- ModuleHob.Type = XmlElement(XmlHob, XmlTag)
-
- XmlTag = "HobGuidCName"
- ModuleHob.GuidCName = XmlAttribute(XmlHob, XmlTag)
-
- SetCommon(ModuleHob, XmlHob)
-
- return ModuleHob
-
-
-## Load a list of Module Hobs.
-#
-# Read an input Module XML DOM object and return a list of Hobs
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Hobs A list of Hobs loaded from XmlMsa.
-#
-def LoadModuleHobs(XmlMsa):
- XmlTag = "ModuleSurfaceArea/Hobs/HobTypes"
- return map(LoadModuleHob, XmlList(XmlMsa, XmlTag))
-
-
-## Load a new Module Variable class object.
-#
-# Read an input XML Variable DOM object and return an object of Variable
-# contained in the DOM object.
-#
-# @param XmlVariable A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleVariable A new Variable object created by XmlVariable.
-#
-def LoadModuleVariable(XmlVariable):
- ModuleVariable = ModuleVariableClass()
-
- XmlTag = "Variable/VariableName"
- HexWordArray = XmlElement(XmlVariable, XmlTag).split()
- try:
- ModuleVariable.Name = "".join([unichr(int(a, 16)) for a in HexWordArray])
- except:
- ModuleVariable.Name = ""
-
- XmlTag = "Variable/GuidC_Name"
- ModuleVariable.GuidCName = XmlElement(XmlVariable, XmlTag)
-
- SetCommon(ModuleVariable, XmlVariable)
-
- return ModuleVariable
-
-
-## Load a list of Module Variables.
-#
-# Read an input Module XML DOM object and return a list of Variables
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Variables A list of Variables loaded from XmlMsa.
-#
-def LoadModuleVariables(XmlMsa):
- XmlTag = "ModuleSurfaceArea/Variables/Variable"
- return map(LoadModuleVariable, XmlList(XmlMsa, XmlTag))
-
-
-## Load a new Module Boot Mode class object.
-#
-# Read an input XML BootMode DOM object and return an object of Boot Mode
-# contained in the DOM object.
-#
-# @param XmlBootMode A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleBootMode A new Boot Mode object created by XmlBootMode.
-#
-def LoadModuleBootMode(XmlBootMode):
- ModuleBootMode = ModuleBootModeClass()
-
- XmlTag = "BootModeName"
- ModuleBootMode.Name = XmlAttribute(XmlBootMode, XmlTag)
-
- SetCommon(ModuleBootMode, XmlBootMode)
-
- return ModuleBootMode
-
-
-## Load a list of Module Boot Modes.
-#
-# Read an input Module XML DOM object and return a list of Boot Modes
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel BootModes A list of Boot Modes loaded from XmlMsa.
-#
-def LoadModuleBootModes(XmlMsa):
- XmlTag = "ModuleSurfaceArea/BootModes/BootMode"
- return map(LoadModuleBootMode, XmlList(XmlMsa, XmlTag))
-
-
-## Load a new Module System Table class object.
-#
-# Read an input XML SystemTable DOM object and return an object of System Table
-# contained in the DOM object.
-#
-# @param XmlSystemTable A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleSystemTable A new System Table object created by XmlSystemTable.
-#
-def LoadModuleSystemTable(XmlSystemTable):
- ModuleSystemTable = ModuleSystemTableClass()
-
- XmlTag = "SystemTable/SystemTableCName"
- ModuleSystemTable.CName = XmlElement(XmlSystemTable, XmlTag)
-
- SetCommon(ModuleSystemTable, XmlSystemTable)
-
- return ModuleSystemTable
-
-
-## Load a list of Module System Tables.
-#
-# Read an input Module XML DOM object and return a list of System Tables
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel SystemTables A list of System Tables loaded from XmlMsa.
-#
-def LoadModuleSystemTables(XmlMsa):
- XmlTag = "ModuleSurfaceArea/SystemTables/SystemTableCNames"
- return map(LoadModuleSystemTable, XmlList(XmlMsa, XmlTag))
-
-
-## Load a new Module Data Hub class object.
-#
-# Read an input XML DataHub DOM object and return an object of Data Hub
-# contained in the DOM object.
-#
-# @param XmlDataHub A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleDataHub A new Data Hub object created by XmlDataHub.
-#
-def LoadModuleDataHub(XmlDataHub):
- ModuleDataHub = ModuleDataHubClass()
-
- XmlTag = "DataHub/DataHubCName"
- ModuleDataHub.CName = XmlElement(XmlDataHub, "DataHubCName")
-
- SetCommon(ModuleDataHub, XmlDataHub)
-
- return ModuleDataHub
-
-
-## Load a list of Module Data Hubs.
-#
-# Read an input Module XML DOM object and return a list of Data Hubs
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel DataHubs A list of Data Hubs loaded from XmlMsa.
-#
-def LoadModuleDataHubs(XmlMsa):
- XmlTag = "ModuleSurfaceArea/DataHubs/DataHubRecord"
- return map(LoadModuleDataHub, XmlList(XmlMsa, XmlTag))
-
-
-## Load a new Module Hii Package class object.
-#
-# Read an input XML HiiPackage DOM object and return an object of Hii Package
-# contained in the DOM object.
-#
-# @param XmlHiiPackage A child XML DOM object in Module XML DOM.
-#
-# @retvel ModuleHiiPackage A new Hii Package object created by XmlHiiPackage.
-#
-def LoadModuleHiiPackage(XmlHiiPackage):
- ModuleHiiPackage = ModuleHiiPackageClass()
-
- XmlTag = "HiiPackage/HiiPackageCName"
- ModuleHiiPackage.CName = XmlElement(XmlHiiPackage, "HiiCName")
-
- SetCommon(ModuleHiiPackage, XmlHiiPackage)
-
- return ModuleHiiPackage
-
-
-## Load a list of Module Hii Packages.
-#
-# Read an input Module XML DOM object and return a list of Hii Packages
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel HiiPackages A list of Hii Packages loaded from XmlMsa.
-#
-def LoadModuleHiiPackages(XmlMsa):
- XmlTag = "ModuleSurfaceArea/HiiPackages/HiiPackage"
- return map(LoadModuleHiiPackage, XmlList(XmlMsa, XmlTag))
-
-
-## Load a list of Module Guids.
-#
-# Read an input Module XML DOM object and return a list of Guids
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel Guids A list of Guids loaded from XmlMsa.
-#
-def LoadModuleGuids(XmlMsa):
- XmlTag = "ModuleSurfaceArea/Guids/GuidCNames"
- return map(LoadGuidProtocolPpiCommon, XmlList(XmlMsa, XmlTag))
-
-
-## Load a list of Module Pcd Codes.
-#
-# Read an input Module XML DOM object and return a list of Pcd Codes
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel PcdCodes A list of Pcd Codes loaded from XmlMsa.
-#
-def LoadModulePcdCodes(XmlMsa):
- XmlTag = "ModuleSurfaceArea/PcdCoded/PcdEntry"
- return map(LoadPcd, XmlList(XmlMsa, XmlTag))
-
-
-## Load a list of Module Extern Images.
-#
-# Read an input Module XML DOM object and return a list of Extern Images
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel ExternImages A list of Extern Images loaded from XmlMsa.
-#
-def LoadModuleExternImages(XmlMsa):
- ModuleExternImages = []
-
- XmlTag = "ModuleSurfaceArea/Externs/Extern"
- for XmlExtern in XmlList(XmlMsa, XmlTag):
- XmlTag = "Extern/ModuleEntryPoint"
- ModuleEntryPoint = XmlElement(XmlExtern, XmlTag)
- XmlTag = "Extern/ModuleUnloadImage"
- ModuleUnloadImage = XmlElement(XmlExtern, XmlTag)
- if ModuleEntryPoint == "" and ModuleUnloadImage == "":
- continue
-
- ModuleExtern = ModuleExternImageClass()
- ModuleExtern.ModuleEntryPoint = ModuleEntryPoint
- ModuleExtern.ModuleUnloadImage = ModuleUnloadImage
- ModuleExternImages.append(ModuleExtern)
-
- return ModuleExternImages
-
-
-## Load a list of Module Extern Libraries.
-#
-# Read an input Module XML DOM object and return a list of Extern Libraries
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel ExternLibraries A list of Extern Libraries loaded from XmlMsa.
-#
-def LoadModuleExternLibraries(XmlMsa):
- ModuleExternLibraries = []
-
- XmlTag = "ModuleSurfaceArea/Externs/Extern"
- for XmlExtern in XmlList(XmlMsa, XmlTag):
- XmlTag = "Extern/Constructor"
- Constructor = XmlElement(XmlExtern, XmlTag)
- XmlTag = "Extern/Destructor"
- Destructor = XmlElement(XmlExtern, XmlTag)
- if Constructor == "" and Destructor == "":
- continue
-
- ModuleExtern = ModuleExternLibraryClass()
- ModuleExtern.Constructor = Constructor
- ModuleExtern.Destructor = Destructor
- ModuleExternLibraries.append(ModuleExtern)
-
- return ModuleExternLibraries
-
-
-## Load a list of Module Extern Drivers.
-#
-# Read an input Module XML DOM object and return a list of Extern Drivers
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel ExternDrivers A list of Extern Drivers loaded from XmlMsa.
-#
-def LoadModuleExternDrivers(XmlMsa):
- ModuleExternDrivers = []
-
- XmlTag = "ModuleSurfaceArea/Externs/Extern"
- for XmlExtern in XmlList(XmlMsa, XmlTag):
- XmlTag = "Extern/DriverBinding"
- DriverBinding = XmlElement(XmlExtern, XmlTag)
- XmlTag = "Extern/ComponentName"
- ComponentName = XmlElement(XmlExtern, XmlTag)
- XmlTag = "Extern/DriverConfig"
- DriverConfig = XmlElement(XmlExtern, XmlTag)
- XmlTag = "Extern/DriverDiag"
- DriverDiag = XmlElement(XmlExtern, XmlTag)
- if DriverBinding == "":
- continue
-
- ModuleExtern = ModuleExternDriverClass()
- ModuleExtern.DriverBinding = DriverBinding
- ModuleExtern.ComponentName = ComponentName
- ModuleExtern.DriverConfig = DriverConfig
- ModuleExtern.DriverDiag = DriverDiag
- ModuleExternDrivers.append(ModuleExtern)
-
- return ModuleExternDrivers
-
-
-## Load a list of Module Extern Call Backs.
-#
-# Read an input Module XML DOM object and return a list of Extern Call Backs
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel ExternCallBacks A list of Extern Call Backs loaded from XmlMsa.
-#
-def LoadModuleExternCallBacks(XmlMsa):
- ModuleExternCallBacks = []
-
- XmlTag = "ModuleSurfaceArea/Externs/Extern"
- for XmlExtern in XmlList(XmlMsa, XmlTag):
- XmlTag = "Extern/SetVirtualAddressMapCallBack"
- SetVirtualAddressMap = XmlElement(XmlExtern, XmlTag)
- XmlTag = "Extern/ExitBootServicesCallBack"
- ExitBootServices = XmlElement(XmlExtern, XmlTag)
- if SetVirtualAddressMap == "" and ExitBootServices == "":
- continue
-
- ModuleExtern = ModuleExternCallBackClass()
- ModuleExtern.ExitBootServicesCallBack = ExitBootServices
- ModuleExtern.SetVirtualAddressMapCallBack = SetVirtualAddressMap
- ModuleExternCallBacks.append(ModuleExtern)
-
- return ModuleExternCallBacks
-
-
-## Load a list of Module Build Options.
-#
-# Read an input Module XML DOM object and return a list of Build Options
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel BuildOptions A list of Build Options loaded from XmlMsa.
-#
-def LoadModuleBuildOptions(XmlMsa):
- XmlTag = "ModuleSurfaceArea/ModuleBuildOptions/Options/Option"
- return map(LoadBuildOption, XmlList(XmlMsa, XmlTag))
-
-
-## Load a list of Module User Extensions.
-#
-# Read an input Module XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlMsa An XML DOM object read from MSA file.
-#
-# @retvel UserExtensions A list of User Extensions loaded from XmlMsa.
-#
-def LoadModuleUserExtensions(XmlMsa):
- XmlTag = "ModuleSurfaceArea/UserExtensions"
- return map(LoadUserExtensions, XmlList(XmlMsa, XmlTag))
-
-## Load a new Module class object.
-#
-# Read an input MSA File and return a new Module class Object.
-#
-# @param MsaFileName An XML DOM object read from MSA file.
-#
-# @retvel Module A new Module class object loaded from MSA File.
-#
-def LoadMsa(MsaFileName):
- XmlMsa = XmlParseFile(MsaFileName)
- EdkLogger.verbose("Load MSA File: %s" % MsaFileName)
-
- Module = ModuleClass()
- Module.Header = LoadModuleHeader(XmlMsa, MsaFileName)
- Module.LibraryClasses = LoadModuleLibraryClasses(XmlMsa)
- Module.Sources = LoadModuleSources(XmlMsa)
- Module.BinaryFiles = LoadModuleBinaries(XmlMsa)
- Module.NonProcessedFiles = LoadModuleNonProcessedFiles(XmlMsa)
- Module.PackageDependencies = LoadModulePackageDependencies(XmlMsa)
- Module.Protocols = LoadModuleProtocols(XmlMsa)
- Module.Ppis = LoadModulePpis(XmlMsa)
- Module.Events = LoadModuleEvents(XmlMsa)
- Module.Hobs = LoadModuleHobs(XmlMsa)
- Module.Variables = LoadModuleVariables(XmlMsa)
- Module.BootModes = LoadModuleBootModes(XmlMsa)
- Module.SystemTables = LoadModuleSystemTables(XmlMsa)
- Module.DataHubs = LoadModuleDataHubs(XmlMsa)
- Module.HiiPackages = LoadModuleHiiPackages(XmlMsa)
- Module.Guids = LoadModuleGuids(XmlMsa)
- Module.PcdCodes = LoadModulePcdCodes(XmlMsa)
- Module.ExternImages = LoadModuleExternImages(XmlMsa)
- Module.ExternLibraries = LoadModuleExternLibraries(XmlMsa)
- Module.ExternDrivers = LoadModuleExternDrivers(XmlMsa)
- Module.ExternCallBacks = LoadModuleExternCallBacks(XmlMsa)
- Module.BuildOptions = LoadModuleBuildOptions(XmlMsa)
- Module.UserExtensions = LoadModuleUserExtensions(XmlMsa)
-
- return Module
-
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- pass \ No newline at end of file
diff --git a/BaseTools/Source/Python/msa2inf/Msa2Inf.py b/BaseTools/Source/Python/msa2inf/Msa2Inf.py
deleted file mode 100644
index 04c86026de..0000000000
--- a/BaseTools/Source/Python/msa2inf/Msa2Inf.py
+++ /dev/null
@@ -1,44 +0,0 @@
-## @file
-# Convert an XML-based MSA file to a text-based INF file.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import sys
-from Common.MigrationUtilities import *
-from LoadMsa import LoadMsa
-from StoreInf import StoreInf
-from ConvertModule import ConvertMsaModuleToInfModule
-
-## Entrance method
-#
-# This method mainly dispatch specific methods per the command line options.
-# If no error found, return zero value so the caller of this tool can know
-# if it's executed successfully or not.
-#
-# @retval 0 Tool was successful.
-# @retval 1 Tool failed.
-#
-def Main():
- try:
- Options, InputFile = MigrationOptionParser("MSA", "INF", "%prog")
- Module = LoadMsa(InputFile)
- ConvertMsaModuleToInfModule(Module)
- StoreInf(Options.OutputFile, Module)
- return 0
- except Exception, e:
- print e
- return 1
-
-if __name__ == '__main__':
- sys.exit(Main())
diff --git a/BaseTools/Source/Python/msa2inf/StoreInf.py b/BaseTools/Source/Python/msa2inf/StoreInf.py
deleted file mode 100644
index d7f6869d76..0000000000
--- a/BaseTools/Source/Python/msa2inf/StoreInf.py
+++ /dev/null
@@ -1,442 +0,0 @@
-## @file
-# Store a Module class object to an INF file.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-from LoadMsa import LoadMsa
-from CommonDataClass.ModuleClass import *
-from Common.MigrationUtilities import *
-
-## Get the produced library class.
-#
-# Return the item of Library Class based on Library .
-#
-# @param LibraryClasses A list of library classes the module produces.
-#
-# @retval LibraryClassItem A text format library class item.
-#
-def GetModuleLibraryClass(LibraryClasses):
- ProducedLibraryClasses = []
- for LibraryClass in LibraryClasses:
- ProducedLibraryClass = LibraryClass.LibraryClass
- SupportedModueTypes = " ".join(LibraryClass.SupModuleList)
- if SupportedModueTypes != "":
- ProducedLibraryClass += "|" + SupportedModueTypes
- ProducedLibraryClasses.append(ProducedLibraryClass)
-
- return "|".join(ProducedLibraryClasses)
-
-
-## Store Defines section.
-#
-# Write [Defines] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Defines section.
-# @param Module An input Module class object.
-#
-def StoreModuleDefinesSection(InfFile, Module):
- ModuleHeader = Module.Header
-
- DefinesTupleList = []
- DefinesTupleList.append(("INF_VERSION", ModuleHeader.InfVersion))
-
- if ModuleHeader.Name != "":
- DefinesTupleList.append(("BASE_NAME", ModuleHeader.Name))
-
- if ModuleHeader.Guid != "":
- DefinesTupleList.append(("FILE_GUID", ModuleHeader.Guid))
-
- if ModuleHeader.Version != "":
- DefinesTupleList.append(("VERSION_STRING", ModuleHeader.Version))
-
- if ModuleHeader.ModuleType != "":
- DefinesTupleList.append(("MODULE_TYPE", ModuleHeader.ModuleType))
-
- if ModuleHeader.UefiSpecificationVersion != "":
- DefinesTupleList.append(("UEFI_SPECIFICATION_VERSION", ModuleHeader.UefiSpecificationVersion))
-
- if ModuleHeader.EdkReleaseVersion != "":
- DefinesTupleList.append(("EDK_RELEASE_VERSION", ModuleHeader.EdkReleaseVersion))
-
- ProducedLibraryClass = GetModuleLibraryClass(ModuleHeader.LibraryClass)
- if ProducedLibraryClass != "":
- DefinesTupleList.append(("LIBRARY_CLASS", ProducedLibraryClass))
-
- if ModuleHeader.MakefileName != "":
- DefinesTupleList.append(("MAKEFILE_NAME", ModuleHeader.MakeFileName))
-
- if ModuleHeader.PcdIsDriver != "":
- DefinesTupleList.append(("PCD_DRIVER", "TRUE"))
-
- if len(Module.ExternImages) > 0:
- ModuleEntryPoint = Module.ExternImages[0].ModuleEntryPoint
- ModuleUnloadImage = Module.ExternImages[0].ModuleUnloadImage
- if ModuleEntryPoint != "":
- DefinesTupleList.append(("ENTRY_POINT", ModuleEntryPoint))
- if ModuleUnloadImage != "":
- DefinesTupleList.append(("UNLOAD_IMAGE", ModuleUnloadImage))
-
- if len(Module.ExternLibraries) > 0:
- Constructor = Module.ExternLibraries[0].Constructor
- Destructor = Module.ExternLibraries[0].Destructor
- if Constructor != "":
- DefinesTupleList.append(("CONSTRUCTOR", Constructor))
- if Destructor != "":
- DefinesTupleList.append(("DESTRUCTOR", Destructor))
-
- StoreDefinesSection(InfFile, DefinesTupleList)
-
-
-## Return a Module Source Item.
-#
-# Read the input ModuleSourceFile class object and return one line of Source Item.
-#
-# @param ModuleSourceFile An input ModuleSourceFile class object.
-#
-# @retval SourceItem A Module Source Item.
-#
-def GetModuleSourceItem(ModuleSourceFile):
- Source = []
- Source.append(ModuleSourceFile.SourceFile)
- Source.append(ModuleSourceFile.ToolChainFamily)
- Source.append(ModuleSourceFile.TagName)
- Source.append(ModuleSourceFile.ToolCode)
- Source.append(ModuleSourceFile.FeatureFlag)
- return "|".join(Source).rstrip("|")
-
-
-## Store Sources section.
-#
-# Write [Sources] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Sources section.
-# @param Module An input Module class object.
-#
-def StoreModuleSourcesSection(InfFile, Module):
- Section = GetSection("Sources", GetModuleSourceItem, Module.Sources)
- StoreTextFile(InfFile, Section)
-
-
-## Return a Module Binary Item.
-#
-# Read the input ModuleBinaryFile class object and return one line of Binary Item.
-#
-# @param ModuleBinaryFile An input ModuleBinaryFile class object.
-#
-# @retval BinaryItem A Module Binary Item.
-#
-def GetModuleBinaryItem(ModuleBinaryFile):
- Binary = []
- Binary.append(ModuleBinaryFile.FileType)
- Binary.append(ModuleBinaryFile.BinaryFile)
- Binary.append(ModuleBinaryFile.Target)
- Binary.append(ModuleBinaryFile.FeatureFlag)
- return "|".join(Binary).rstrip("|")
-
-
-## Store Binaries section.
-#
-# Write [Binaries] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Binaries section.
-# @param Module An input Module class object.
-#
-def StoreModuleBinariesSection(InfFile, Module):
- Section = GetSection("Binaries", GetModuleBinaryItem, Module.Binaries)
- StoreTextFile(InfFile, Section)
-
-
-## Return a Module Library Class Item.
-#
-# Read the input LibraryClass class object and return one line of Library Class Item.
-#
-# @param LibraryClass An input LibraryClass class object.
-#
-# @retval LibraryClassItem A Module Library Class Item.
-#
-def GetModuleLibraryClassItem(LibraryClass):
- if "ALWAYS_PRODUCED" in LibraryClass.Usage:
- return ""
-
- LibraryClassList = []
- LibraryClassList.append(LibraryClass.LibraryClass)
- LibraryClassList.append(LibraryClass.RecommendedInstance)
- LibraryClassList.append(LibraryClass.FeatureFlag)
-
- return "|".join(LibraryClassList).rstrip("|")
-
-
-## Store Library Classes section.
-#
-# Write [LibraryClasses] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Library Classes section.
-# @param Module An input Module class object.
-#
-def StoreModuleLibraryClassesSection(InfFile, Module):
- Section = GetSection("LibraryClasses", GetModuleLibraryClassItem, Module.LibraryClasses)
- StoreTextFile(InfFile, Section)
-
-
-## Return a Module Package Item.
-#
-# Read the input PackageDependency class object and return one line of Package Item.
-#
-# @param PackageDependency An input PackageDependency class object.
-#
-# @retval PackageItem A Module Package Item.
-#
-def GetModulePackageItem(PackageDependency):
- return PackageDependency.FilePath
-
-
-## Store Packages section.
-#
-# Write [Packages] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Packages section.
-# @param Module An input Module class object.
-#
-def StoreModulePackagesSection(InfFile, Module):
- Section = GetSection("Packages", GetModulePackageItem, Module.PackageDependencies)
- StoreTextFile(InfFile, Section)
-
-
-## Return a Module Guid C Name Item.
-#
-# Read the input Guid class object and return one line of Guid C Name Item.
-#
-# @param Guid An input Guid class object.
-#
-# @retval GuidCNameItem A Module Guid C Name Item.
-#
-def GetModuleGuidCNameItem(Guid):
- try:
- return Guid.GuidCName
- except:
- return Guid.CName
-
-
-## Store Protocols section.
-#
-# Write [Protocols] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Protocols section.
-# @param Module An input Module class object.
-#
-def StoreModuleProtocolsSection(InfFile, Module):
- Section = GetSection("Protocols", GetModuleGuidCNameItem, Module.Protocols)
- StoreTextFile(InfFile, Section)
-
-
-## Store Ppis section.
-#
-# Write [Ppis] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Ppis section.
-# @param Module An input Module class object.
-#
-def StoreModulePpisSection(InfFile, Module):
- Section = GetSection("Ppis", GetModuleGuidCNameItem, Module.Ppis)
- StoreTextFile(InfFile, Section)
-
-
-## Store Guids section.
-#
-# Write [Guids] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Guids section.
-# @param Module An input Module class object.
-#
-def StoreModuleGuidsSection(InfFile, Module):
- Guids = []
- Guids += Module.Guids
- Guids += Module.Events
- Guids += Module.Hobs
- Guids += Module.Variables
- Guids += Module.SystemTables
- Guids += Module.DataHubs
- Guids += Module.HiiPackages
- Section = GetSection("Guids", GetModuleGuidCNameItem, Guids)
- StoreTextFile(InfFile, Section)
-
-
-## Return a Module Pcd Item.
-#
-# Read the input Pcd class object and return one line of Pcd Item.
-#
-# @param Pcd An input Pcd class object.
-#
-# @retval PcdItem A Module Pcd Item.
-#
-def GetModulePcdItem(Pcd):
- PcdItem = "%s.%s" % (Pcd.TokenSpaceGuidCName, Pcd.CName)
- if Pcd.DefaultValue != "":
- PcdItem = "%s|%s" % (PcdItem, Pcd.DefaultValue)
-
- return PcdItem
-
-
-## DEC Pcd Section Name dictionary indexed by PCD Item Type.
-mInfPcdSectionNameDict = {
- "FEATURE_FLAG" : "FeaturePcd",
- "FIXED_AT_BUILD" : "FixedPcd",
- "PATCHABLE_IN_MODULE" : "PatchPcd",
- "DYNAMIC" : "Pcd",
- "DYNAMIC_EX" : "PcdEx"
- }
-
-## Store Pcds section.
-#
-# Write [(PcdType)] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Pcds section.
-# @param Module An input Module class object.
-#
-def StoreModulePcdsSection(InfFile, Module):
- PcdsDict = {}
- for Pcd in Module.PcdCodes:
- PcdSectionName = mInfPcdSectionNameDict.get(Pcd.ItemType)
- if PcdSectionName:
- PcdsDict.setdefault(PcdSectionName, []).append(Pcd)
- else:
- EdkLogger.info("Unknown Pcd Item Type: %s" % Pcd.ItemType)
-
- Section = ""
- for PcdSectionName in PcdsDict:
- Pcds = PcdsDict[PcdSectionName]
- Section += GetSection(PcdSectionName, GetModulePcdItem, Pcds)
- Section += "\n"
-
- StoreTextFile(InfFile, Section)
-
-
-## Return a Module Depex Item.
-#
-# Read the input Depex class object and return one line of Depex Item.
-#
-# @param Depex An input Depex class object.
-#
-# @retval DepexItem A Module Depex Item.
-#
-def GetModuleDepexItem(Depex):
- return Depex.Depex
-
-
-## Store Depex section.
-#
-# Write [Depex] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Depex section.
-# @param Module An input Module class object.
-#
-def StoreModuleDepexSection(InfFile, Module):
- Section = GetSection("Depex", GetModuleDepexItem, Module.Depex)
- StoreTextFile(InfFile, Section)
-
-
-## Return a Module Build Option Item.
-#
-# Read the input BuildOption class object and return one line of Build Option Item.
-#
-# @param BuildOption An input BuildOption class object.
-#
-# @retval BuildOptionItem A Module Build Option Item.
-#
-def GetModuleBuildOptionItem(BuildOption):
- BuildTarget = BuildOption.BuildTarget
- if BuildTarget == "":
- BuildTarget = "*"
-
- TagName = BuildOption.TagName
- if TagName == "":
- TagName = "*"
-
- ToolCode = BuildOption.ToolCode
- if ToolCode == "":
- ToolCode = "*"
-
- Item = "_".join((BuildTarget, TagName, "*", ToolCode, "Flag"))
-
- ToolChainFamily = BuildOption.ToolChainFamily
- if ToolChainFamily != "":
- Item = "%s:%s" % (ToolChainFamily, Item)
-
- return "%-30s = %s" % (Item, BuildOption.Option)
-
-
-## Store Build Options section.
-#
-# Write [BuildOptions] section to the InfFile based on Module class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param InfFile The output INF file to store the Build Options section.
-# @param Module An input Module class object.
-#
-def StoreModuleBuildOptionsSection(InfFile, Module):
- Section = GetSection("BuildOption", GetModuleBuildOptionItem, Module.BuildOptions)
- StoreTextFile(InfFile, Section)
-
-
-## Store User Extensions section.
-#
-# Write [UserExtensions] section to the InfFile based on Module class object.
-#
-# @param InfFile The output INF file to store the User Extensions section.
-# @param Module An input Module class object.
-#
-def StoreModuleUserExtensionsSection(InfFile, Module):
- Section = "".join(map(GetUserExtensions, Module.UserExtensions))
- StoreTextFile(InfFile, Section)
-
-
-## Store a Module class object to a new INF file.
-#
-# Read an input Module class object and save the contents to a new INF file.
-#
-# @param INFFileName The output INF file.
-# @param Module An input Package class object.
-#
-def StoreInf(InfFileName, Module):
- InfFile = open(InfFileName, "w+")
- EdkLogger.info("Save file to %s" % InfFileName)
-
- StoreHeader(InfFile, Module.Header)
- StoreModuleDefinesSection(InfFile, Module)
- StoreModuleSourcesSection(InfFile, Module)
- StoreModuleBinariesSection(InfFile, Module)
- StoreModulePackagesSection(InfFile, Module)
- StoreModuleLibraryClassesSection(InfFile, Module)
- StoreModuleProtocolsSection(InfFile, Module)
- StoreModulePpisSection(InfFile, Module)
- StoreModuleGuidsSection(InfFile, Module)
- StoreModulePcdsSection(InfFile, Module)
- StoreModuleDepexSection(InfFile, Module)
- StoreModuleBuildOptionsSection(InfFile, Module)
- StoreModuleUserExtensionsSection(InfFile, Module)
-
- InfFile.close()
-
-if __name__ == '__main__':
- pass
diff --git a/BaseTools/Source/Python/msa2inf/__init__.py b/BaseTools/Source/Python/msa2inf/__init__.py
deleted file mode 100644
index ed1749bd12..0000000000
--- a/BaseTools/Source/Python/msa2inf/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-## @file
-# Python 'msa2inf' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
diff --git a/BaseTools/Source/Python/spd2dec/ConvertPackage.py b/BaseTools/Source/Python/spd2dec/ConvertPackage.py
deleted file mode 100644
index f074225280..0000000000
--- a/BaseTools/Source/Python/spd2dec/ConvertPackage.py
+++ /dev/null
@@ -1,66 +0,0 @@
-## @file
-# Convert an SPD Package class object ot a DEC Package class object by filling
-# some fields required by DEC file.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-from Common.MigrationUtilities import *
-from LoadSpd import LoadSpd
-from StoreDec import StoreDec
-
-#The default DEC version number tool generates.
-gDecVersion = "0x00010005"
-
-
-## Add required version information.
-#
-# Add the default DEC specification version to Package class object.
-#
-# @param Package An input Package class object.
-#
-def AddPackageMiscVersion(Package):
- PackageHeader = Package.Header
- PackageHeader.DecSpecification = gDecVersion
-
-## Add package include information.
-#
-# Adds the default "Include" folder to if that directory exists.
-#
-# @param Package An input Package class object.
-#
-def AddPackageInclude(Package):
- PackageDir = os.path.dirname(Package.Header.FullPath)
- DefaultIncludeDir = os.path.join(PackageDir, "Include")
- if os.path.exists(DefaultIncludeDir):
- Include = IncludeClass()
- Include.FilePath = "Include"
- Package.Includes.insert(0, Include)
-
-## Convert SPD Package class object to DEC Package class object.
-#
-# Convert SPD Package class ojbect to DEC Package class object by filling in
-# several information required by DEC file.
-#
-# @param Package An input Package class object.
-#
-def ConvertSpdPackageToDecPackage(Package):
- AddPackageMiscVersion(Package)
- AddPackageInclude(Package)
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- pass
- \ No newline at end of file
diff --git a/BaseTools/Source/Python/spd2dec/LoadSpd.py b/BaseTools/Source/Python/spd2dec/LoadSpd.py
deleted file mode 100644
index e82a9bfa80..0000000000
--- a/BaseTools/Source/Python/spd2dec/LoadSpd.py
+++ /dev/null
@@ -1,273 +0,0 @@
-## @file
-# Open an SPD file and load all its contents to a PackageClass object.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-from Common.XmlRoutines import *
-from Common.MigrationUtilities import *
-from CommonDataClass.PackageClass import *
-
-
-## Load a list of Package Cloned Records.
-#
-# Read an input Package XML DOM object and return a list of Cloned Records
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel ClonedRecords A list of Cloned Records loaded from XmlSpd.
-#
-def LoadPackageClonedRecords(XmlSpd):
- XmlTag = "PackageSurfaceArea/PackageDefinitions/ClonedFrom/Cloned"
- return map(LoadClonedRecord, XmlList(XmlSpd, XmlTag))
-
-
-## Load Package Header.
-#
-# Read an input Package XML DOM object and return Package Header class object
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-# @param SpdFileName The file path of SPD File.
-#
-# @retvel PackageHeader A new Package Header object loaded from XmlSpd.
-#
-def LoadPackageHeader(XmlSpd, SpdFileName):
- PackageHeader = PackageHeaderClass()
-
- XmlTag = "PackageSurfaceArea/SpdHeader"
- SpdHeader = XmlNode(XmlSpd, XmlTag)
-
- SetIdentification(PackageHeader, SpdHeader, "PackageName", SpdFileName)
- SetCommonHeader(PackageHeader, SpdHeader)
-
- XmlTag = "PackageSurfaceArea/PackageDefinitions/ReadOnly"
- if XmlElement(XmlSpd, XmlTag).lower() == "true":
- PackageHeader.ReadOnly = True
-
- XmlTag = "PackageSurfaceArea/PackageDefinitions/RePackage"
- if XmlElement(XmlSpd, XmlTag).lower() == "true":
- PackageHeader.RePackage = True
-
- PackageHeader.ClonedFrom = LoadPackageClonedRecords(XmlSpd)
-
- return PackageHeader
-
-
-## Load a list of Package Library Classes.
-#
-# Read an input Package XML DOM object and return a list of Library Classes
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel LibraryClasses A list of Library Classes loaded from XmlSpd.
-#
-def LoadPackageLibraryClasses(XmlSpd):
- XmlTag = "PackageSurfaceArea/LibraryClassDeclarations/LibraryClass"
- return map(LoadLibraryClass, XmlList(XmlSpd, XmlTag))
-
-
-## Load a new Package Industry Std Header class object.
-#
-# Read an input XML IndustryStdHeader DOM object and return an object of
-# Industry Std Header contained in the DOM object.
-#
-# @param XmlIndustryStdHeader A child XML DOM object in Package XML DOM.
-#
-# @retvel PackageIndustryStdHeader A new Industry Std Header object created by XmlIndustryStdHeader.
-#
-def LoadPackageIndustryStdHeader(XmlIndustryStdHeader):
- PackageIndustryStdHeader = PackageIndustryStdHeaderClass()
-
- XmlTag = "Name"
- Name = XmlAttribute(XmlIndustryStdHeader, XmlTag)
- PackageIndustryStdHeader.Name = Name
-
- XmlTag = "IndustryStdHeader/IncludeHeader"
- IncludeHeader = XmlElement(XmlIndustryStdHeader, XmlTag)
- PackageIndustryStdHeader.IncludeHeader = IncludeHeader
-
- SetCommon(PackageIndustryStdHeader, XmlIndustryStdHeader)
-
- return PackageIndustryStdHeader
-
-
-## Load a list of Package Industry Std Headers.
-#
-# Read an input Package XML DOM object and return a list of Industry Std Headers
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel IndustryStdHeaders A list of Industry Std Headers loaded from XmlSpd.
-#
-def LoadPackageIndustryStdHeaders(XmlSpd):
- XmlTag = "PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader"
- return map(LoadPackageIndustryStdHeader, XmlList(XmlSpd, XmlTag))
-
-
-## Load a list of Package Module Files.
-#
-# Read an input Package XML DOM object and return a list of Module Files
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel ModuleFiles A list of Module Files loaded from XmlSpd.
-#
-def LoadPackageModuleFiles(XmlSpd):
- XmlTag = "PackageSurfaceArea/MsaFiles/Filename"
- return XmlElementList(XmlSpd, XmlTag)
-
-
-## Load a new Package Include Pkg Header class object.
-#
-# Read an input XML IncludePkgHeader DOM object and return an object of Include
-# Package Header contained in the DOM object.
-#
-# @param XmlPackageIncludeHeader A child XML DOM object in Package XML DOM.
-#
-# @retvel PackageIncludePkgHeader A new Include Pkg Header object created by
-# XmlPackageIncludeHeader.
-#
-def LoadPackageIncludePkgHeader(XmlPackageIncludeHeader):
- PackageIncludeHeader = PackageIncludePkgHeaderClass()
-
- IncludeHeader = XmlElementData(XmlPackageIncludeHeader)
- PackageIncludeHeader.IncludeHeader = IncludeHeader
-
- XmlTag = "ModuleType"
- ModuleTypes = XmlAttribute(XmlPackageIncludeHeader, XmlTag)
- PackageIncludeHeader.ModuleType = ModuleTypes.split()
-
- return PackageIncludeHeader
-
-
-## Load a list of Package Include Pkg Headers.
-#
-# Read an input Package XML DOM object and return a list of Include Pkg Headers
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel IncludePkgHeaders A list of Include Pkg Headers loaded from XmlSpd.
-#
-def LoadPackageIncludePkgHeaders(XmlSpd):
- XmlTag = "PackageSurfaceArea/PackageHeaders/IncludePkgHeader"
- return map(LoadPackageIncludePkgHeader, XmlList(XmlSpd, XmlTag))
-
-
-## Load a list of Package Guid Declarations.
-#
-# Read an input Package XML DOM object and return a list of Guid Declarations
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel GuidDeclarations A list of Guid Declarations loaded from XmlSpd.
-#
-def LoadPackageGuidDeclarations(XmlSpd):
- XmlTag = "PackageSurfaceArea/GuidDeclarations/Entry"
- return map(LoadGuidProtocolPpiCommon, XmlList(XmlSpd, XmlTag))
-
-
-## Load a list of Package Protocol Declarations.
-#
-# Read an input Package XML DOM object and return a list of Protocol Declarations
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel ProtocolDeclarations A list of Protocol Declarations loaded from XmlSpd.
-#
-def LoadPackageProtocolDeclarations(XmlSpd):
- XmlTag = "PackageSurfaceArea/ProtocolDeclarations/Entry"
- return map(LoadGuidProtocolPpiCommon, XmlList(XmlSpd, XmlTag))
-
-
-## Load a list of Package Ppi Declarations.
-#
-# Read an input Package XML DOM object and return a list of Ppi Declarations
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel PpiDeclarations A list of Ppi Declarations loaded from XmlSpd.
-#
-def LoadPackagePpiDeclarations(XmlSpd):
- XmlTag = "PackageSurfaceArea/PpiDeclarations/Entry"
- return map(LoadGuidProtocolPpiCommon, XmlList(XmlSpd, XmlTag))
-
-
-## Load a list of Package Pcd Declarations.
-#
-# Read an input Package XML DOM object and return a list of Pcd Declarations
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel PcdDeclarations A list of Pcd Declarations loaded from XmlSpd.
-#
-def LoadPackagePcdDeclarations(XmlSpd):
- XmlTag = "PackageSurfaceArea/PcdDeclarations/PcdEntry"
- return map(LoadPcd, XmlList(XmlSpd, XmlTag))
-
-
-## Load a list of Package User Extensions.
-#
-# Read an input Package XML DOM object and return a list of User Extensions
-# contained in the DOM object.
-#
-# @param XmlSpd An XML DOM object read from SPD file.
-#
-# @retvel UserExtensions A list of User Extensions loaded from XmlSpd.
-#
-def LoadPackageUserExtensions(XmlSpd):
- XmlTag = "PackageSurfaceArea/UserExtensions"
- return map(LoadUserExtensions, XmlList(XmlSpd, XmlTag))
-
-
-## Load a new Package class object.
-#
-# Read an input SPD File and return a new Package class Object.
-#
-# @param SpdFileName An XML DOM object read from SPD file.
-#
-# @retvel Package A new Module class object loaded from SPD File.
-#
-def LoadSpd(SpdFileName):
- XmlSpd = XmlParseFile(SpdFileName)
- EdkLogger.verbose("Xml Object loaded for file %s" % SpdFileName)
-
- Package = PackageClass()
- Package.Header = LoadPackageHeader(XmlSpd, SpdFileName)
- Package.LibraryClassDeclarations = LoadPackageLibraryClasses(XmlSpd)
- Package.IndustryStdHeaders = LoadPackageIndustryStdHeaders(XmlSpd)
- Package.ModuleFiles = LoadPackageModuleFiles(XmlSpd)
- Package.PackageIncludePkgHeaders = LoadPackageIncludePkgHeaders(XmlSpd)
- Package.GuidDeclarations = LoadPackageGuidDeclarations(XmlSpd)
- Package.ProtocolDeclarations = LoadPackageProtocolDeclarations(XmlSpd)
- Package.PpiDeclarations = LoadPackagePpiDeclarations(XmlSpd)
- Package.PcdDeclarations = LoadPackagePcdDeclarations(XmlSpd)
- Package.UserExtensions = LoadPackageUserExtensions(XmlSpd)
-
- return Package
-
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- pass
diff --git a/BaseTools/Source/Python/spd2dec/Spd2Dec.py b/BaseTools/Source/Python/spd2dec/Spd2Dec.py
deleted file mode 100644
index 2d2814ae0d..0000000000
--- a/BaseTools/Source/Python/spd2dec/Spd2Dec.py
+++ /dev/null
@@ -1,46 +0,0 @@
-## @file
-# Convert an XML-based SPD file to a text-based DEC file.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import sys
-from Common.MigrationUtilities import *
-from LoadSpd import LoadSpd
-from StoreDec import StoreDec
-from ConvertPackage import ConvertSpdPackageToDecPackage
-
-## Entrance method
-#
-# This method mainly dispatch specific methods per the command line options.
-# If no error found, return zero value so the caller of this tool can know
-# if it's executed successfully or not.
-#
-# @retval 0 Tool was successful.
-# @retval 1 Tool failed.
-#
-def Main():
- try:
- Options, InputFile = MigrationOptionParser("SPD", "DEC", "%prog")
- Package = LoadSpd(InputFile)
- ConvertSpdPackageToDecPackage(Package)
- StoreDec(Options.OutputFile, Package)
- return 0
- except Exception, e:
- print e
- return 1
-
-if __name__ == '__main__':
- sys.exit(Main())
-
-
diff --git a/BaseTools/Source/Python/spd2dec/StoreDec.py b/BaseTools/Source/Python/spd2dec/StoreDec.py
deleted file mode 100644
index f3805f6210..0000000000
--- a/BaseTools/Source/Python/spd2dec/StoreDec.py
+++ /dev/null
@@ -1,247 +0,0 @@
-## @file
-# Store a Package class object to a DEC file.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-##
-# Import Modules
-#
-import os
-from Common.MigrationUtilities import *
-from LoadSpd import LoadSpd
-from CommonDataClass.PackageClass import *
-
-
-## Store Defines section.
-#
-# Write [Defines] section to the DecFile based on Package class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DecFile The output DEC file to store the Defines section.
-# @param Package An input Package class object.
-#
-def StorePackageDefinesSection(DecFile, Package):
- DefinesTupleList = []
- DefinesTupleList.append(("DEC_VERSION", Package.Header.DecSpecification))
- DefinesTupleList.append(("PACKAGE_NAME", Package.Header.Name))
- DefinesTupleList.append(("PACKAGE_GUID", Package.Header.Guid))
-
- StoreDefinesSection(DecFile, DefinesTupleList)
-
-
-## Return a Package Include Class Item.
-#
-# Read the input Include class object and return one Include Class Item.
-#
-# @param Include An input Include class object.
-#
-# @retval IncludeClassItem A Package Include Class Item.
-#
-def GetPackageIncludeClassItem(Include):
- return Include.FilePath
-
-
-## Store Includes section.
-#
-# Write [Includes] section to the DecFile based on Package class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DecFile The output DEC file to store the Includes section.
-# @param Package An input Package class object.
-#
-def StorePackageIncludesSection(DecFile, Package):
- Includes = Package.Includes
- Section = GetSection("Includes", GetPackageIncludeClassItem, Includes)
- StoreTextFile(DecFile, Section)
-
-
-## Return a Package Library Class Item.
-#
-# Read the input LibraryClass class object and return one Library Class Item.
-#
-# @param LibraryClass An input LibraryClass class object.
-#
-# @retval LibraryClassItem A Package Library Class Item.
-#
-def GetPackageLibraryClassItem(LibraryClass):
- return "|".join((LibraryClass.LibraryClass, LibraryClass.IncludeHeader))
-
-
-## Store Library Classes section.
-#
-# Write [LibraryClasses] section to the DecFile based on Package class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DecFile The output DEC file to store the Library Classes
-# section.
-# @param Package An input Package class object.
-#
-def StorePackageLibraryClassesSection(DecFile, Package):
- LibraryClasses = Package.LibraryClassDeclarations
- Section = GetSection("LibraryClasses", GetPackageLibraryClassItem, LibraryClasses)
- StoreTextFile(DecFile, Section)
-
-
-## Return a Package Guid Declaration Item.
-#
-# Read the input Guid class object and return one line of Guid Declaration Item.
-#
-# @param Guid An input Guid class object.
-#
-# @retval GuidDeclarationItem A Package Guid Declaration Item.
-#
-def GetPackageGuidDeclarationItem(Guid):
- GuidCName = Guid.CName
- GuidValue = Guid.Guid.replace("-", "")
- GuidValueList = [GuidValue[0:8]]
- GuidValueList += [GuidValue[i : i + 4] for i in range(8, 16, 4)]
- GuidValueList += [GuidValue[i : i + 2] for i in range(16, 32, 2)]
-
- GuidCFormat = "{0x%s" + ", 0x%s" * 2 + ", {0x%s" + ", 0x%s" * 7 + "}}"
- GuidCValue = GuidCFormat % tuple(GuidValueList)
- return "%-30s = %s" % (GuidCName, GuidCValue)
-
-
-## Store Protocols section.
-#
-# Write [Protocols] section to the DecFile based on Package class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DecFile The output DEC file to store the Protocols section.
-# @param Package An input Package class object.
-#
-def StorePackageProtocolsSection(DecFile, Package):
- Protocols = Package.ProtocolDeclarations
- Section = GetSection("Protocols", GetPackageGuidDeclarationItem, Protocols)
- StoreTextFile(DecFile, Section)
-
-
-## Store Ppis section.
-#
-# Write [Ppis] section to the DecFile based on Package class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DecFile The output DEC file to store the Ppis section.
-# @param Package An input Package class object.
-#
-def StorePackagePpisSection(DecFile, Package):
- Ppis = Package.PpiDeclarations
- Section = GetSection("Ppis", GetPackageGuidDeclarationItem, Ppis)
- StoreTextFile(DecFile, Section)
-
-
-## Store Guids section.
-#
-# Write [Guids] section to the DecFile based on Package class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DecFile The output DEC file to store the Guids section.
-# @param Package An input Package class object.
-#
-def StorePackageGuidsSection(DecFile, Package):
- Guids = Package.GuidDeclarations
- Section = GetSection("Guids", GetPackageGuidDeclarationItem, Guids)
- StoreTextFile(DecFile, Section)
-
-
-## Return a Package Pcd Item.
-#
-# Read the input Pcd class object and return one line of Pcd Item.
-#
-# @param Pcd An input Pcd class object.
-#
-# @retval PcdItem A Package Pcd Item.
-#
-def GetPackagePcdItem(Pcd):
- PcdPair = "%s.%s" % (Pcd.TokenSpaceGuidCName, Pcd.CName)
- DatumType = Pcd.DatumType
- DefaultValue = Pcd.DefaultValue
- Token = Pcd.Token
- PcdList = [PcdPair, DefaultValue, DatumType, Token]
- return "|".join(PcdList)
-
-
-## DEC Pcd Section Name dictionary indexed by PCD Item Type.
-mDecPcdSectionNameDict = {
- "FEATURE_FLAG" : "PcdsFeatureFlag",
- "FIXED_AT_BUILD" : "PcdsFixedAtBuild",
- "PATCHABLE_IN_MODULE" : "PcdsPatchableInModule",
- "DYNAMIC" : "PcdsDynamic",
- "DYNAMIC_EX" : "PcdsDynamicEx"
- }
-
-## Store Pcds section.
-#
-# Write [Pcds*] section to the DecFile based on Package class object.
-# Different CPU architectures are specified in the subsection if possible.
-#
-# @param DecFile The output DEC file to store the Pcds section.
-# @param Package An input Package class object.
-#
-def StorePackagePcdsSection(DecFile, Package):
- PcdsDict = {}
- for Pcd in Package.PcdDeclarations:
- for PcdItemType in Pcd.ValidUsage:
- PcdSectionName = mDecPcdSectionNameDict.get(PcdItemType)
- if PcdSectionName:
- PcdsDict.setdefault(PcdSectionName, []).append(Pcd)
- else:
- EdkLogger.info("Unknown Pcd Item Type: %s" % PcdItemType)
-
- Section = ""
- for PcdSectionName in PcdsDict:
- Pcds = PcdsDict[PcdSectionName]
- Section += GetSection(PcdSectionName, GetPackagePcdItem, Pcds)
-
- StoreTextFile(DecFile, Section)
-
-
-## Store User Extensions section.
-#
-# Write [UserExtensions] section to the DecFile based on Package class object.
-#
-# @param DecFile The output DEC file to store the User Extensions section.
-# @param Package An input Package class object.
-#
-def StorePackageUserExtensionsSection(DecFile, Package):
- Section = "".join(map(GetUserExtensions, Package.UserExtensions))
- StoreTextFile(DecFile, Section)
-
-
-## Store a Package class object to a new DEC file.
-#
-# Read an input Package class object and ave the contents to a new DEC file.
-#
-# @param DecFileName The output DEC file.
-# @param Package An input Package class object.
-#
-def StoreDec(DecFileName, Package):
- DecFile = open(DecFileName, "w+")
- EdkLogger.info("Save file to %s" % DecFileName)
-
- StoreHeader(DecFile, Package.Header)
- StorePackageDefinesSection(DecFile, Package)
- StorePackageIncludesSection(DecFile, Package)
- StorePackageLibraryClassesSection(DecFile, Package)
- StorePackageProtocolsSection(DecFile, Package)
- StorePackagePpisSection(DecFile, Package)
- StorePackageGuidsSection(DecFile, Package)
- StorePackagePcdsSection(DecFile, Package)
- StorePackageUserExtensionsSection(DecFile, Package)
-
- DecFile.close()
-
-
-# This acts like the main() function for the script, unless it is 'import'ed
-# into another script.
-if __name__ == '__main__':
- pass
- \ No newline at end of file
diff --git a/BaseTools/Source/Python/spd2dec/__init__.py b/BaseTools/Source/Python/spd2dec/__init__.py
deleted file mode 100644
index 41e5b2656e..0000000000
--- a/BaseTools/Source/Python/spd2dec/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-## @file
-# Python 'spd2dec' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#