]>
Commit | Line | Data |
---|---|---|
4465cd12 FZ |
1 | ## @file\r |
2 | # build a platform or a module\r | |
3 | #\r | |
4 | # Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r | |
3c139380 | 5 | # Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>\r |
f60d5ca9 | 6 | # Copyright (c) 2018 - 2020, Hewlett Packard Enterprise Development, L.P.<BR>\r |
c53807cb | 7 | # Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r |
4465cd12 FZ |
8 | #\r |
9 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
10 | #\r | |
11 | \r | |
12 | # Version and Copyright\r | |
13 | from Common.BuildVersion import gBUILD_VERSION\r | |
14 | from optparse import OptionParser\r | |
15 | VersionNumber = "0.60" + ' ' + gBUILD_VERSION\r | |
16 | __version__ = "%prog Version " + VersionNumber\r | |
17 | __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation All rights reserved."\r | |
18 | \r | |
19 | gParamCheck = []\r | |
20 | def SingleCheckCallback(option, opt_str, value, parser):\r | |
21 | if option not in gParamCheck:\r | |
22 | setattr(parser.values, option.dest, value)\r | |
23 | gParamCheck.append(option)\r | |
24 | else:\r | |
25 | parser.error("Option %s only allows one instance in command line!" % option)\r | |
26 | \r | |
27 | \r | |
28 | class MyOptionParser():\r | |
29 | \r | |
30 | def __new__(cls, *args, **kw):\r | |
31 | if not hasattr(cls, '_instance'):\r | |
32 | orig = super(MyOptionParser, cls)\r | |
33 | cls._instance = orig.__new__(cls, *args, **kw)\r | |
34 | return cls._instance\r | |
35 | \r | |
36 | def __init__(self):\r | |
37 | if not hasattr(self, 'BuildOption'):\r | |
38 | self.BuildOption = None\r | |
39 | if not hasattr(self, 'BuildTarget'):\r | |
40 | self.BuildTarget = None\r | |
41 | \r | |
42 | def GetOption(self):\r | |
43 | Parser = OptionParser(description=__copyright__, version=__version__, prog="build.exe", usage="%prog [options] [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]")\r | |
3c139380 | 44 | Parser.add_option("-a", "--arch", action="append", dest="TargetArch",\r |
c53807cb | 45 | help="ARCHS is one of list: IA32, X64, ARM, AARCH64, RISCV64, LOONGARCH64 or EBC, which overrides target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option.")\r |
4465cd12 FZ |
46 | Parser.add_option("-p", "--platform", action="callback", type="string", dest="PlatformFile", callback=SingleCheckCallback,\r |
47 | help="Build the platform specified by the DSC file name argument, overriding target.txt's ACTIVE_PLATFORM definition.")\r | |
48 | Parser.add_option("-m", "--module", action="callback", type="string", dest="ModuleFile", callback=SingleCheckCallback,\r | |
49 | help="Build the module specified by the INF file name argument.")\r | |
50 | Parser.add_option("-b", "--buildtarget", type="string", dest="BuildTarget", help="Using the TARGET to build the platform, overriding target.txt's TARGET definition.",\r | |
51 | action="append")\r | |
52 | Parser.add_option("-t", "--tagname", action="append", type="string", dest="ToolChain",\r | |
53 | help="Using the Tool Chain Tagname to build the platform, overriding target.txt's TOOL_CHAIN_TAG definition.")\r | |
54 | Parser.add_option("-x", "--sku-id", action="callback", type="string", dest="SkuId", callback=SingleCheckCallback,\r | |
55 | help="Using this name of SKU ID to build the platform, overriding SKUID_IDENTIFIER in DSC file.")\r | |
56 | \r | |
57 | Parser.add_option("-n", action="callback", type="int", dest="ThreadNumber", callback=SingleCheckCallback,\r | |
58 | 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 | |
59 | "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 | |
60 | \r | |
61 | Parser.add_option("-f", "--fdf", action="callback", type="string", dest="FdfFile", callback=SingleCheckCallback,\r | |
62 | help="The name of the FDF file to use, which overrides the setting in the DSC file.")\r | |
63 | Parser.add_option("-r", "--rom-image", action="append", type="string", dest="RomImage", default=[],\r | |
64 | help="The name of FD to be generated. The name must be from [FD] section in FDF file.")\r | |
65 | Parser.add_option("-i", "--fv-image", action="append", type="string", dest="FvImage", default=[],\r | |
66 | help="The name of FV to be generated. The name must be from [FV] section in FDF file.")\r | |
67 | Parser.add_option("-C", "--capsule-image", action="append", type="string", dest="CapName", default=[],\r | |
68 | help="The name of Capsule to be generated. The name must be from [Capsule] section in FDF file.")\r | |
69 | Parser.add_option("-u", "--skip-autogen", action="store_true", dest="SkipAutoGen", help="Skip AutoGen step.")\r | |
70 | Parser.add_option("-e", "--re-parse", action="store_true", dest="Reparse", help="Re-parse all meta-data files.")\r | |
71 | \r | |
72 | Parser.add_option("-c", "--case-insensitive", action="store_true", dest="CaseInsensitive", default=False, help="Don't check case of file name.")\r | |
73 | \r | |
74 | Parser.add_option("-w", "--warning-as-error", action="store_true", dest="WarningAsError", help="Treat warning in tools as error.")\r | |
75 | Parser.add_option("-j", "--log", action="store", dest="LogFile", help="Put log in specified file as well as on console.")\r | |
76 | \r | |
77 | Parser.add_option("-s", "--silent", action="store_true", type=None, dest="SilentMode",\r | |
78 | help="Make use of silent mode of (n)make.")\r | |
79 | Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r | |
80 | Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\\r | |
81 | "including library instances selected, final dependency expression, "\\r | |
82 | "and warning messages, etc.")\r | |
83 | Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r | |
84 | Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")\r | |
85 | \r | |
86 | Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Create/overwrite the report to the specified filename.")\r | |
87 | 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 | |
88 | 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 | |
89 | "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 | |
90 | Parser.add_option("-F", "--flag", action="store", type="string", dest="Flag",\r | |
91 | 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 | |
92 | "This option can also be specified by setting *_*_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both specified, this value "\\r | |
93 | "will override the setting in [BuildOptions] section of platform DSC.")\r | |
94 | Parser.add_option("-N", "--no-cache", action="store_true", dest="DisableCache", default=False, help="Disable build cache mechanism")\r | |
95 | Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")\r | |
96 | Parser.add_option("--check-usage", action="store_true", dest="CheckUsage", default=False, help="Check usage content of entries listed in INF file.")\r | |
97 | Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")\r | |
98 | Parser.add_option("--pcd", action="append", dest="OptionPcd", help="Set PCD value by command line. Format: \"PcdName=Value\" ")\r | |
99 | 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 | |
100 | Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")\r | |
101 | Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.")\r | |
102 | Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.")\r | |
103 | Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.")\r | |
104 | Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.")\r | |
105 | 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 | |
106 | self.BuildOption, self.BuildTarget = Parser.parse_args()\r |