summaryrefslogtreecommitdiff
path: root/BaseTools/Source
diff options
context:
space:
mode:
authorHesheng Chen <hesheng.chen@intel.com>2015-10-08 09:28:15 +0000
committerlgao4 <lgao4@Edk2>2015-10-08 09:28:15 +0000
commitfb0f8067ea4bfe21b8bc3bd2b2617f5b3d8d87aa (patch)
tree882a5514c217ca069268fd4cbbece6ad738fcb85 /BaseTools/Source
parent05cc51ad5894c8904d0fe5cdcf3f4d0a07dab85d (diff)
downloadedk2-platforms-fb0f8067ea4bfe21b8bc3bd2b2617f5b3d8d87aa.tar.xz
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
Diffstat (limited to 'BaseTools/Source')
-rw-r--r--BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py26
-rw-r--r--BaseTools/Source/Python/UPT/Core/PackageFile.py8
-rw-r--r--BaseTools/Source/Python/UPT/Library/GlobalData.py3
-rw-r--r--BaseTools/Source/Python/UPT/Library/Misc.py7
-rw-r--r--BaseTools/Source/Python/UPT/Library/ParserValidate.py3
-rw-r--r--BaseTools/Source/Python/UPT/Library/Parsing.py32
-rw-r--r--BaseTools/Source/Python/UPT/MkPkg.py7
-rw-r--r--BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py5
-rw-r--r--BaseTools/Source/Python/UPT/UPT.py3
9 files changed, 57 insertions, 37 deletions
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
#
diff --git a/BaseTools/Source/Python/UPT/Library/GlobalData.py b/BaseTools/Source/Python/UPT/Library/GlobalData.py
index d478983c23..8f446d4888 100644
--- a/BaseTools/Source/Python/UPT/Library/GlobalData.py
+++ b/BaseTools/Source/Python/UPT/Library/GlobalData.py
@@ -19,6 +19,7 @@ GlobalData
# The workspace directory
#
gWORKSPACE = '.'
+gPACKAGE_PATH = None
#
# INF module directory
@@ -107,4 +108,4 @@ gPackageDict = {}
# Used by Library instance parser
# {FilePath: FileObj}
#
-gLIBINSTANCEDICT = {} \ No newline at end of file
+gLIBINSTANCEDICT = {}
diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source/Python/UPT/Library/Misc.py
index bc9e0e172b..df9db2439b 100644
--- a/BaseTools/Source/Python/UPT/Library/Misc.py
+++ b/BaseTools/Source/Python/UPT/Library/Misc.py
@@ -50,6 +50,7 @@ from Library.ParserValidate import IsValidHexVersion
from Library.ParserValidate import IsValidPath
from Object.POM.CommonObject import TextObject
from Core.FileHook import __FileHookOpen__
+from CommonDataClass.CommonClass import MultipleWorkspace as mws
## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C
# structure style
@@ -592,7 +593,11 @@ def GetWorkspace():
if WorkspaceDir[-1] == ':':
WorkspaceDir += os.sep
- return WorkspaceDir
+
+ PackagesPath = os.environ.get("PACKAGES_PATH")
+ mws.setWs(WorkspaceDir, PackagesPath)
+
+ return WorkspaceDir, mws.PACKAGES_PATH
## Get relative path
#
diff --git a/BaseTools/Source/Python/UPT/Library/ParserValidate.py b/BaseTools/Source/Python/UPT/Library/ParserValidate.py
index e973227898..2f4b4d1934 100644
--- a/BaseTools/Source/Python/UPT/Library/ParserValidate.py
+++ b/BaseTools/Source/Python/UPT/Library/ParserValidate.py
@@ -27,6 +27,7 @@ from Library.DataType import TAB_SPACE_SPLIT
from Library.String import GetSplitValueList
from Library.ExpressionValidate import IsValidBareCString
from Library.ExpressionValidate import IsValidFeatureFlagExp
+from CommonDataClass.CommonClass import MultipleWorkspace as mws
## __HexDigit() method
#
@@ -236,7 +237,7 @@ def IsValidPath(Path, Root):
Path = os.path.normpath(Path).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):
return False
diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py b/BaseTools/Source/Python/UPT/Library/Parsing.py
index ace3e0d118..c34e775144 100644
--- a/BaseTools/Source/Python/UPT/Library/Parsing.py
+++ b/BaseTools/Source/Python/UPT/Library/Parsing.py
@@ -827,21 +827,23 @@ def GetPkgInfoFromDec(Path):
def GetWorkspacePackage():
DecFileList = []
WorkspaceDir = GlobalData.gWORKSPACE
- for Root, Dirs, Files in os.walk(WorkspaceDir):
- if 'CVS' in Dirs:
- Dirs.remove('CVS')
- if '.svn' in Dirs:
- Dirs.remove('.svn')
- for Dir in Dirs:
- if Dir.startswith('.'):
- Dirs.remove(Dir)
- for FileSp in Files:
- if FileSp.startswith('.'):
- continue
- Ext = os.path.splitext(FileSp)[1]
- if Ext.lower() in ['.dec']:
- DecFileList.append\
- (os.path.normpath(os.path.join(Root, FileSp)))
+ PackageDir = GlobalData.gPACKAGE_PATH
+ for PkgRoot in [WorkspaceDir] + PackageDir:
+ for Root, Dirs, Files in os.walk(PkgRoot):
+ if 'CVS' in Dirs:
+ Dirs.remove('CVS')
+ if '.svn' in Dirs:
+ Dirs.remove('.svn')
+ for Dir in Dirs:
+ if Dir.startswith('.'):
+ Dirs.remove(Dir)
+ for FileSp in Files:
+ if FileSp.startswith('.'):
+ continue
+ Ext = os.path.splitext(FileSp)[1]
+ if Ext.lower() in ['.dec']:
+ DecFileList.append\
+ (os.path.normpath(os.path.join(Root, FileSp)))
#
# abstract package guid, version info from DecFile List
#
diff --git a/BaseTools/Source/Python/UPT/MkPkg.py b/BaseTools/Source/Python/UPT/MkPkg.py
index 2eb84588bd..87c84f0cc2 100644
--- a/BaseTools/Source/Python/UPT/MkPkg.py
+++ b/BaseTools/Source/Python/UPT/MkPkg.py
@@ -50,6 +50,7 @@ from Library.ParserValidate import IsValidPath
from Core.DistributionPackageClass import DistributionPackageClass
from Core.PackageFile import PackageFile
+from Common.MultipleWorkspace import MultipleWorkspace as mws
## CheckForExistingDp
#
@@ -136,7 +137,7 @@ def Main(Options = None):
# write().
#
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:
(DpGuid, DpVersion, DpName, Repackage) = RePkgDict[FileFullPath]
if not Repackage:
@@ -183,7 +184,7 @@ def Main(Options = None):
DistPkg.Header.RePackage = True
Cwd = getcwd()
- chdir(WorkspaceDir)
+ chdir(WorkspaceDir)
ContentFile.PackFiles(FileList)
chdir(Cwd)
@@ -264,7 +265,7 @@ def CheckFileList(QualifiedExt, FileList, ErrorStringExt, ErrorStringFullPath):
ErrorStringExt % 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):
Logger.Error("\nMkPkg", FILE_NOT_FOUND, ST.ERR_NOT_FOUND % Item)
elif Item == Path:
diff --git a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
index 22e9ef5fc0..a151732853 100644
--- a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
+++ b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
@@ -51,7 +51,7 @@ from PomAdapter.InfPomAlignmentMisc import GenModuleHeaderUserExt
from PomAdapter.InfPomAlignmentMisc import GenBinaryData
from Parser import InfParser
from PomAdapter.DecPomAlignment import DecPomAlignment
-
+from Common.MultipleWorkspace import MultipleWorkspace as mws
## InfPomAlignment
#
@@ -534,8 +534,7 @@ class InfPomAlignment(ModuleObject):
PackageDependency.SetSupArchList(ConvertArchList(PackageItemObj.GetSupArchList()))
PackageDependency.SetFeatureFlag(PackageItemObj.GetFeatureFlagExp())
- PkgInfo = GetPkgInfoFromDec(os.path.normpath(os.path.join(self.WorkSpace,
- NormPath(PackageItemObj.GetPackageName()))))
+ PkgInfo = GetPkgInfoFromDec(mws.join(self.WorkSpace, NormPath(PackageItemObj.GetPackageName())))
if PkgInfo[1] and PkgInfo[2]:
PackageDependency.SetGuid(PkgInfo[1])
PackageDependency.SetVersion(PkgInfo[2])
diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/UPT/UPT.py
index e7b0a8f264..17decda5c3 100644
--- a/BaseTools/Source/Python/UPT/UPT.py
+++ b/BaseTools/Source/Python/UPT/UPT.py
@@ -39,6 +39,7 @@ from Logger.ToolError import FILE_TYPE_MISMATCH
from Logger.ToolError import OPTION_CONFLICT
from Logger.ToolError import FatalError
from Logger.ToolError import UPT_ALREADY_INSTALLED_ERROR
+from Common.MultipleWorkspace import MultipleWorkspace as mws
import MkPkg
import InstallPkg
@@ -164,7 +165,7 @@ def Main():
setattr(Opt, Var[0], Var[1])
try:
- GlobalData.gWORKSPACE = GetWorkspace()
+ GlobalData.gWORKSPACE, GlobalData.gPACKAGE_PATH = GetWorkspace()
except FatalError, XExcept:
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())