From 05cc51ad5894c8904d0fe5cdcf3f4d0a07dab85d Mon Sep 17 00:00:00 2001 From: Li YangX Date: Thu, 8 Oct 2015 09:27:14 +0000 Subject: BaseTools: Update Build tool to support multiple workspaces WORKSPACE is still kept. New PACKAGES_PATH is introduced to specify the additional WORKSPACEs. In PACKAGES_PATH, ';' is separator in Windows, ':' is separator in Linux. Build directory is in WORKSPACE. Package, BaseTools and Conf directory will be found from WORKSPACE and PACKAGES_PATH. In implementation, BaseTools adds MultipleWorkspace class for the file path conversion from WORKSPACE and PACKAGES_PATH. Verify two tree layouts. Root\edk2\MdePkg Root\edk2\MdeMdeModulePkg Root\edk2\... 1. set WORKSPACE=Root\edk2 2. set WORKSPACE=Root, and set PACKAGES_PATH=Root\edk2 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Li YangX Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18579 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 7 ++++--- BaseTools/Source/Python/GenFds/GenFds.py | 13 +++++++++---- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 +++- BaseTools/Source/Python/GenFds/Region.py | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) (limited to 'BaseTools/Source/Python/GenFds') diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 29dc75f433..ed767d3fa6 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -28,6 +28,7 @@ import Section import RuleSimpleFile import RuleComplexFile from CommonDataClass.FdfClass import FfsInfStatementClassObject +from Common.MultipleWorkspace import MultipleWorkspace as mws from Common.String import * from Common.Misc import PathClass from Common.Misc import GuidStructureByteArrayToGuidString @@ -365,7 +366,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # self.__InfParse__(Dict) - SrcFile = os.path.join( GenFdsGlobalVariable.WorkSpaceDir , self.InfFileName); + SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir , self.InfFileName); DestFile = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs') SrcFileDir = "." @@ -511,7 +512,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # def __GetPlatformArchList__(self): - InfFileKey = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName)) + InfFileKey = os.path.normpath(mws.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName)) DscArchList = [] PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IA32', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] if PlatformDataBase != None: @@ -878,7 +879,7 @@ class FfsInfStatement(FfsInfStatementClassObject): if not HasGneratedFlag: UniVfrOffsetFileSection = "" - ModuleFileName = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName) + ModuleFileName = mws.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName) InfData = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(ModuleFileName), self.CurrentArch] # # Search the source list in InfData to find if there are .vfr file exist. diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index c2ad4e0e2a..a0beff0391 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -39,6 +39,7 @@ from Common.Misc import SaveFileOnChange from Common.Misc import ClearDuplicatedInf from Common.Misc import GuidStructureStringToGuidString from Common.BuildVersion import gBUILD_VERSION +from Common.MultipleWorkspace import MultipleWorkspace as mws ## Version and Copyright versionNumber = "1.0" + ' ' + gBUILD_VERSION @@ -94,6 +95,10 @@ def main(): if (Options.debug): GenFdsGlobalVariable.VerboseLogger( "Using Workspace:" + Workspace) os.chdir(GenFdsGlobalVariable.WorkSpaceDir) + + # set multiple workspace + PackagesPath = os.getenv("PACKAGES_PATH") + mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath) if (Options.filename): FdfFilename = Options.filename @@ -102,7 +107,7 @@ def main(): if FdfFilename[0:2] == '..': FdfFilename = os.path.realpath(FdfFilename) if not os.path.isabs (FdfFilename): - FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) + FdfFilename = mws.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) if not os.path.exists(FdfFilename): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename) @@ -129,13 +134,13 @@ def main(): ActivePlatform = os.path.realpath(ActivePlatform) if not os.path.isabs (ActivePlatform): - ActivePlatform = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) + ActivePlatform = mws.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) if not os.path.exists(ActivePlatform) : EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") if os.path.normcase (ActivePlatform).find(Workspace) == 0: - ActivePlatform = ActivePlatform[len(Workspace):] + ActivePlatform = mws.relpath(ActivePlatform, Workspace) if len(ActivePlatform) > 0 : if ActivePlatform[0] == '\\' or ActivePlatform[0] == '/': ActivePlatform = ActivePlatform[1:] @@ -159,7 +164,7 @@ def main(): ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) else: # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf - ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf') + ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf') GenFdsGlobalVariable.ConfDir = ConfDirectoryPath BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt")) if os.path.isfile(BuildConfigurationFile) == True: diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 04bbc300ce..5bdc1b8288 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -31,6 +31,7 @@ from AutoGen.BuildEngine import BuildRule import Common.DataType as DataType from Common.Misc import PathClass from Common.LongFilePathSupport import OpenLongFilePath as open +from Common.MultipleWorkspace import MultipleWorkspace as mws ## Global variables # @@ -322,12 +323,13 @@ class GenFdsGlobalVariable: # @param String String that may contain macro # def ReplaceWorkspaceMacro(String): + String = mws.handleWsMacro(String) Str = String.replace('$(WORKSPACE)', GenFdsGlobalVariable.WorkSpaceDir) if os.path.exists(Str): if not os.path.isabs(Str): Str = os.path.abspath(Str) else: - Str = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, String) + Str = mws.join(GenFdsGlobalVariable.WorkSpaceDir, String) return os.path.normpath(Str) ## Check if the input files are newer than output files diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py index 15b2ecba90..feb56cb60f 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -24,6 +24,7 @@ from stat import * from Common import EdkLogger from Common.BuildToolError import * from Common.LongFilePathSupport import OpenLongFilePath as open +from Common.MultipleWorkspace import MultipleWorkspace as mws ## generate Region # @@ -205,7 +206,7 @@ class Region(RegionClassObject): for RegionData in self.RegionDataList: RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict) if RegionData[1] != ':' : - RegionData = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData) + RegionData = mws.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData) if not os.path.exists(RegionData): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData) # -- cgit v1.2.3