## @file\r
# This file is used to define each component of Target.txt file\r
#\r
-# Copyright (c) 2007, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
# http://opensource.org/licenses/bsd-license.php\r
##\r
# Import Modules\r
#\r
-import os\r
+import Common.LongFilePathOs as os\r
import EdkLogger\r
import DataType\r
from BuildToolError import *\r
import GlobalData\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
\r
-gDefaultTargetTxtFile = "Conf/target.txt"\r
+gDefaultTargetTxtFile = "target.txt"\r
\r
## TargetTxtClassObject\r
#\r
DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM : '',\r
DataType.TAB_TAT_DEFINES_ACTIVE_MODULE : '',\r
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF : '',\r
- DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD : '',\r
DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER : '',\r
DataType.TAB_TAT_DEFINES_TARGET : [],\r
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG : [],\r
DataType.TAB_TAT_DEFINES_TARGET_ARCH : [],\r
DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF : '',\r
}\r
- if Filename != None:\r
+ self.ConfDirectoryPath = ""\r
+ if Filename is not None:\r
self.LoadTargetTxtFile(Filename)\r
\r
## LoadTargetTxtFile\r
def ConvertTextFileToDict(self, FileName, CommentCharacter, KeySplitCharacter):\r
F = None\r
try:\r
- F = open(FileName,'r')\r
+ F = open(FileName, 'r')\r
+ self.ConfDirectoryPath = os.path.dirname(FileName)\r
except:\r
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=FileName)\r
- if F != None:\r
+ if F is not None:\r
F.close()\r
\r
for Line in F:\r
if Key in [DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM, DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF, \\r
DataType.TAB_TAT_DEFINES_ACTIVE_MODULE, DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF]:\r
self.TargetTxtDictionary[Key] = Value.replace('\\', '/')\r
+ if Key == DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.TargetTxtDictionary[Key]:\r
+ if self.TargetTxtDictionary[Key].startswith("Conf/"):\r
+ Tools_Def = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip())\r
+ if not os.path.exists(Tools_Def) or not os.path.isfile(Tools_Def):\r
+ # If Conf/Conf does not exist, try just the Conf/ directory\r
+ Tools_Def = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].replace("Conf/", "", 1).strip())\r
+ else:\r
+ # The File pointed to by TOOL_CHAIN_CONF is not in a Conf/ directory\r
+ Tools_Def = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip())\r
+ self.TargetTxtDictionary[Key] = Tools_Def\r
+ if Key == DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF and self.TargetTxtDictionary[Key]:\r
+ if self.TargetTxtDictionary[Key].startswith("Conf/"):\r
+ Build_Rule = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip())\r
+ if not os.path.exists(Build_Rule) or not os.path.isfile(Build_Rule):\r
+ # If Conf/Conf does not exist, try just the Conf/ directory\r
+ Build_Rule = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].replace("Conf/", "", 1).strip())\r
+ else:\r
+ # The File pointed to by BUILD_RULE_CONF is not in a Conf/ directory\r
+ Build_Rule = os.path.join(self.ConfDirectoryPath, self.TargetTxtDictionary[Key].strip())\r
+ self.TargetTxtDictionary[Key] = Build_Rule\r
elif Key in [DataType.TAB_TAT_DEFINES_TARGET, DataType.TAB_TAT_DEFINES_TARGET_ARCH, \\r
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]:\r
self.TargetTxtDictionary[Key] = Value.split()\r
- elif Key == DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD:\r
- if Value not in ["Enable", "Disable"]:\r
- EdkLogger.error("build", FORMAT_INVALID, "Invalid setting of [%s]: %s." % (Key, Value),\r
- ExtraData="\tSetting must be one of [Enable, Disable]",\r
- File=FileName)\r
- self.TargetTxtDictionary[Key] = Value\r
elif Key == DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER:\r
try:\r
V = int(Value, 0)\r
F.close()\r
return 0\r
\r
- ## Print the dictionary\r
- #\r
- # Print all items of dictionary one by one\r
- #\r
- # @param Dict: The dictionary to be printed\r
- #\r
- def printDict(Dict):\r
- if Dict != None:\r
- KeyList = Dict.keys()\r
- for Key in KeyList:\r
- if Dict[Key] != '':\r
- print Key + ' = ' + str(Dict[Key])\r
-\r
- ## Print the dictionary\r
- #\r
- # Print the items of dictionary which matched with input key\r
- #\r
- # @param list: The dictionary to be printed\r
- # @param key: The key of the item to be printed\r
- #\r
- def printList(Key, List):\r
- if type(List) == type([]):\r
- if len(List) > 0:\r
- if Key.find(TAB_SPLIT) != -1:\r
- print "\n" + Key\r
- for Item in List:\r
- print Item\r
## TargetTxtDict\r
#\r
-# Load target.txt in input workspace dir\r
+# Load target.txt in input Conf dir\r
#\r
-# @param WorkSpace: Workspace dir\r
+# @param ConfDir: Conf dir\r
#\r
# @retval Target An instance of TargetTxtClassObject() with loaded target.txt\r
#\r
-def TargetTxtDict(WorkSpace):\r
+def TargetTxtDict(ConfDir):\r
Target = TargetTxtClassObject()\r
- Target.LoadTargetTxtFile(os.path.normpath(os.path.join(WorkSpace, gDefaultTargetTxtFile)))\r
+ Target.LoadTargetTxtFile(os.path.normpath(os.path.join(ConfDir, gDefaultTargetTxtFile)))\r
return Target\r
\r
##\r