from BuildToolError import *\r
from TargetTxtClassObject import *\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
+from Common.Misc import PathClass\r
+from Common.String import NormPath\r
+import Common.GlobalData as GlobalData\r
+from Common import GlobalData\r
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
\r
##\r
# Static variables used for pattern\r
# @param Filename: Input value for full path of tools_def.txt\r
#\r
def LoadToolDefFile(self, FileName):\r
+ # set multiple workspace\r
+ PackagesPath = os.getenv("PACKAGES_PATH")\r
+ mws.setWs(GlobalData.gWorkspace, PackagesPath)\r
+\r
+ self.ToolsDefTxtDatabase = {\r
+ TAB_TOD_DEFINES_TARGET : [],\r
+ TAB_TOD_DEFINES_TOOL_CHAIN_TAG : [],\r
+ TAB_TOD_DEFINES_TARGET_ARCH : [],\r
+ TAB_TOD_DEFINES_COMMAND_TYPE : []\r
+ }\r
+\r
+ self.IncludeToolDefFile(FileName)\r
+\r
+\r
+ ## IncludeToolDefFile\r
+ #\r
+ # Load target.txt file and parse it as if it's contents were inside the main file\r
+ #\r
+ # @param Filename: Input value for full path of tools_def.txt\r
+ #\r
+ def IncludeToolDefFile(self, FileName):\r
FileContent = []\r
if os.path.isfile(FileName):\r
try:\r
else:\r
EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND, ExtraData=FileName)\r
\r
- self.ToolsDefTxtDatabase = {\r
- TAB_TOD_DEFINES_TARGET : [],\r
- TAB_TOD_DEFINES_TOOL_CHAIN_TAG : [],\r
- TAB_TOD_DEFINES_TARGET_ARCH : [],\r
- TAB_TOD_DEFINES_COMMAND_TYPE : []\r
- }\r
-\r
for Index in range(len(FileContent)):\r
Line = FileContent[Index].strip()\r
if Line == "" or Line[0] == '#':\r
continue\r
+\r
+ if Line.startswith("!include"):\r
+ IncFile = Line[8:].strip()\r
+ Done, IncFile = self.ExpandMacros(IncFile)\r
+ if not Done:\r
+ EdkLogger.error("tools_def.txt parser", ATTRIBUTE_NOT_AVAILABLE,\r
+ "Macro or Environment has not been defined",\r
+ ExtraData=IncFile[4:-1], File=FileName, Line=Index+1)\r
+ IncFile = NormPath(IncFile)\r
+\r
+ if not os.path.isabs(IncFile):\r
+ #\r
+ # try WORKSPACE\r
+ #\r
+ IncFileTmp = PathClass(IncFile, GlobalData.gWorkspace)\r
+ ErrorCode = IncFileTmp.Validate()[0]\r
+ if ErrorCode != 0:\r
+ #\r
+ # try PACKAGES_PATH\r
+ #\r
+ IncFileTmp = mws.join(GlobalData.gWorkspace, IncFile)\r
+ if not os.path.exists(IncFileTmp):\r
+ #\r
+ # try directory of current file\r
+ #\r
+ IncFileTmp = PathClass(IncFile, os.path.dirname(FileName))\r
+ ErrorCode = IncFileTmp.Validate()[0]\r
+ if ErrorCode != 0:\r
+ EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND, ExtraData=IncFile)\r
+\r
+ if type(IncFileTmp) is PathClass:\r
+ IncFile = IncFileTmp.Path\r
+ else:\r
+ IncFile = IncFileTmp\r
+\r
+ self.IncludeToolDefFile(IncFile)\r
+ continue\r
+\r
NameValuePair = Line.split("=", 1)\r
if len(NameValuePair) != 2:\r
EdkLogger.warn("tools_def.txt parser", "Line %d: not correct assignment statement, skipped" % (Index + 1))\r