# build a platform or a module\r
#\r
# Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
-# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>\r
# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
# Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
#\r
except:\r
return False, UNKNOWN_ERROR\r
\r
+ ## Add TOOLCHAIN and FAMILY declared in DSC [BuildOptions] to ToolsDefTxtDatabase.\r
+ #\r
+ # Loop through the set of build targets, tool chains, and archs provided on either\r
+ # the command line or in target.txt to discover FAMILY and TOOLCHAIN delclarations\r
+ # in [BuildOptions] sections that may be within !if expressions that may use\r
+ # $(TARGET), $(TOOLCHAIN), $(TOOLCHAIN_TAG), or $(ARCH) operands.\r
+ #\r
+ def GetToolChainAndFamilyFromDsc (self, File):\r
+ for BuildTarget in self.BuildTargetList:\r
+ GlobalData.gGlobalDefines['TARGET'] = BuildTarget\r
+ for BuildToolChain in self.ToolChainList:\r
+ GlobalData.gGlobalDefines['TOOLCHAIN'] = BuildToolChain\r
+ GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = BuildToolChain\r
+ for BuildArch in self.ArchList:\r
+ GlobalData.gGlobalDefines['ARCH'] = BuildArch\r
+ dscobj = self.BuildDatabase[File, BuildArch]\r
+ for KeyFamily, Key, KeyCodeBase in dscobj.BuildOptions:\r
+ try:\r
+ Target, ToolChain, Arch, Tool, Attr = Key.split('_')\r
+ except:\r
+ continue\r
+ if ToolChain == TAB_STAR or Attr != TAB_TOD_DEFINES_FAMILY:\r
+ continue\r
+ try:\r
+ Family = dscobj.BuildOptions[(KeyFamily, Key, KeyCodeBase)]\r
+ Family = Family.strip().strip('=').strip()\r
+ except:\r
+ continue\r
+ if TAB_TOD_DEFINES_FAMILY not in self.ToolDef.ToolsDefTxtDatabase:\r
+ self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY] = {}\r
+ if ToolChain not in self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY]:\r
+ self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][ToolChain] = Family\r
+ if TAB_TOD_DEFINES_BUILDRULEFAMILY not in self.ToolDef.ToolsDefTxtDatabase:\r
+ self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY] = {}\r
+ if ToolChain not in self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY]:\r
+ self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMILY][ToolChain] = Family\r
+ if TAB_TOD_DEFINES_TOOL_CHAIN_TAG not in self.ToolDef.ToolsDefTxtDatabase:\r
+ self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG] = []\r
+ if ToolChain not in self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG]:\r
+ self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG].append(ToolChain)\r
+\r
## Load configuration\r
#\r
# This method will parse target.txt and get the build configurations.\r
if self.ToolChainList is None or len(self.ToolChainList) == 0:\r
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.\n")\r
\r
+ if not self.PlatformFile:\r
+ PlatformFile = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_ACTIVE_PLATFORM]\r
+ if not PlatformFile:\r
+ # Try to find one in current directory\r
+ WorkingDirectory = os.getcwd()\r
+ FileList = glob.glob(os.path.normpath(os.path.join(WorkingDirectory, '*.dsc')))\r
+ FileNum = len(FileList)\r
+ if FileNum >= 2:\r
+ EdkLogger.error("build", OPTION_MISSING,\r
+ ExtraData="There are %d DSC files in %s. Use '-p' to specify one.\n" % (FileNum, WorkingDirectory))\r
+ elif FileNum == 1:\r
+ PlatformFile = FileList[0]\r
+ else:\r
+ EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,\r
+ ExtraData="No active platform specified in target.txt or command line! Nothing can be built.\n")\r
+\r
+ self.PlatformFile = PathClass(NormFile(PlatformFile, self.WorkspaceDir), self.WorkspaceDir)\r
+\r
+ self.GetToolChainAndFamilyFromDsc (self.PlatformFile)\r
+\r
# check if the tool chains are defined or not\r
NewToolChainList = []\r
for ToolChain in self.ToolChainList:\r
ToolChainFamily.append(ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool])\r
self.ToolChainFamily = ToolChainFamily\r
\r
- if not self.PlatformFile:\r
- PlatformFile = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_ACTIVE_PLATFORM]\r
- if not PlatformFile:\r
- # Try to find one in current directory\r
- WorkingDirectory = os.getcwd()\r
- FileList = glob.glob(os.path.normpath(os.path.join(WorkingDirectory, '*.dsc')))\r
- FileNum = len(FileList)\r
- if FileNum >= 2:\r
- EdkLogger.error("build", OPTION_MISSING,\r
- ExtraData="There are %d DSC files in %s. Use '-p' to specify one.\n" % (FileNum, WorkingDirectory))\r
- elif FileNum == 1:\r
- PlatformFile = FileList[0]\r
- else:\r
- EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,\r
- ExtraData="No active platform specified in target.txt or command line! Nothing can be built.\n")\r
-\r
- self.PlatformFile = PathClass(NormFile(PlatformFile, self.WorkspaceDir), self.WorkspaceDir)\r
self.ThreadNumber = ThreadNum()\r
## Initialize build configuration\r
#\r
continue\r
\r
for Arch in self.ArchList:\r
- # Build up the list of supported architectures for this build\r
- prefix = '%s_%s_%s_' % (BuildTarget, ToolChain, Arch)\r
-\r
# Look through the tool definitions for GUIDed tools\r
guidAttribs = []\r
for (attrib, value) in self.ToolDef.ToolsDefTxtDictionary.items():\r
- if attrib.upper().endswith('_GUID'):\r
- split = attrib.split('_')\r
- thisPrefix = '_'.join(split[0:3]) + '_'\r
- if thisPrefix == prefix:\r
- guid = self.ToolDef.ToolsDefTxtDictionary[attrib]\r
- guid = guid.lower()\r
- toolName = split[3]\r
- path = '_'.join(split[0:4]) + '_PATH'\r
- path = self.ToolDef.ToolsDefTxtDictionary[path]\r
- path = self.GetRealPathOfTool(path)\r
- guidAttribs.append((guid, toolName, path))\r
-\r
+ GuidBuildTarget, GuidToolChain, GuidArch, GuidTool, GuidAttr = attrib.split('_')\r
+ if GuidAttr.upper() == 'GUID':\r
+ if GuidBuildTarget == TAB_STAR:\r
+ GuidBuildTarget = BuildTarget\r
+ if GuidToolChain == TAB_STAR:\r
+ GuidToolChain = ToolChain\r
+ if GuidArch == TAB_STAR:\r
+ GuidArch = Arch\r
+ if GuidBuildTarget == BuildTarget and GuidToolChain == ToolChain and GuidArch == Arch:\r
+ path = '_'.join(attrib.split('_')[:-1]) + '_PATH'\r
+ if path in self.ToolDef.ToolsDefTxtDictionary:\r
+ path = self.ToolDef.ToolsDefTxtDictionary[path]\r
+ path = self.GetRealPathOfTool(path)\r
+ guidAttribs.append((value.lower(), GuidTool, path))\r
+ # Sort by GuidTool name\r
+ sorted (guidAttribs, key=lambda x: x[1])\r
# Write out GuidedSecTools.txt\r
toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt')\r
toolsFile = open(toolsFile, 'wt')\r