From 97fa0ee9b1cffbb4b97ee35365afa7afcf50e174 Mon Sep 17 00:00:00 2001 From: Yingke Liu Date: Thu, 28 Aug 2014 13:53:34 +0000 Subject: License header updated to match correct format. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yingke Liu Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15971 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Source/Python/Common/TargetTxtClassObject.py | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'BaseTools/Source/Python/Common/TargetTxtClassObject.py') diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py index 89e3937086..387e515230 100644 --- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py +++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py @@ -21,7 +21,7 @@ from BuildToolError import * import GlobalData from Common.LongFilePathSupport import OpenLongFilePath as open -gDefaultTargetTxtFile = "Conf/target.txt" +gDefaultTargetTxtFile = "target.txt" ## TargetTxtClassObject # @@ -44,6 +44,7 @@ class TargetTxtClassObject(object): DataType.TAB_TAT_DEFINES_TARGET_ARCH : [], DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF : '', } + self.ConfDirectoryPath = "" if Filename != None: self.LoadTargetTxtFile(Filename) @@ -78,7 +79,8 @@ class TargetTxtClassObject(object): def ConvertTextFileToDict(self, FileName, CommentCharacter, KeySplitCharacter): F = None try: - F = open(FileName,'r') + F = open(FileName, 'r') + self.ConfDirectoryPath = os.path.dirname(FileName) except: EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=FileName) if F != None: @@ -99,6 +101,26 @@ class TargetTxtClassObject(object): if Key in [DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM, DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF, \ DataType.TAB_TAT_DEFINES_ACTIVE_MODULE, DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF]: self.TargetTxtDictionary[Key] = Value.replace('\\', '/') + if Key == DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.TargetTxtDictionary[Key]: + if self.TargetTxtDictionary[Key].startswith("Conf/"): + Tools_Def = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip()) + if not os.path.exists(Tools_Def) or not os.path.isfile(Tools_Def): + # If Conf/Conf does not exist, try just the Conf/ directory + Tools_Def = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].replace("Conf/", "", 1).strip()) + else: + # The File pointed to by TOOL_CHAIN_CONF is not in a Conf/ directory + Tools_Def = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip()) + self.TargetTxtDictionary[Key] = Tools_Def + if Key == DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF and self.TargetTxtDictionary[Key]: + if self.TargetTxtDictionary[Key].startswith("Conf/"): + Build_Rule = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip()) + if not os.path.exists(Build_Rule) or not os.path.isfile(Build_Rule): + # If Conf/Conf does not exist, try just the Conf/ directory + Build_Rule = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].replace("Conf/", "", 1).strip()) + else: + # The File pointed to by BUILD_RULE_CONF is not in a Conf/ directory + Build_Rule = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip()) + self.TargetTxtDictionary[Key] = Build_Rule elif Key in [DataType.TAB_TAT_DEFINES_TARGET, DataType.TAB_TAT_DEFINES_TARGET_ARCH, \ DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]: self.TargetTxtDictionary[Key] = Value.split() @@ -144,15 +166,15 @@ class TargetTxtClassObject(object): print Item ## TargetTxtDict # -# Load target.txt in input workspace dir +# Load target.txt in input Conf dir # -# @param WorkSpace: Workspace dir +# @param ConfDir: Conf dir # # @retval Target An instance of TargetTxtClassObject() with loaded target.txt # -def TargetTxtDict(WorkSpace): +def TargetTxtDict(ConfDir): Target = TargetTxtClassObject() - Target.LoadTargetTxtFile(os.path.normpath(os.path.join(WorkSpace, gDefaultTargetTxtFile))) + Target.LoadTargetTxtFile(os.path.normpath(os.path.join(ConfDir, gDefaultTargetTxtFile))) return Target ## -- cgit v1.2.3