diff options
author | Carsey, Jaben <jaben.carsey@intel.com> | 2018-04-16 21:52:13 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-04-18 22:15:35 +0800 |
commit | 55c84777ee638be8735a5c421941e7eb71633bdf (patch) | |
tree | d7e686884a5caa82209b2d57db5c38d2f468ec4e /BaseTools/Source/Python/GenFds | |
parent | 5a693b89a1976f13d32a3ed302f5d6e0664979d6 (diff) | |
download | edk2-55c84777ee638be8735a5c421941e7eb71633bdf.tar.gz edk2-55c84777ee638be8735a5c421941e7eb71633bdf.tar.bz2 edk2-55c84777ee638be8735a5c421941e7eb71633bdf.zip |
BaseTools: use predefined constants instead of local strings
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r-- | BaseTools/Source/Python/GenFds/AprioriSection.py | 5 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FdfParser.py | 13 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsInfStatement.py | 5 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/GenFds.py | 12 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 8 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/Section.py | 5 |
6 files changed, 26 insertions, 22 deletions
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py index 92a74670ed..7cf792b5b2 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -1,7 +1,7 @@ ## @file
# process APRIORI file data and generate PEI/DXE APRIORI file
#
-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2018, 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
@@ -25,6 +25,7 @@ from Common.String import * from Common.Misc import SaveFileOnChange,PathClass
from Common import EdkLogger
from Common.BuildToolError import *
+from Common.DataType import TAB_COMMON
## process APRIORI file data and generate PEI/DXE APRIORI file
#
@@ -84,7 +85,7 @@ class AprioriSection (AprioriSectionClassObject): Guid = Inf.Guid
else:
- Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
Guid = Inf.Guid
self.BinFileList = Inf.Module.Binaries
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index dce41701a5..bff1d47393 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -52,6 +52,7 @@ from Common.String import NormPath import Common.GlobalData as GlobalData
from Common.Expression import *
from Common import GlobalData
+from Common.DataType import *
from Common.String import ReplaceMacro
import uuid
from Common.Misc import tdict
@@ -511,8 +512,8 @@ class FdfParser: if Item == '' or Item == 'RULE':
return
- if Item == 'DEFINES':
- self.__CurSection = ['COMMON', 'COMMON', 'COMMON']
+ if Item == TAB_COMMON_DEFINES.upper():
+ self.__CurSection = [TAB_COMMON, TAB_COMMON, TAB_COMMON]
elif Item == 'VTF' and len(ItemList) == 3:
UiName = ItemList[2]
Pos = UiName.find(',')
@@ -520,9 +521,9 @@ class FdfParser: UiName = UiName[:Pos]
self.__CurSection = ['VTF', UiName, ItemList[1]]
elif len(ItemList) > 1:
- self.__CurSection = [ItemList[0], ItemList[1], 'COMMON']
+ self.__CurSection = [ItemList[0], ItemList[1], TAB_COMMON]
elif len(ItemList) > 0:
- self.__CurSection = [ItemList[0], 'DUMMY', 'COMMON']
+ self.__CurSection = [ItemList[0], 'DUMMY', TAB_COMMON]
## PreprocessFile() method
#
@@ -886,7 +887,7 @@ class FdfParser: if self.__CurSection:
# Defines macro
- ScopeMacro = self.__MacroDict['COMMON', 'COMMON', 'COMMON']
+ ScopeMacro = self.__MacroDict[TAB_COMMON, TAB_COMMON, TAB_COMMON]
if ScopeMacro:
MacroDict.update(ScopeMacro)
@@ -3586,7 +3587,7 @@ class FdfParser: raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
Arch = self.__SkippedChars.rstrip(".")
- if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH64", "COMMON"):
+ if Arch.upper() not in ARCH_LIST_FULL:
raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber)
ModuleType = self.__GetModuleType()
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 8ae29b285d..8f5a1bfd10 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -47,6 +47,7 @@ import Common.GlobalData as GlobalData from DepexSection import DepexSection
from Common.Misc import SaveFileOnChange
from Common.Expression import *
+from Common.DataType import TAB_COMMON
## generate FFS from INF
#
@@ -205,7 +206,7 @@ class FfsInfStatement(FfsInfStatementClassObject): self.ShadowFromInfFile = Inf.Shadow
else:
- Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
self.BaseName = Inf.BaseName
self.ModuleGuid = Inf.Guid
self.ModuleType = Inf.ModuleType
@@ -570,7 +571,7 @@ class FfsInfStatement(FfsInfStatementClassObject): RuleName = 'RULE' + \
'.' + \
- 'COMMON' + \
+ TAB_COMMON + \
'.' + \
self.ModuleType.upper()
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 810a1f86e9..c507b0148a 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -238,11 +238,11 @@ def main(): ArchList = Options.archList.split(',')
else:
# EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH")
- ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList
+ ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList
- TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)
+ TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)
if len(TargetArchList) == 0:
- EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList)))
+ EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList)))
for Arch in ArchList:
GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory)
@@ -674,7 +674,7 @@ class GenFds : # @retval None
#
def PreprocessImage(BuildDb, DscFile):
- PcdDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds
+ PcdDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds
PcdValue = ''
for Key in PcdDict:
PcdObj = PcdDict[Key]
@@ -693,9 +693,9 @@ class GenFds : if Int64PcdValue > 0:
TopAddress = Int64PcdValue
- ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
+ ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
for Key in ModuleDict:
- ModuleObj = BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 2f9d58f6bf..5e5dc4c948 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -130,7 +130,7 @@ class GenFdsGlobalVariable: @staticmethod
def GetBuildRules(Inf, Arch):
if not Arch:
- Arch = 'COMMON'
+ Arch = DataType.TAB_COMMON
if not Arch in GenFdsGlobalVariable.OutputDirDict:
return {}
@@ -217,7 +217,7 @@ class GenFdsGlobalVariable: FileList.append((File, DataType.TAB_UNKNOWN_FILE))
for File in Inf.Binaries:
- if File.Target in ['COMMON', '*', GenFdsGlobalVariable.TargetName]:
+ if File.Target in [DataType.TAB_COMMON, '*', GenFdsGlobalVariable.TargetName]:
FileList.append((File, File.Type))
for File, FileType in FileList:
@@ -759,7 +759,7 @@ class GenFdsGlobalVariable: # @param Str String that may contain macro
# @param MacroDict Dictionary that contains macro value pair
#
- def MacroExtend (Str, MacroDict={}, Arch='COMMON'):
+ def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):
if Str is None :
return None
@@ -771,7 +771,7 @@ class GenFdsGlobalVariable: '$(SPACE)' : ' '
}
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[GenFdsGlobalVariable.ArchList[0]]
- if Arch != 'COMMON' and Arch in GenFdsGlobalVariable.ArchList:
+ if Arch != DataType.TAB_COMMON and Arch in GenFdsGlobalVariable.ArchList:
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[Arch]
Dict['$(OUTPUT_DIRECTORY)'] = OutputDir
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index 6335c249a6..4b368b3ada 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,7 +1,7 @@ ## @file
# section base class
#
-# Copyright (c) 2007-2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007-2018, 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
@@ -20,6 +20,7 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable import Common.LongFilePathOs as os, glob
from Common import EdkLogger
from Common.BuildToolError import *
+from Common.DataType import TAB_ARCH_COMMON
## section base class
#
@@ -125,7 +126,7 @@ class Section (SectionClassObject): FileList = []
if FileType is not None:
for File in FfsInf.BinFileList:
- if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:
+ if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch == File.Arch:
if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \
and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \
or (FileType == 'TE'and File.Type == 'PE32'):
|