Reviewed-by: Liming Gao <[email protected]> > -----Original Message----- > From: Zhu, Yonghong > Sent: Wednesday, May 11, 2016 9:17 AM > To: [email protected] > Cc: Gao, Liming <[email protected]> > Subject: [Patch] BaseTools/GenFds: enhance to get TOOL_CHAIN_TAG and > TARGET value > > when user don't set TOOL_CHAIN_TAG and TARGET by –D Flag, then GenFds > would report failure for format: > FILE DATA = > $(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/testfile > so this patch enhance to get the TOOL_CHAIN_TAG and TARGET value by > following priority (high to low): 1. the Macro value set by -D Flag; > 2. Get the value by the -t/-b option. 3. get the value from target.txt > file. Besides, this patch also remove the error checking for missing > -t/-b option. > > Cc: Liming Gao <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Yonghong Zhu <[email protected]> > --- > BaseTools/Source/Python/GenFds/GenFds.py | 32 > +++++++++++++++++++++++++++----- > 1 file changed, 27 insertions(+), 5 deletions(-) > > diff --git a/BaseTools/Source/Python/GenFds/GenFds.py > b/BaseTools/Source/Python/GenFds/GenFds.py > index 672d103..68232c5 100644 > --- a/BaseTools/Source/Python/GenFds/GenFds.py > +++ b/BaseTools/Source/Python/GenFds/GenFds.py > @@ -117,17 +117,13 @@ def main(): > else: > EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filename") > > if (Options.BuildTarget): > GenFdsGlobalVariable.TargetName = Options.BuildTarget > - else: > - EdkLogger.error("GenFds", OPTION_MISSING, "Missing build target") > > if (Options.ToolChain): > GenFdsGlobalVariable.ToolChainTag = Options.ToolChain > - else: > - EdkLogger.error("GenFds", OPTION_MISSING, "Missing tool chain > tag") > > if (Options.activePlatform): > ActivePlatform = Options.activePlatform > ActivePlatform = > GenFdsGlobalVariable.ReplaceWorkspaceMacro(ActivePlatform) > > @@ -159,11 +155,27 @@ def main(): > # Get standard WORKSPACE/Conf, use the absolute path to the > WORKSPACE/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: > - TargetTxtClassObject.TargetTxtClassObject(BuildConfigurationFile) > + TargetTxt = TargetTxtClassObject.TargetTxtClassObject() > + TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) > + # if no build target given in command line, get it from > target.txt > + if not GenFdsGlobalVariable.TargetName: > + BuildTargetList = > TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET] > + if len(BuildTargetList) != 1: > + EdkLogger.error("GenFds", OPTION_VALUE_INVALID, > ExtraData="Only allows one instance for Target.") > + GenFdsGlobalVariable.TargetName = BuildTargetList[0] > + > + # if no tool chain given in command line, get it from target.txt > + if not GenFdsGlobalVariable.ToolChainTag: > + ToolChainList = > TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_T > AG] > + if ToolChainList == None or len(ToolChainList) == 0: > + EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE, > ExtraData="No toolchain given. Don't know how to build.") > + if len(ToolChainList) != 1: > + EdkLogger.error("GenFds", OPTION_VALUE_INVALID, > ExtraData="Only allows one instance for ToolChain.") > + GenFdsGlobalVariable.ToolChainTag = ToolChainList[0] > else: > EdkLogger.error("GenFds", FILE_NOT_FOUND, > ExtraData=BuildConfigurationFile) > > #Set global flag for build mode > GlobalData.gIgnoreSource = Options.IgnoreSources > @@ -174,10 +186,12 @@ def main(): > Pair = Pair[1:] > if Pair.endswith('"'): > Pair = Pair[:-1] > List = Pair.split('=') > if len(List) == 2: > + if not List[1].strip(): > + EdkLogger.error("GenFds", OPTION_VALUE_INVALID, > ExtraData="No Value given for Macro %s" %List[0]) > if List[0].strip() == "EFI_SOURCE": > GlobalData.gEfiSource = List[1].strip() > GlobalData.gGlobalDefines["EFI_SOURCE"] = > GlobalData.gEfiSource > continue > elif List[0].strip() == "EDK_SOURCE": > @@ -190,10 +204,18 @@ def main(): > GlobalData.gCommandLineDefines[List[0].strip()] = > List[1].strip() > else: > GlobalData.gCommandLineDefines[List[0].strip()] = "TRUE" > os.environ["WORKSPACE"] = Workspace > > + # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET > if they are not defined > + if "TARGET" not in GlobalData.gGlobalDefines.keys(): > + GlobalData.gGlobalDefines["TARGET"] = > GenFdsGlobalVariable.TargetName > + if "TOOLCHAIN" not in GlobalData.gGlobalDefines.keys(): > + GlobalData.gGlobalDefines["TOOLCHAIN"] = > GenFdsGlobalVariable.ToolChainTag > + if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines.keys(): > + GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = > GenFdsGlobalVariable.ToolChainTag > + > """call Workspace build create database""" > GlobalData.gDatabasePath = > os.path.normpath(os.path.join(ConfDirectoryPath, > GlobalData.gDatabasePath)) > BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath) > BuildWorkSpace.InitDatabase() > > -- > 2.6.1.windows.1
_______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

