From fb0f8067ea4bfe21b8bc3bd2b2617f5b3d8d87aa Mon Sep 17 00:00:00 2001 From: Hesheng Chen Date: Thu, 8 Oct 2015 09:28:15 +0000 Subject: 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 Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18580 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Python/UPT/Core/DistributionPackageClass.py | 26 +++++++++++++--------- BaseTools/Source/Python/UPT/Core/PackageFile.py | 8 +++++-- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'BaseTools/Source/Python/UPT/Core') diff --git a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py b/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py index bfe6dcc70f..9c55e0ea88 100644 --- a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py +++ b/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py @@ -32,6 +32,7 @@ from Logger.ToolError import EDK1_INF_ERROR from Object.POM.CommonObject import IdentificationObject from Object.POM.CommonObject import CommonHeaderObject from Object.POM.CommonObject import MiscFileObject +from Common.MultipleWorkspace import MultipleWorkspace as mws ## DistributionPackageHeaderClass # @@ -110,14 +111,17 @@ class DistributionPackageClass(object): # @param ModuleList: A list of all modules # def GetDistributionPackage(self, WorkspaceDir, PackageList, ModuleList): + # Backup WorkspaceDir + Root = WorkspaceDir + # # Get Packages # if PackageList: for PackageFile in PackageList: - PackageFileFullPath = \ - os.path.normpath(os.path.join(WorkspaceDir, PackageFile)) - DecObj = DecPomAlignment(PackageFileFullPath, WorkspaceDir, CheckMulDec = True) + PackageFileFullPath = mws.join(Root, PackageFile) + WorkspaceDir = mws.getWs(Root, PackageFile) + DecObj = DecPomAlignment(PackageFileFullPath, WorkspaceDir, CheckMulDec=True) PackageObj = DecObj # # Parser inf file one bye one @@ -140,8 +144,7 @@ class DistributionPackageClass(object): # Inf class in InfPomAlignment. # try: - ModuleObj = InfPomAlignment(Filename, WorkspaceDir, \ - PackageObj.GetPackagePath()) + ModuleObj = InfPomAlignment(Filename, WorkspaceDir, PackageObj.GetPackagePath()) # # Add module to package @@ -168,11 +171,11 @@ class DistributionPackageClass(object): # if ModuleList: for ModuleFile in ModuleList: - ModuleFileFullPath = \ - os.path.normpath(os.path.join(WorkspaceDir, ModuleFile)) + ModuleFileFullPath = mws.join(Root, ModuleFile) + WorkspaceDir = mws.getWs(Root, ModuleFile) + try: - ModuleObj = InfPomAlignment(ModuleFileFullPath, - WorkspaceDir) + ModuleObj = InfPomAlignment(ModuleFileFullPath, WorkspaceDir) ModuleKey = (ModuleObj.GetGuid(), ModuleObj.GetVersion(), ModuleObj.GetName(), @@ -185,7 +188,10 @@ class DistributionPackageClass(object): ST.WRN_EDK1_INF_FOUND%ModuleFileFullPath, ExtraData=ST.ERR_NOT_SUPPORTED_SA_MODULE) else: - raise + raise + + # Recover WorkspaceDir + WorkspaceDir = Root ## Get all files included for a distribution package, except tool/misc of # distribution level diff --git a/BaseTools/Source/Python/UPT/Core/PackageFile.py b/BaseTools/Source/Python/UPT/Core/PackageFile.py index 47ea0bc0a9..5fafd85bff 100644 --- a/BaseTools/Source/Python/UPT/Core/PackageFile.py +++ b/BaseTools/Source/Python/UPT/Core/PackageFile.py @@ -37,6 +37,7 @@ from Logger import StringTable as ST from Library.Misc import CreateDirectory from Library.Misc import RemoveDirectory from Core.FileHook import __FileHookOpen__ +from Common.MultipleWorkspace import MultipleWorkspace as mws class PackageFile: @@ -203,8 +204,11 @@ class PackageFile: # @param Files: the files to pack # def PackFiles(self, Files): - for File1 in Files: - self.PackFile(File1) + for File in Files: + Cwd = os.getcwd() + os.chdir(mws.getWs(mws.WORKSPACE, File)) + self.PackFile(File) + os.chdir(Cwd) ## Pack the file # -- cgit v1.2.3