BaseTools: Update UPT tool to support multiple workspaces

Update UPT to refer MultipleWorkspace class to convert
the file path from WORKSPACE and PACKAGES_PATH.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hesheng Chen <hesheng.chen@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18580 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Hesheng Chen
2015-10-08 09:28:15 +00:00
committed by lgao4
parent 05cc51ad58
commit fb0f8067ea
9 changed files with 57 additions and 37 deletions

View File

@ -32,6 +32,7 @@ from Logger.ToolError import EDK1_INF_ERROR
from Object.POM.CommonObject import IdentificationObject from Object.POM.CommonObject import IdentificationObject
from Object.POM.CommonObject import CommonHeaderObject from Object.POM.CommonObject import CommonHeaderObject
from Object.POM.CommonObject import MiscFileObject from Object.POM.CommonObject import MiscFileObject
from Common.MultipleWorkspace import MultipleWorkspace as mws
## DistributionPackageHeaderClass ## DistributionPackageHeaderClass
# #
@ -110,14 +111,17 @@ class DistributionPackageClass(object):
# @param ModuleList: A list of all modules # @param ModuleList: A list of all modules
# #
def GetDistributionPackage(self, WorkspaceDir, PackageList, ModuleList): def GetDistributionPackage(self, WorkspaceDir, PackageList, ModuleList):
# Backup WorkspaceDir
Root = WorkspaceDir
# #
# Get Packages # Get Packages
# #
if PackageList: if PackageList:
for PackageFile in PackageList: for PackageFile in PackageList:
PackageFileFullPath = \ PackageFileFullPath = mws.join(Root, PackageFile)
os.path.normpath(os.path.join(WorkspaceDir, PackageFile)) WorkspaceDir = mws.getWs(Root, PackageFile)
DecObj = DecPomAlignment(PackageFileFullPath, WorkspaceDir, CheckMulDec = True) DecObj = DecPomAlignment(PackageFileFullPath, WorkspaceDir, CheckMulDec=True)
PackageObj = DecObj PackageObj = DecObj
# #
# Parser inf file one bye one # Parser inf file one bye one
@ -140,8 +144,7 @@ class DistributionPackageClass(object):
# Inf class in InfPomAlignment. # Inf class in InfPomAlignment.
# #
try: try:
ModuleObj = InfPomAlignment(Filename, WorkspaceDir, \ ModuleObj = InfPomAlignment(Filename, WorkspaceDir, PackageObj.GetPackagePath())
PackageObj.GetPackagePath())
# #
# Add module to package # Add module to package
@ -168,11 +171,11 @@ class DistributionPackageClass(object):
# #
if ModuleList: if ModuleList:
for ModuleFile in ModuleList: for ModuleFile in ModuleList:
ModuleFileFullPath = \ ModuleFileFullPath = mws.join(Root, ModuleFile)
os.path.normpath(os.path.join(WorkspaceDir, ModuleFile)) WorkspaceDir = mws.getWs(Root, ModuleFile)
try: try:
ModuleObj = InfPomAlignment(ModuleFileFullPath, ModuleObj = InfPomAlignment(ModuleFileFullPath, WorkspaceDir)
WorkspaceDir)
ModuleKey = (ModuleObj.GetGuid(), ModuleKey = (ModuleObj.GetGuid(),
ModuleObj.GetVersion(), ModuleObj.GetVersion(),
ModuleObj.GetName(), ModuleObj.GetName(),
@ -187,6 +190,9 @@ class DistributionPackageClass(object):
else: else:
raise raise
# Recover WorkspaceDir
WorkspaceDir = Root
## Get all files included for a distribution package, except tool/misc of ## Get all files included for a distribution package, except tool/misc of
# distribution level # distribution level
# #

View File

@ -37,6 +37,7 @@ from Logger import StringTable as ST
from Library.Misc import CreateDirectory from Library.Misc import CreateDirectory
from Library.Misc import RemoveDirectory from Library.Misc import RemoveDirectory
from Core.FileHook import __FileHookOpen__ from Core.FileHook import __FileHookOpen__
from Common.MultipleWorkspace import MultipleWorkspace as mws
class PackageFile: class PackageFile:
@ -203,8 +204,11 @@ class PackageFile:
# @param Files: the files to pack # @param Files: the files to pack
# #
def PackFiles(self, Files): def PackFiles(self, Files):
for File1 in Files: for File in Files:
self.PackFile(File1) Cwd = os.getcwd()
os.chdir(mws.getWs(mws.WORKSPACE, File))
self.PackFile(File)
os.chdir(Cwd)
## Pack the file ## Pack the file
# #

View File

@ -19,6 +19,7 @@ GlobalData
# The workspace directory # The workspace directory
# #
gWORKSPACE = '.' gWORKSPACE = '.'
gPACKAGE_PATH = None
# #
# INF module directory # INF module directory

View File

@ -50,6 +50,7 @@ from Library.ParserValidate import IsValidHexVersion
from Library.ParserValidate import IsValidPath from Library.ParserValidate import IsValidPath
from Object.POM.CommonObject import TextObject from Object.POM.CommonObject import TextObject
from Core.FileHook import __FileHookOpen__ from Core.FileHook import __FileHookOpen__
from CommonDataClass.CommonClass import MultipleWorkspace as mws
## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C ## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C
# structure style # structure style
@ -592,7 +593,11 @@ def GetWorkspace():
if WorkspaceDir[-1] == ':': if WorkspaceDir[-1] == ':':
WorkspaceDir += os.sep WorkspaceDir += os.sep
return WorkspaceDir
PackagesPath = os.environ.get("PACKAGES_PATH")
mws.setWs(WorkspaceDir, PackagesPath)
return WorkspaceDir, mws.PACKAGES_PATH
## Get relative path ## Get relative path
# #

View File

@ -27,6 +27,7 @@ from Library.DataType import TAB_SPACE_SPLIT
from Library.String import GetSplitValueList from Library.String import GetSplitValueList
from Library.ExpressionValidate import IsValidBareCString from Library.ExpressionValidate import IsValidBareCString
from Library.ExpressionValidate import IsValidFeatureFlagExp from Library.ExpressionValidate import IsValidFeatureFlagExp
from CommonDataClass.CommonClass import MultipleWorkspace as mws
## __HexDigit() method ## __HexDigit() method
# #
@ -236,7 +237,7 @@ def IsValidPath(Path, Root):
Path = os.path.normpath(Path).replace('\\', '/') Path = os.path.normpath(Path).replace('\\', '/')
Root = os.path.normpath(Root).replace('\\', '/') Root = os.path.normpath(Root).replace('\\', '/')
FullPath = os.path.normpath(os.path.join(Root, Path)).replace('\\', '/') FullPath = mws.join(Root, Path)
if not os.path.exists(FullPath): if not os.path.exists(FullPath):
return False return False

View File

@ -827,7 +827,9 @@ def GetPkgInfoFromDec(Path):
def GetWorkspacePackage(): def GetWorkspacePackage():
DecFileList = [] DecFileList = []
WorkspaceDir = GlobalData.gWORKSPACE WorkspaceDir = GlobalData.gWORKSPACE
for Root, Dirs, Files in os.walk(WorkspaceDir): PackageDir = GlobalData.gPACKAGE_PATH
for PkgRoot in [WorkspaceDir] + PackageDir:
for Root, Dirs, Files in os.walk(PkgRoot):
if 'CVS' in Dirs: if 'CVS' in Dirs:
Dirs.remove('CVS') Dirs.remove('CVS')
if '.svn' in Dirs: if '.svn' in Dirs:

View File

@ -50,6 +50,7 @@ from Library.ParserValidate import IsValidPath
from Core.DistributionPackageClass import DistributionPackageClass from Core.DistributionPackageClass import DistributionPackageClass
from Core.PackageFile import PackageFile from Core.PackageFile import PackageFile
from Common.MultipleWorkspace import MultipleWorkspace as mws
## CheckForExistingDp ## CheckForExistingDp
# #
@ -136,7 +137,7 @@ def Main(Options = None):
# write(). # write().
# #
FromFile = os.path.normpath(FileObject.GetURI()).encode('utf_8') FromFile = os.path.normpath(FileObject.GetURI()).encode('utf_8')
FileFullPath = os.path.normpath(os.path.join(WorkspaceDir, FromFile)) FileFullPath = mws.join(WorkspaceDir, FromFile)
if FileFullPath in RePkgDict: if FileFullPath in RePkgDict:
(DpGuid, DpVersion, DpName, Repackage) = RePkgDict[FileFullPath] (DpGuid, DpVersion, DpName, Repackage) = RePkgDict[FileFullPath]
if not Repackage: if not Repackage:
@ -264,7 +265,7 @@ def CheckFileList(QualifiedExt, FileList, ErrorStringExt, ErrorStringFullPath):
ErrorStringExt % Item) ErrorStringExt % Item)
Item = os.path.normpath(Item) Item = os.path.normpath(Item)
Path = os.path.normpath(os.path.join(WorkspaceDir, Item)) Path = mws.join(WorkspaceDir, Item)
if not os.path.exists(Path): if not os.path.exists(Path):
Logger.Error("\nMkPkg", FILE_NOT_FOUND, ST.ERR_NOT_FOUND % Item) Logger.Error("\nMkPkg", FILE_NOT_FOUND, ST.ERR_NOT_FOUND % Item)
elif Item == Path: elif Item == Path:

View File

@ -51,7 +51,7 @@ from PomAdapter.InfPomAlignmentMisc import GenModuleHeaderUserExt
from PomAdapter.InfPomAlignmentMisc import GenBinaryData from PomAdapter.InfPomAlignmentMisc import GenBinaryData
from Parser import InfParser from Parser import InfParser
from PomAdapter.DecPomAlignment import DecPomAlignment from PomAdapter.DecPomAlignment import DecPomAlignment
from Common.MultipleWorkspace import MultipleWorkspace as mws
## InfPomAlignment ## InfPomAlignment
# #
@ -534,8 +534,7 @@ class InfPomAlignment(ModuleObject):
PackageDependency.SetSupArchList(ConvertArchList(PackageItemObj.GetSupArchList())) PackageDependency.SetSupArchList(ConvertArchList(PackageItemObj.GetSupArchList()))
PackageDependency.SetFeatureFlag(PackageItemObj.GetFeatureFlagExp()) PackageDependency.SetFeatureFlag(PackageItemObj.GetFeatureFlagExp())
PkgInfo = GetPkgInfoFromDec(os.path.normpath(os.path.join(self.WorkSpace, PkgInfo = GetPkgInfoFromDec(mws.join(self.WorkSpace, NormPath(PackageItemObj.GetPackageName())))
NormPath(PackageItemObj.GetPackageName()))))
if PkgInfo[1] and PkgInfo[2]: if PkgInfo[1] and PkgInfo[2]:
PackageDependency.SetGuid(PkgInfo[1]) PackageDependency.SetGuid(PkgInfo[1])
PackageDependency.SetVersion(PkgInfo[2]) PackageDependency.SetVersion(PkgInfo[2])

View File

@ -39,6 +39,7 @@ from Logger.ToolError import FILE_TYPE_MISMATCH
from Logger.ToolError import OPTION_CONFLICT from Logger.ToolError import OPTION_CONFLICT
from Logger.ToolError import FatalError from Logger.ToolError import FatalError
from Logger.ToolError import UPT_ALREADY_INSTALLED_ERROR from Logger.ToolError import UPT_ALREADY_INSTALLED_ERROR
from Common.MultipleWorkspace import MultipleWorkspace as mws
import MkPkg import MkPkg
import InstallPkg import InstallPkg
@ -164,7 +165,7 @@ def Main():
setattr(Opt, Var[0], Var[1]) setattr(Opt, Var[0], Var[1])
try: try:
GlobalData.gWORKSPACE = GetWorkspace() GlobalData.gWORKSPACE, GlobalData.gPACKAGE_PATH = GetWorkspace()
except FatalError, XExcept: except FatalError, XExcept:
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())