Revision: 18580
http://sourceforge.net/p/edk2/code/18580
Author: lgao4
Date: 2015-10-08 09:28:15 +0000 (Thu, 08 Oct 2015)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Modified Paths:
--------------
trunk/edk2/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py
trunk/edk2/BaseTools/Source/Python/UPT/Core/PackageFile.py
trunk/edk2/BaseTools/Source/Python/UPT/Library/GlobalData.py
trunk/edk2/BaseTools/Source/Python/UPT/Library/Misc.py
trunk/edk2/BaseTools/Source/Python/UPT/Library/ParserValidate.py
trunk/edk2/BaseTools/Source/Python/UPT/Library/Parsing.py
trunk/edk2/BaseTools/Source/Python/UPT/MkPkg.py
trunk/edk2/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
trunk/edk2/BaseTools/Source/Python/UPT/UPT.py
Modified:
trunk/edk2/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py
2015-10-08 09:27:14 UTC (rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py
2015-10-08 09:28:15 UTC (rev 18580)
@@ -32,6 +32,7 @@
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 @@
# @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 @@
# 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 @@
#
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,8 +188,11 @@
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
#
Modified: trunk/edk2/BaseTools/Source/Python/UPT/Core/PackageFile.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/Core/PackageFile.py 2015-10-08
09:27:14 UTC (rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/Core/PackageFile.py 2015-10-08
09:28:15 UTC (rev 18580)
@@ -37,6 +37,7 @@
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 @@
# @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
#
Modified: trunk/edk2/BaseTools/Source/Python/UPT/Library/GlobalData.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/Library/GlobalData.py
2015-10-08 09:27:14 UTC (rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/Library/GlobalData.py
2015-10-08 09:28:15 UTC (rev 18580)
@@ -19,6 +19,7 @@
# The workspace directory
#
gWORKSPACE = '.'
+gPACKAGE_PATH = None
#
# INF module directory
@@ -107,4 +108,4 @@
# Used by Library instance parser
# {FilePath: FileObj}
#
-gLIBINSTANCEDICT = {}
\ No newline at end of file
+gLIBINSTANCEDICT = {}
Modified: trunk/edk2/BaseTools/Source/Python/UPT/Library/Misc.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/Library/Misc.py 2015-10-08
09:27:14 UTC (rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/Library/Misc.py 2015-10-08
09:28:15 UTC (rev 18580)
@@ -50,6 +50,7 @@
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,8 +593,12 @@
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
#
# use full path and workspace to get relative path
Modified: trunk/edk2/BaseTools/Source/Python/UPT/Library/ParserValidate.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/Library/ParserValidate.py
2015-10-08 09:27:14 UTC (rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/Library/ParserValidate.py
2015-10-08 09:28:15 UTC (rev 18580)
@@ -27,6 +27,7 @@
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 @@
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
Modified: trunk/edk2/BaseTools/Source/Python/UPT/Library/Parsing.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/Library/Parsing.py 2015-10-08
09:27:14 UTC (rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/Library/Parsing.py 2015-10-08
09:28:15 UTC (rev 18580)
@@ -827,21 +827,23 @@
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
#
Modified: trunk/edk2/BaseTools/Source/Python/UPT/MkPkg.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/MkPkg.py 2015-10-08 09:27:14 UTC
(rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/MkPkg.py 2015-10-08 09:28:15 UTC
(rev 18580)
@@ -50,6 +50,7 @@
from Core.DistributionPackageClass import DistributionPackageClass
from Core.PackageFile import PackageFile
+from Common.MultipleWorkspace import MultipleWorkspace as mws
## CheckForExistingDp
#
@@ -136,7 +137,7 @@
# 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 @@
DistPkg.Header.RePackage = True
Cwd = getcwd()
- chdir(WorkspaceDir)
+ chdir(WorkspaceDir)
ContentFile.PackFiles(FileList)
chdir(Cwd)
@@ -264,7 +265,7 @@
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:
Modified: trunk/edk2/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
2015-10-08 09:27:14 UTC (rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
2015-10-08 09:28:15 UTC (rev 18580)
@@ -51,8 +51,8 @@
from PomAdapter.InfPomAlignmentMisc import GenBinaryData
from Parser import InfParser
from PomAdapter.DecPomAlignment import DecPomAlignment
+from Common.MultipleWorkspace import MultipleWorkspace as mws
-
## InfPomAlignment
#
# Inherit from ModuleObject
@@ -534,8 +534,7 @@
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])
Modified: trunk/edk2/BaseTools/Source/Python/UPT/UPT.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/UPT/UPT.py 2015-10-08 09:27:14 UTC
(rev 18579)
+++ trunk/edk2/BaseTools/Source/Python/UPT/UPT.py 2015-10-08 09:28:15 UTC
(rev 18580)
@@ -39,6 +39,7 @@
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 @@
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())
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits