from Common.Misc import tdict, PathClass\r
from Common.StringUtils import NormPath\r
from Common.DataType import *\r
-from Common.TargetTxtClassObject import TargetTxt\r
+from Common.TargetTxtClassObject import TargetTxtDict\r
gDefaultBuildRuleFile = 'build_rule.txt'\r
AutoGenReqBuildRuleVerNum = '0.1'\r
\r
_UnknownSection : SkipSection,\r
}\r
\r
-def GetBuildRule():\r
- BuildRuleFile = None\r
- if TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:\r
- BuildRuleFile = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]\r
- if not BuildRuleFile:\r
- BuildRuleFile = gDefaultBuildRuleFile\r
- RetVal = BuildRule(BuildRuleFile)\r
- if RetVal._FileVersion == "":\r
- RetVal._FileVersion = AutoGenReqBuildRuleVerNum\r
- else:\r
- if RetVal._FileVersion < AutoGenReqBuildRuleVerNum :\r
- # If Build Rule's version is less than the version number required by the tools, halting the build.\r
- EdkLogger.error("build", AUTOGEN_ERROR,\r
- ExtraData="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\\r
- % (RetVal._FileVersion, AutoGenReqBuildRuleVerNum))\r
- return RetVal\r
-\r
-BuildRuleObj = GetBuildRule()\r
+class ToolBuildRule():\r
+\r
+ def __new__(cls, *args, **kw):\r
+ if not hasattr(cls, '_instance'):\r
+ orig = super(ToolBuildRule, cls)\r
+ cls._instance = orig.__new__(cls, *args, **kw)\r
+ return cls._instance\r
+\r
+ def __init__(self):\r
+ if not hasattr(self, 'ToolBuildRule'):\r
+ self._ToolBuildRule = None\r
+\r
+ @property\r
+ def ToolBuildRule(self):\r
+ if not self._ToolBuildRule:\r
+ self._GetBuildRule()\r
+ return self._ToolBuildRule\r
+\r
+ def _GetBuildRule(self):\r
+ BuildRuleFile = None\r
+ TargetObj = TargetTxtDict()\r
+ TargetTxt = TargetObj.Target\r
+ if TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:\r
+ BuildRuleFile = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]\r
+ if not BuildRuleFile:\r
+ BuildRuleFile = gDefaultBuildRuleFile\r
+ RetVal = BuildRule(BuildRuleFile)\r
+ if RetVal._FileVersion == "":\r
+ RetVal._FileVersion = AutoGenReqBuildRuleVerNum\r
+ else:\r
+ if RetVal._FileVersion < AutoGenReqBuildRuleVerNum :\r
+ # If Build Rule's version is less than the version number required by the tools, halting the build.\r
+ EdkLogger.error("build", AUTOGEN_ERROR,\r
+ ExtraData="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\\r
+ % (RetVal._FileVersion, AutoGenReqBuildRuleVerNum))\r
+ self._ToolBuildRule = RetVal\r
\r
# This acts like the main() function for the script, unless it is 'import'ed into another\r
# script.\r
# The Conf dir outside the workspace dir\r
#\r
gConfDirectory = ''\r
-\r
+gCmdConfDir = ''\r
gBuildDirectory = ''\r
#\r
# The relative default database file path\r
#\r
from __future__ import print_function\r
from __future__ import absolute_import\r
-from Common.buildoptions import BuildOption,BuildTarget\r
+\r
import Common.GlobalData as GlobalData\r
import Common.LongFilePathOs as os\r
from . import EdkLogger\r
#\r
# @retval Target An instance of TargetTxtClassObject() with loaded target.txt\r
#\r
-def TargetTxtDict():\r
- Target = TargetTxtClassObject()\r
- if BuildOption.ConfDirectory:\r
- # Get alternate Conf location, if it is absolute, then just use the absolute directory name\r
- ConfDirectoryPath = os.path.normpath(BuildOption.ConfDirectory)\r
-\r
- if not os.path.isabs(ConfDirectoryPath):\r
- # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE\r
- # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf\r
- ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], ConfDirectoryPath)\r
- else:\r
- if "CONF_PATH" in os.environ:\r
- ConfDirectoryPath = os.path.normcase(os.path.normpath(os.environ["CONF_PATH"]))\r
+\r
+class TargetTxtDict():\r
+\r
+ def __new__(cls, *args, **kw):\r
+ if not hasattr(cls, '_instance'):\r
+ orig = super(TargetTxtDict, cls)\r
+ cls._instance = orig.__new__(cls, *args, **kw)\r
+ return cls._instance\r
+\r
+ def __init__(self):\r
+ if not hasattr(self, 'Target'):\r
+ self.TxtTarget = None\r
+\r
+ @property\r
+ def Target(self):\r
+ if not self.TxtTarget:\r
+ self._GetTarget()\r
+ return self.TxtTarget\r
+\r
+ def _GetTarget(self):\r
+ Target = TargetTxtClassObject()\r
+ ConfDirectory = GlobalData.gCmdConfDir\r
+ if ConfDirectory:\r
+ # Get alternate Conf location, if it is absolute, then just use the absolute directory name\r
+ ConfDirectoryPath = os.path.normpath(ConfDirectory)\r
+\r
+ if not os.path.isabs(ConfDirectoryPath):\r
+ # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE\r
+ # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf\r
+ ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], ConfDirectoryPath)\r
else:\r
- # Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf\r
- ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 'Conf')\r
- GlobalData.gConfDirectory = ConfDirectoryPath\r
- targettxt = os.path.normpath(os.path.join(ConfDirectoryPath, gDefaultTargetTxtFile))\r
- if os.path.exists(targettxt):\r
- Target.LoadTargetTxtFile(targettxt)\r
- return Target\r
-\r
-TargetTxt = TargetTxtDict()\r
+ if "CONF_PATH" in os.environ:\r
+ ConfDirectoryPath = os.path.normcase(os.path.normpath(os.environ["CONF_PATH"]))\r
+ else:\r
+ # Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf\r
+ ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 'Conf')\r
+ GlobalData.gConfDirectory = ConfDirectoryPath\r
+ targettxt = os.path.normpath(os.path.join(ConfDirectoryPath, gDefaultTargetTxtFile))\r
+ if os.path.exists(targettxt):\r
+ Target.LoadTargetTxtFile(targettxt)\r
+ self.TxtTarget = Target\r
\r
##\r
#\r
from . import EdkLogger\r
\r
from .BuildToolError import *\r
-from Common.TargetTxtClassObject import TargetTxt\r
+from Common.TargetTxtClassObject import TargetTxtDict\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
from Common.Misc import PathClass\r
from Common.StringUtils import NormPath\r
#\r
# @retval ToolDef An instance of ToolDefClassObject() with loaded tools_def.txt\r
#\r
-def ToolDefDict(ConfDir):\r
- Target = TargetTxt\r
- ToolDef = ToolDefClassObject()\r
- if TAB_TAT_DEFINES_TOOL_CHAIN_CONF in Target.TargetTxtDictionary:\r
- ToolsDefFile = Target.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
- if ToolsDefFile:\r
- ToolDef.LoadToolDefFile(os.path.normpath(ToolsDefFile))\r
- else:\r
- ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(ConfDir, gDefaultToolsDefFile)))\r
- else:\r
- ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(ConfDir, gDefaultToolsDefFile)))\r
- return ToolDef\r
\r
-ToolDef = ToolDefDict((os.path.join(os.getenv("WORKSPACE"),"Conf")))\r
+\r
+class ToolDefDict():\r
+\r
+ def __new__(cls, ConfDir, *args, **kw):\r
+ if not hasattr(cls, '_instance'):\r
+ orig = super(ToolDefDict, cls)\r
+ cls._instance = orig.__new__(cls, *args, **kw)\r
+ return cls._instance\r
+\r
+ def __init__(self, ConfDir):\r
+ self.ConfDir = ConfDir\r
+ if not hasattr(self, 'ToolDef'):\r
+ self._ToolDef = None\r
+\r
+ @property\r
+ def ToolDef(self):\r
+ if not self._ToolDef:\r
+ self._GetToolDef()\r
+ return self._ToolDef\r
+\r
+ def _GetToolDef(self):\r
+ TargetObj = TargetTxtDict()\r
+ Target = TargetObj.Target\r
+ ToolDef = ToolDefClassObject()\r
+ if TAB_TAT_DEFINES_TOOL_CHAIN_CONF in Target.TargetTxtDictionary:\r
+ ToolsDefFile = Target.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
+ if ToolsDefFile:\r
+ ToolDef.LoadToolDefFile(os.path.normpath(ToolsDefFile))\r
+ else:\r
+ ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(self.ConfDir, gDefaultToolsDefFile)))\r
+ else:\r
+ ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(self.ConfDir, gDefaultToolsDefFile)))\r
+ self._ToolDef = ToolDef\r
\r
##\r
#\r
+++ /dev/null
-## @file\r
-# build a platform or a module\r
-#\r
-# Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
-# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
-# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-\r
-# Version and Copyright\r
-from Common.BuildVersion import gBUILD_VERSION\r
-from optparse import OptionParser\r
-VersionNumber = "0.60" + ' ' + gBUILD_VERSION\r
-__version__ = "%prog Version " + VersionNumber\r
-__copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation All rights reserved."\r
-\r
-gParamCheck = []\r
-def SingleCheckCallback(option, opt_str, value, parser):\r
- if option not in gParamCheck:\r
- setattr(parser.values, option.dest, value)\r
- gParamCheck.append(option)\r
- else:\r
- parser.error("Option %s only allows one instance in command line!" % option)\r
-\r
-def MyOptionParser():\r
- Parser = OptionParser(description=__copyright__, version=__version__, prog="build.exe", usage="%prog [options] [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]")\r
- Parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32', 'X64', 'EBC', 'ARM', 'AARCH64'], dest="TargetArch",\r
- help="ARCHS is one of list: IA32, X64, ARM, AARCH64 or EBC, which overrides target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option.")\r
- Parser.add_option("-p", "--platform", action="callback", type="string", dest="PlatformFile", callback=SingleCheckCallback,\r
- help="Build the platform specified by the DSC file name argument, overriding target.txt's ACTIVE_PLATFORM definition.")\r
- Parser.add_option("-m", "--module", action="callback", type="string", dest="ModuleFile", callback=SingleCheckCallback,\r
- help="Build the module specified by the INF file name argument.")\r
- Parser.add_option("-b", "--buildtarget", type="string", dest="BuildTarget", help="Using the TARGET to build the platform, overriding target.txt's TARGET definition.",\r
- action="append")\r
- Parser.add_option("-t", "--tagname", action="append", type="string", dest="ToolChain",\r
- help="Using the Tool Chain Tagname to build the platform, overriding target.txt's TOOL_CHAIN_TAG definition.")\r
- Parser.add_option("-x", "--sku-id", action="callback", type="string", dest="SkuId", callback=SingleCheckCallback,\r
- help="Using this name of SKU ID to build the platform, overriding SKUID_IDENTIFIER in DSC file.")\r
-\r
- Parser.add_option("-n", action="callback", type="int", dest="ThreadNumber", callback=SingleCheckCallback,\r
- help="Build the platform using multi-threaded compiler. The value overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. When value is set to 0, tool automatically detect number of "\\r
- "processor threads, set value to 1 means disable multi-thread build, and set value to more than 1 means user specify the threads number to build.")\r
-\r
- Parser.add_option("-f", "--fdf", action="callback", type="string", dest="FdfFile", callback=SingleCheckCallback,\r
- help="The name of the FDF file to use, which overrides the setting in the DSC file.")\r
- Parser.add_option("-r", "--rom-image", action="append", type="string", dest="RomImage", default=[],\r
- help="The name of FD to be generated. The name must be from [FD] section in FDF file.")\r
- Parser.add_option("-i", "--fv-image", action="append", type="string", dest="FvImage", default=[],\r
- help="The name of FV to be generated. The name must be from [FV] section in FDF file.")\r
- Parser.add_option("-C", "--capsule-image", action="append", type="string", dest="CapName", default=[],\r
- help="The name of Capsule to be generated. The name must be from [Capsule] section in FDF file.")\r
- Parser.add_option("-u", "--skip-autogen", action="store_true", dest="SkipAutoGen", help="Skip AutoGen step.")\r
- Parser.add_option("-e", "--re-parse", action="store_true", dest="Reparse", help="Re-parse all meta-data files.")\r
-\r
- Parser.add_option("-c", "--case-insensitive", action="store_true", dest="CaseInsensitive", default=False, help="Don't check case of file name.")\r
-\r
- Parser.add_option("-w", "--warning-as-error", action="store_true", dest="WarningAsError", help="Treat warning in tools as error.")\r
- Parser.add_option("-j", "--log", action="store", dest="LogFile", help="Put log in specified file as well as on console.")\r
-\r
- Parser.add_option("-s", "--silent", action="store_true", type=None, dest="SilentMode",\r
- help="Make use of silent mode of (n)make.")\r
- Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r
- Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\\r
- "including library instances selected, final dependency expression, "\\r
- "and warning messages, etc.")\r
- Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r
- Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")\r
-\r
- Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Create/overwrite the report to the specified filename.")\r
- Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD', 'LIBRARY', 'FLASH', 'DEPEX', 'BUILD_FLAGS', 'FIXED_ADDRESS', 'HASH', 'EXECUTION_ORDER'], dest="ReportType", default=[],\r
- help="Flags that control the type of build report to generate. Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS, HASH, EXECUTION_ORDER]. "\\r
- "To specify more than one flag, repeat this option on the command line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, HASH, BUILD_FLAGS, FIXED_ADDRESS]")\r
- Parser.add_option("-F", "--flag", action="store", type="string", dest="Flag",\r
- help="Specify the specific option to parse EDK UNI file. Must be one of: [-c, -s]. -c is for EDK framework UNI file, and -s is for EDK UEFI UNI file. "\\r
- "This option can also be specified by setting *_*_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both specified, this value "\\r
- "will override the setting in [BuildOptions] section of platform DSC.")\r
- Parser.add_option("-N", "--no-cache", action="store_true", dest="DisableCache", default=False, help="Disable build cache mechanism")\r
- Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")\r
- Parser.add_option("--check-usage", action="store_true", dest="CheckUsage", default=False, help="Check usage content of entries listed in INF file.")\r
- Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")\r
- Parser.add_option("--pcd", action="append", dest="OptionPcd", help="Set PCD value by command line. Format: \"PcdName=Value\" ")\r
- Parser.add_option("-l", "--cmd-len", action="store", type="int", dest="CommandLength", help="Specify the maximum line length of build command. Default is 4096.")\r
- Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")\r
- Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.")\r
- Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.")\r
- Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.")\r
- Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.")\r
- Parser.add_option("--disable-include-path-check", action="store_true", dest="DisableIncludePathCheck", default=False, help="Disable the include path check for outside of package.")\r
- (Opt, Args) = Parser.parse_args()\r
- return (Opt, Args)\r
-\r
-BuildOption, BuildTarget = MyOptionParser()\r
from io import BytesIO\r
\r
import Common.LongFilePathOs as os\r
-from Common.TargetTxtClassObject import TargetTxt\r
+from Common.TargetTxtClassObject import TargetTxtDict\r
from Common.DataType import *\r
import Common.GlobalData as GlobalData\r
from Common import EdkLogger\r
BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt"))\r
if os.path.isfile(BuildConfigurationFile) == True:\r
# if no build target given in command line, get it from target.txt\r
+ TargetObj = TargetTxtDict()\r
+ TargetTxt = TargetObj.Target\r
if not GenFdsGlobalVariable.TargetName:\r
BuildTargetList = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TARGET]\r
if len(BuildTargetList) != 1:\r
from Common import EdkLogger\r
from Common.Misc import SaveFileOnChange\r
\r
-from Common.TargetTxtClassObject import TargetTxt\r
-from Common.ToolDefClassObject import ToolDef\r
-from AutoGen.BuildEngine import BuildRuleObj\r
+from Common.TargetTxtClassObject import TargetTxtDict\r
+from Common.ToolDefClassObject import ToolDefDict\r
+from AutoGen.BuildEngine import ToolBuildRule\r
import Common.DataType as DataType\r
from Common.Misc import PathClass\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
def _LoadBuildRule():\r
if GenFdsGlobalVariable.__BuildRuleDatabase:\r
return GenFdsGlobalVariable.__BuildRuleDatabase\r
- GenFdsGlobalVariable.__BuildRuleDatabase = BuildRuleObj\r
- ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
+ BuildRule = ToolBuildRule()\r
+ GenFdsGlobalVariable.__BuildRuleDatabase = BuildRule.ToolBuildRule\r
+ TargetObj = TargetTxtDict()\r
+ ToolDefinitionFile = TargetObj.Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
if ToolDefinitionFile == '':\r
ToolDefinitionFile = "Conf/tools_def.txt"\r
if os.path.isfile(ToolDefinitionFile):\r
- ToolDefinition = ToolDef.ToolsDefTxtDatabase\r
+ ToolDefObj = ToolDefDict((os.path.join(os.getenv("WORKSPACE"), "Conf")))\r
+ ToolDefinition = ToolDefObj.ToolDef.ToolsDefTxtDatabase\r
if DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDefinition \\r
and GenFdsGlobalVariable.ToolChainTag in ToolDefinition[DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY] \\r
and ToolDefinition[DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY][GenFdsGlobalVariable.ToolChainTag]:\r
# @param NameGuid The Guid name\r
#\r
def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):\r
+ ToolDefObj = ToolDefDict((os.path.join(os.getenv("WORKSPACE"), "Conf")))\r
+ ToolDef = ToolDefObj.ToolDef\r
ToolDb = ToolDef.ToolsDefTxtDatabase\r
# if user not specify filter, try to deduce it from global data.\r
if KeyStringList is None or KeyStringList == []:\r
from types import *\r
from Common.Expression import *\r
from CommonDataClass.CommonClass import SkuInfoClass\r
-from Common.TargetTxtClassObject import TargetTxt\r
-from Common.ToolDefClassObject import ToolDef\r
+from Common.TargetTxtClassObject import TargetTxtDict\r
+from Common.ToolDefClassObject import ToolDefDict\r
from .MetaDataTable import *\r
from .MetaFileTable import *\r
from .MetaFileParser import *\r
@property\r
def ToolChainFamily(self):\r
self._ToolChainFamily = TAB_COMPILER_MSFT\r
+ TargetObj = TargetTxtDict()\r
+ TargetTxt = TargetObj.Target\r
BuildConfigurationFile = os.path.normpath(os.path.join(GlobalData.gConfDirectory, "target.txt"))\r
if os.path.isfile(BuildConfigurationFile) == True:\r
ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
ToolDefinitionFile = "tools_def.txt"\r
ToolDefinitionFile = os.path.normpath(mws.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile))\r
if os.path.isfile(ToolDefinitionFile) == True:\r
- ToolDefinition = ToolDef.ToolsDefTxtDatabase\r
+ ToolDefObj = ToolDefDict((os.path.join(os.getenv("WORKSPACE"), "Conf")))\r
+ ToolDefinition = ToolDefObj.ToolDef.ToolsDefTxtDatabase\r
if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \\r
or self._Toolchain not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \\r
or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Toolchain]:\r
import threading\r
from subprocess import Popen,PIPE, STDOUT\r
from collections import OrderedDict, defaultdict\r
-from Common.buildoptions import BuildOption,BuildTarget\r
+\r
from AutoGen.PlatformAutoGen import PlatformAutoGen\r
from AutoGen.ModuleAutoGen import ModuleAutoGen\r
from AutoGen.WorkspaceAutoGen import WorkspaceAutoGen\r
from AutoGen import GenMake\r
from Common import Misc as Utils\r
\r
-from Common.TargetTxtClassObject import TargetTxt\r
-from Common.ToolDefClassObject import ToolDef\r
+from Common.TargetTxtClassObject import TargetTxtDict\r
+from Common.ToolDefClassObject import ToolDefDict\r
+from buildoptions import MyOptionParser\r
from Common.Misc import PathClass,SaveFileOnChange,RemoveDirectory\r
from Common.StringUtils import NormPath\r
from Common.MultipleWorkspace import MultipleWorkspace as mws\r
self.ConfDirectory = BuildOptions.ConfDirectory\r
self.SpawnMode = True\r
self.BuildReport = BuildReport(BuildOptions.ReportFile, BuildOptions.ReportType)\r
- self.TargetTxt = TargetTxt\r
- self.ToolDef = ToolDef\r
self.AutoGenTime = 0\r
self.MakeTime = 0\r
self.GenFdsTime = 0\r
+ TargetObj = TargetTxtDict()\r
+ ToolDefObj = ToolDefDict((os.path.join(os.getenv("WORKSPACE"),"Conf")))\r
+ self.TargetTxt = TargetObj.Target\r
+ self.ToolDef = ToolDefObj.ToolDef\r
GlobalData.BuildOptionPcd = BuildOptions.OptionPcd if BuildOptions.OptionPcd else []\r
#Set global flag for build mode\r
GlobalData.gIgnoreSource = BuildOptions.IgnoreSources\r
EdkLogger.quiet("%-16s = %s" % ("POSTBUILD", self.Postbuild))\r
if self.Prebuild:\r
self.LaunchPrebuild()\r
- self.TargetTxt = TargetTxt\r
- self.ToolDef = ToolDef\r
+ TargetObj = TargetTxtDict()\r
+ ToolDefObj = ToolDefDict((os.path.join(os.getenv("WORKSPACE"), "Conf")))\r
+ self.TargetTxt = TargetObj.Target\r
+ self.ToolDef = ToolDefObj.ToolDef\r
if not (self.LaunchPrebuildFlag and os.path.exists(self.PlatformBuildPath)):\r
self.InitBuild()\r
\r
else:\r
return None\r
def ThreadNum():\r
+ OptionParser = MyOptionParser()\r
+ if not OptionParser.BuildOption and not OptionParser.BuildTarget:\r
+ OptionParser.GetOption()\r
+ BuildOption, BuildTarget = OptionParser.BuildOption, OptionParser.BuildTarget\r
ThreadNumber = BuildOption.ThreadNumber\r
+ GlobalData.gCmdConfDir = BuildOption.ConfDirectory\r
if ThreadNumber is None:\r
- ThreadNumber = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]\r
+ TargetObj = TargetTxtDict()\r
+ ThreadNumber = TargetObj.Target.TargetTxtDictionary[TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]\r
if ThreadNumber == '':\r
ThreadNumber = 0\r
else:\r
#\r
# Parse the options and args\r
#\r
- Option, Target = BuildOption, BuildTarget\r
+ OptionParser = MyOptionParser()\r
+ if not OptionParser.BuildOption and not OptionParser.BuildTarget:\r
+ OptionParser.GetOption()\r
+ Option, Target = OptionParser.BuildOption, OptionParser.BuildTarget\r
GlobalData.gOptions = Option\r
GlobalData.gCaseInsensitive = Option.CaseInsensitive\r
\r
--- /dev/null
+## @file\r
+# build a platform or a module\r
+#\r
+# Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+\r
+# Version and Copyright\r
+from Common.BuildVersion import gBUILD_VERSION\r
+from optparse import OptionParser\r
+VersionNumber = "0.60" + ' ' + gBUILD_VERSION\r
+__version__ = "%prog Version " + VersionNumber\r
+__copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation All rights reserved."\r
+\r
+gParamCheck = []\r
+def SingleCheckCallback(option, opt_str, value, parser):\r
+ if option not in gParamCheck:\r
+ setattr(parser.values, option.dest, value)\r
+ gParamCheck.append(option)\r
+ else:\r
+ parser.error("Option %s only allows one instance in command line!" % option)\r
+\r
+\r
+class MyOptionParser():\r
+\r
+ def __new__(cls, *args, **kw):\r
+ if not hasattr(cls, '_instance'):\r
+ orig = super(MyOptionParser, cls)\r
+ cls._instance = orig.__new__(cls, *args, **kw)\r
+ return cls._instance\r
+\r
+ def __init__(self):\r
+ if not hasattr(self, 'BuildOption'):\r
+ self.BuildOption = None\r
+ if not hasattr(self, 'BuildTarget'):\r
+ self.BuildTarget = None\r
+\r
+ def GetOption(self):\r
+ Parser = OptionParser(description=__copyright__, version=__version__, prog="build.exe", usage="%prog [options] [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]")\r
+ Parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32', 'X64', 'EBC', 'ARM', 'AARCH64'], dest="TargetArch",\r
+ help="ARCHS is one of list: IA32, X64, ARM, AARCH64 or EBC, which overrides target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option.")\r
+ Parser.add_option("-p", "--platform", action="callback", type="string", dest="PlatformFile", callback=SingleCheckCallback,\r
+ help="Build the platform specified by the DSC file name argument, overriding target.txt's ACTIVE_PLATFORM definition.")\r
+ Parser.add_option("-m", "--module", action="callback", type="string", dest="ModuleFile", callback=SingleCheckCallback,\r
+ help="Build the module specified by the INF file name argument.")\r
+ Parser.add_option("-b", "--buildtarget", type="string", dest="BuildTarget", help="Using the TARGET to build the platform, overriding target.txt's TARGET definition.",\r
+ action="append")\r
+ Parser.add_option("-t", "--tagname", action="append", type="string", dest="ToolChain",\r
+ help="Using the Tool Chain Tagname to build the platform, overriding target.txt's TOOL_CHAIN_TAG definition.")\r
+ Parser.add_option("-x", "--sku-id", action="callback", type="string", dest="SkuId", callback=SingleCheckCallback,\r
+ help="Using this name of SKU ID to build the platform, overriding SKUID_IDENTIFIER in DSC file.")\r
+\r
+ Parser.add_option("-n", action="callback", type="int", dest="ThreadNumber", callback=SingleCheckCallback,\r
+ help="Build the platform using multi-threaded compiler. The value overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. When value is set to 0, tool automatically detect number of "\\r
+ "processor threads, set value to 1 means disable multi-thread build, and set value to more than 1 means user specify the threads number to build.")\r
+\r
+ Parser.add_option("-f", "--fdf", action="callback", type="string", dest="FdfFile", callback=SingleCheckCallback,\r
+ help="The name of the FDF file to use, which overrides the setting in the DSC file.")\r
+ Parser.add_option("-r", "--rom-image", action="append", type="string", dest="RomImage", default=[],\r
+ help="The name of FD to be generated. The name must be from [FD] section in FDF file.")\r
+ Parser.add_option("-i", "--fv-image", action="append", type="string", dest="FvImage", default=[],\r
+ help="The name of FV to be generated. The name must be from [FV] section in FDF file.")\r
+ Parser.add_option("-C", "--capsule-image", action="append", type="string", dest="CapName", default=[],\r
+ help="The name of Capsule to be generated. The name must be from [Capsule] section in FDF file.")\r
+ Parser.add_option("-u", "--skip-autogen", action="store_true", dest="SkipAutoGen", help="Skip AutoGen step.")\r
+ Parser.add_option("-e", "--re-parse", action="store_true", dest="Reparse", help="Re-parse all meta-data files.")\r
+\r
+ Parser.add_option("-c", "--case-insensitive", action="store_true", dest="CaseInsensitive", default=False, help="Don't check case of file name.")\r
+\r
+ Parser.add_option("-w", "--warning-as-error", action="store_true", dest="WarningAsError", help="Treat warning in tools as error.")\r
+ Parser.add_option("-j", "--log", action="store", dest="LogFile", help="Put log in specified file as well as on console.")\r
+\r
+ Parser.add_option("-s", "--silent", action="store_true", type=None, dest="SilentMode",\r
+ help="Make use of silent mode of (n)make.")\r
+ Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r
+ Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\\r
+ "including library instances selected, final dependency expression, "\\r
+ "and warning messages, etc.")\r
+ Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r
+ Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")\r
+\r
+ Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Create/overwrite the report to the specified filename.")\r
+ Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD', 'LIBRARY', 'FLASH', 'DEPEX', 'BUILD_FLAGS', 'FIXED_ADDRESS', 'HASH', 'EXECUTION_ORDER'], dest="ReportType", default=[],\r
+ help="Flags that control the type of build report to generate. Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS, HASH, EXECUTION_ORDER]. "\\r
+ "To specify more than one flag, repeat this option on the command line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, HASH, BUILD_FLAGS, FIXED_ADDRESS]")\r
+ Parser.add_option("-F", "--flag", action="store", type="string", dest="Flag",\r
+ help="Specify the specific option to parse EDK UNI file. Must be one of: [-c, -s]. -c is for EDK framework UNI file, and -s is for EDK UEFI UNI file. "\\r
+ "This option can also be specified by setting *_*_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both specified, this value "\\r
+ "will override the setting in [BuildOptions] section of platform DSC.")\r
+ Parser.add_option("-N", "--no-cache", action="store_true", dest="DisableCache", default=False, help="Disable build cache mechanism")\r
+ Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")\r
+ Parser.add_option("--check-usage", action="store_true", dest="CheckUsage", default=False, help="Check usage content of entries listed in INF file.")\r
+ Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")\r
+ Parser.add_option("--pcd", action="append", dest="OptionPcd", help="Set PCD value by command line. Format: \"PcdName=Value\" ")\r
+ Parser.add_option("-l", "--cmd-len", action="store", type="int", dest="CommandLength", help="Specify the maximum line length of build command. Default is 4096.")\r
+ Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")\r
+ Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.")\r
+ Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.")\r
+ Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.")\r
+ Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.")\r
+ Parser.add_option("--disable-include-path-check", action="store_true", dest="DisableIncludePathCheck", default=False, help="Disable the include path check for outside of package.")\r
+ self.BuildOption, self.BuildTarget = Parser.parse_args()\r