blob: fe4114168cd4cca4aad8137f50e1739a19557971 [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14package com.google.devtools.build.lib.exec;
15
steinman13a628a2019-01-09 08:39:32 -080016import com.google.common.collect.ImmutableMap;
jcater2dd46e62018-02-20 14:00:33 -080017import com.google.common.collect.Iterables;
ahumeskybe31bb82018-07-26 13:37:45 -070018import com.google.devtools.build.lib.actions.ActionExecutionContext.ShowSubcommands;
steinman13a628a2019-01-09 08:39:32 -080019import com.google.devtools.build.lib.actions.LocalHostCapacity;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010020import com.google.devtools.build.lib.actions.ResourceSet;
jcater2dd46e62018-02-20 14:00:33 -080021import com.google.devtools.build.lib.analysis.config.PerLabelOptions;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010022import com.google.devtools.build.lib.util.OptionsUtils;
jcater2dd46e62018-02-20 14:00:33 -080023import com.google.devtools.build.lib.util.RegexFilter;
Googler7859ff22018-12-21 10:12:48 -080024import com.google.devtools.build.lib.util.ResourceConverter;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010025import com.google.devtools.build.lib.vfs.PathFragment;
ahumeskybe31bb82018-07-26 13:37:45 -070026import com.google.devtools.common.options.BoolOrEnumConverter;
philwo207ac6e2019-02-20 12:44:06 -080027import com.google.devtools.common.options.Converters.AssignmentToListOfValuesConverter;
28import com.google.devtools.common.options.Converters.CommaSeparatedNonEmptyOptionListConverter;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010029import com.google.devtools.common.options.Option;
ccalvarin3bc15472017-06-27 17:58:35 +020030import com.google.devtools.common.options.OptionDocumentationCategory;
ccalvarinc82a1972017-07-17 21:13:39 +020031import com.google.devtools.common.options.OptionEffectTag;
philwo849113c2019-02-20 15:09:30 -080032import com.google.devtools.common.options.OptionMetadataTag;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010033import com.google.devtools.common.options.Options;
34import com.google.devtools.common.options.OptionsBase;
jcater2dd46e62018-02-20 14:00:33 -080035import com.google.devtools.common.options.OptionsParsingException;
jcater2dd46e62018-02-20 14:00:33 -080036import java.util.Collections;
37import java.util.List;
philwo784557b2019-01-04 05:33:12 -080038import java.util.Map;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010039
40/**
41 * Options affecting the execution phase of a build.
42 *
Googlerc023bc22015-03-20 16:26:08 +000043 * These options are interpreted by the BuildTool to choose an Executor to
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010044 * be used for the build.
45 *
Googlerc023bc22015-03-20 16:26:08 +000046 * Note: from the user's point of view, the characteristic function of this
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010047 * set of options is indistinguishable from that of the BuildRequestOptions:
48 * they are all per-request. The difference is only apparent in the
49 * implementation: these options are used only by the lib.exec machinery, which
50 * affects how C++ and Java compilation occur. (The BuildRequestOptions
51 * contain a mixture of "semantic" options affecting the choice of targets to
52 * build, and "non-semantic" options affecting the lib.actions machinery.)
53 * Ideally, the user would be unaware of the difference. For now, the usage
54 * strings are identical modulo "part 1", "part 2".
55 */
56public class ExecutionOptions extends OptionsBase {
57
58 public static final ExecutionOptions DEFAULTS = Options.getDefaults(ExecutionOptions.class);
59
ccalvarin2eaa02e2017-04-17 23:37:46 +020060 @Option(
philwo849113c2019-02-20 15:09:30 -080061 name = "incompatible_list_based_execution_strategy_selection",
ishikhman37033332019-05-16 10:27:29 -070062 defaultValue = "true",
philwo849113c2019-02-20 15:09:30 -080063 documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY,
64 effectTags = {OptionEffectTag.EXECUTION},
65 metadataTags = {
66 OptionMetadataTag.INCOMPATIBLE_CHANGE,
67 OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
68 },
69 help = "See https://github.com/bazelbuild/bazel/issues/7480")
70 public boolean incompatibleListBasedExecutionStrategySelection;
71
72 @Option(
philwo784557b2019-01-04 05:33:12 -080073 name = "spawn_strategy",
74 defaultValue = "",
philwo207ac6e2019-02-20 12:44:06 -080075 converter = CommaSeparatedNonEmptyOptionListConverter.class,
philwo784557b2019-01-04 05:33:12 -080076 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
77 effectTags = {OptionEffectTag.UNKNOWN},
78 help =
79 "Specify how spawn actions are executed by default. "
80 + "'standalone' means run all of them locally without any kind of sandboxing. "
81 + "'sandboxed' means to run them in a sandboxed environment with limited privileges "
82 + "(details depend on platform support).")
philwo207ac6e2019-02-20 12:44:06 -080083 public List<String> spawnStrategy;
philwo784557b2019-01-04 05:33:12 -080084
85 @Option(
86 name = "genrule_strategy",
87 defaultValue = "",
philwo849113c2019-02-20 15:09:30 -080088 converter = CommaSeparatedNonEmptyOptionListConverter.class,
philwo784557b2019-01-04 05:33:12 -080089 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
90 effectTags = {OptionEffectTag.UNKNOWN},
91 help =
92 "Specify how to execute genrules. This flag will be phased out. Instead, use "
93 + "--spawn_strategy=<value> to control all actions or --strategy=Genrule=<value> "
94 + "to control genrules only.")
philwo207ac6e2019-02-20 12:44:06 -080095 public List<String> genruleStrategy;
philwo784557b2019-01-04 05:33:12 -080096
97 @Option(
98 name = "strategy",
99 allowMultiple = true,
philwo207ac6e2019-02-20 12:44:06 -0800100 converter = AssignmentToListOfValuesConverter.class,
philwo784557b2019-01-04 05:33:12 -0800101 defaultValue = "",
102 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
103 effectTags = {OptionEffectTag.UNKNOWN},
104 help =
105 "Specify how to distribute compilation of other spawn actions. "
106 + "Example: 'Javac=local' means to spawn Java compilation locally. "
107 + "'JavaIjar=sandboxed' means to spawn Java Ijar actions in a sandbox. ")
philwo207ac6e2019-02-20 12:44:06 -0800108 public List<Map.Entry<String, List<String>>> strategy;
philwo784557b2019-01-04 05:33:12 -0800109
110 @Option(
111 name = "strategy_regexp",
112 allowMultiple = true,
113 converter = RegexFilterAssignmentConverter.class,
114 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
115 effectTags = {OptionEffectTag.UNKNOWN},
116 defaultValue = "",
117 help =
118 "Override which spawn strategy should be used to execute spawn actions that have "
119 + "descriptions matching a certain regex_filter. See --per_file_copt for details on"
120 + "regex_filter matching. "
121 + "The first regex_filter that matches the description is used. "
122 + "This option overrides other flags for specifying strategy. "
123 + "Example: --strategy_regexp=//foo.*\\.cc,-//foo/bar=local means to run actions "
124 + "using local strategy if their descriptions match //foo.*.cc but not //foo/bar. "
125 + "Example: --strategy_regexp='Compiling.*/bar=local "
126 + " --strategy_regexp=Compiling=sandboxed will run 'Compiling //foo/bar/baz' with "
127 + "the 'local' strategy, but reversing the order would run it with 'sandboxed'. ")
philwo207ac6e2019-02-20 12:44:06 -0800128 public List<Map.Entry<RegexFilter, List<String>>> strategyByRegexp;
philwo784557b2019-01-04 05:33:12 -0800129
130 @Option(
tomlu09fe0622018-06-19 12:55:39 -0700131 name = "materialize_param_files",
132 defaultValue = "false",
133 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
134 effectTags = {OptionEffectTag.UNKNOWN},
135 help =
136 "Writes intermediate parameter files to output tree even when using "
137 + "remote action execution. Useful when debugging actions. ")
138 public boolean materializeParamFiles;
139
140 @Option(
ccalvarin2eaa02e2017-04-17 23:37:46 +0200141 name = "verbose_failures",
142 defaultValue = "false",
ccalvarin3bc15472017-06-27 17:58:35 +0200143 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
144 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200145 help = "If a command fails, print out the full command line."
146 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100147 public boolean verboseFailures;
148
ccalvarin2eaa02e2017-04-17 23:37:46 +0200149 @Option(
150 name = "subcommands",
151 abbrev = 's',
152 defaultValue = "false",
ahumeskybe31bb82018-07-26 13:37:45 -0700153 converter = ShowSubcommandsConverter.class,
ccalvarin3bc15472017-06-27 17:58:35 +0200154 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
155 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200156 help = "Display the subcommands executed during a build."
157 )
ahumeskybe31bb82018-07-26 13:37:45 -0700158 public ShowSubcommands showSubcommands;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100159
ccalvarin2eaa02e2017-04-17 23:37:46 +0200160 @Option(
161 name = "check_up_to_date",
162 defaultValue = "false",
ccalvarin3bc15472017-06-27 17:58:35 +0200163 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
164 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200165 help =
166 "Don't perform the build, just check if it is up-to-date. If all targets are "
167 + "up-to-date, the build completes successfully. If any step needs to be executed "
168 + "an error is reported and the build fails."
169 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100170 public boolean checkUpToDate;
171
ccalvarin2eaa02e2017-04-17 23:37:46 +0200172 @Option(
173 name = "check_tests_up_to_date",
174 defaultValue = "false",
ccalvarin2eaa02e2017-04-17 23:37:46 +0200175 implicitRequirements = {"--check_up_to_date"},
ccalvarin3bc15472017-06-27 17:58:35 +0200176 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
177 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200178 help =
179 "Don't run tests, just check if they are up-to-date. If all tests results are "
180 + "up-to-date, the testing completes successfully. If any test needs to be built or "
181 + "executed, an error is reported and the testing fails. This option implies "
182 + "--check_up_to_date behavior."
183 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100184 public boolean testCheckUpToDate;
185
ccalvarin2eaa02e2017-04-17 23:37:46 +0200186 @Option(
187 name = "test_strategy",
188 defaultValue = "",
ccalvarin3bc15472017-06-27 17:58:35 +0200189 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
190 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200191 help = "Specifies which strategy to use when running tests."
192 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100193 public String testStrategy;
194
ccalvarin2eaa02e2017-04-17 23:37:46 +0200195 @Option(
196 name = "test_keep_going",
197 defaultValue = "true",
ccalvarin3bc15472017-06-27 17:58:35 +0200198 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
199 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200200 help =
201 "When disabled, any non-passing test will cause the entire build to stop. By default "
202 + "all tests are run, even if some do not pass."
203 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100204 public boolean testKeepGoing;
205
ccalvarin2eaa02e2017-04-17 23:37:46 +0200206 @Option(
207 name = "runs_per_test_detects_flakes",
208 defaultValue = "false",
ccalvarin3bc15472017-06-27 17:58:35 +0200209 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
210 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200211 help =
212 "If true, any shard in which at least one run/attempt passes and at least one "
213 + "run/attempt fails gets a FLAKY status."
214 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100215 public boolean runsPerTestDetectsFlakes;
216
ccalvarin2eaa02e2017-04-17 23:37:46 +0200217 @Option(
218 name = "flaky_test_attempts",
jcater2dd46e62018-02-20 14:00:33 -0800219 allowMultiple = true,
ccalvarin2eaa02e2017-04-17 23:37:46 +0200220 defaultValue = "default",
jcater2dd46e62018-02-20 14:00:33 -0800221 converter = TestAttemptsConverter.class,
ccalvarin3bc15472017-06-27 17:58:35 +0200222 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
223 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200224 help =
225 "Each test will be retried up to the specified number of times in case of any test "
226 + "failure. Tests that required more than one attempt to pass would be marked as "
227 + "'FLAKY' in the test summary. If this option is set, it should specify an int N or "
228 + "the string 'default'. If it's an int, then all tests will be run up to N times. "
229 + "If it is not specified or its value is 'default', then only a single test attempt "
230 + "will be made for regular tests and three for tests marked explicitly as flaky by "
231 + "their rule (flaky=1 attribute)."
232 )
jcater2dd46e62018-02-20 14:00:33 -0800233 public List<PerLabelOptions> testAttempts;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100234
ccalvarin2eaa02e2017-04-17 23:37:46 +0200235 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700236 name = "test_tmpdir",
237 defaultValue = "null",
238 converter = OptionsUtils.PathFragmentConverter.class,
239 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
240 effectTags = {OptionEffectTag.UNKNOWN},
241 help = "Specifies the base temporary directory for 'bazel test' to use.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100242 public PathFragment testTmpDir;
243
ccalvarin2eaa02e2017-04-17 23:37:46 +0200244 @Option(
245 name = "test_output",
246 defaultValue = "summary",
ccalvarin2eaa02e2017-04-17 23:37:46 +0200247 converter = TestStrategy.TestOutputFormat.Converter.class,
ccalvarin3bc15472017-06-27 17:58:35 +0200248 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
249 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200250 help =
251 "Specifies desired output mode. Valid values are 'summary' to output only test status "
252 + "summary, 'errors' to also print test logs for failed tests, 'all' to print logs "
253 + "for all tests and 'streamed' to output logs for all tests in real time "
254 + "(this will force tests to be executed locally one at a time regardless of "
255 + "--test_strategy value)."
256 )
jcater2dd46e62018-02-20 14:00:33 -0800257 public TestStrategy.TestOutputFormat testOutput;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100258
ccalvarin2eaa02e2017-04-17 23:37:46 +0200259 @Option(
260 name = "test_summary",
261 defaultValue = "short",
ccalvarin2eaa02e2017-04-17 23:37:46 +0200262 converter = TestStrategy.TestSummaryFormat.Converter.class,
ccalvarin3bc15472017-06-27 17:58:35 +0200263 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
264 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200265 help =
266 "Specifies the desired format ot the test summary. Valid values are 'short' to print "
267 + "information only about tests executed, 'terse', to print information only about "
Klaus Aehlig1d71c0c2017-08-30 14:58:28 +0200268 + "unsuccessful tests that were run, 'detailed' to print detailed information about "
269 + "failed test cases, and 'none' to omit the summary."
ccalvarin2eaa02e2017-04-17 23:37:46 +0200270 )
jcater2dd46e62018-02-20 14:00:33 -0800271 public TestStrategy.TestSummaryFormat testSummary;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100272
ccalvarin2eaa02e2017-04-17 23:37:46 +0200273 @Option(
ccalvarin2eaa02e2017-04-17 23:37:46 +0200274 name = "resource_autosense",
275 defaultValue = "false",
ccalvarin3bc15472017-06-27 17:58:35 +0200276 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
277 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200278 help = "This flag has no effect, and is deprecated"
279 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100280 public boolean useResourceAutoSense;
281
ccalvarin2eaa02e2017-04-17 23:37:46 +0200282 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700283 name = "ram_utilization_factor",
steinman13a628a2019-01-09 08:39:32 -0800284 defaultValue = "0",
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700285 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
286 effectTags = {OptionEffectTag.UNKNOWN},
287 help =
288 "Specify what percentage of the system's RAM Bazel should try to use for its "
289 + "subprocesses. This option affects how many processes Bazel will try to run in "
290 + "parallel. If you run several Bazel builds in parallel, using a lower value for "
291 + "this option may avoid thrashing and thus improve overall throughput. "
steinman13a628a2019-01-09 08:39:32 -0800292 + "Using a value higher than 67 is NOT recommended. "
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700293 + "Note that Blaze's estimates are very coarse, so the actual RAM usage may be much "
294 + "higher or much lower than specified. "
295 + "Note also that this option does not affect the amount of memory that the Bazel "
steinman13a628a2019-01-09 08:39:32 -0800296 + "server itself will use. "
297 + "Setting this value overrides --local_ram_resources")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100298 public int ramUtilizationPercentage;
299
ccalvarin2eaa02e2017-04-17 23:37:46 +0200300 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700301 name = "local_resources",
302 defaultValue = "null",
303 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
304 effectTags = {OptionEffectTag.UNKNOWN},
305 help =
306 "Explicitly set amount of local resources available to Blaze. By default, Bazel will "
307 + "query system configuration to estimate amount of RAM (in MB) "
308 + "and number of CPU cores available for the locally executed build actions. It "
309 + "would also assume default I/O capabilities of the local workstation (1.0). This "
310 + "options allows to explicitly set all 3 values. Note, that if this option is used, "
steinman13a628a2019-01-09 08:39:32 -0800311 + "Bazel will ignore --ram_utilization_factor, --local_cpu_resources, and "
312 + "--local_ram_resources.",
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700313 converter = ResourceSet.ResourceSetConverter.class)
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100314 public ResourceSet availableResources;
Mark Schallerdffb6ee2015-02-25 20:01:01 +0000315
ccalvarin2eaa02e2017-04-17 23:37:46 +0200316 @Option(
steinman3501b212019-03-25 12:36:43 -0700317 name = "incompatible_remove_local_resources",
318 defaultValue = "false",
319 documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY,
320 effectTags = {OptionEffectTag.EXECUTION},
321 metadataTags = {
322 OptionMetadataTag.INCOMPATIBLE_CHANGE,
323 OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
324 },
325 help =
326 "Deprecate local_resources in favor of --local_ram_resources and "
327 + "--local_cpu_resources.")
328 public boolean removeLocalResources;
329
330 @Option(
steinman13a628a2019-01-09 08:39:32 -0800331 name = "local_cpu_resources",
332 defaultValue = "HOST_CPUS",
333 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
334 effectTags = {OptionEffectTag.UNKNOWN},
335 help =
336 "Explicitly set the number of local CPU threads available to Bazel. Takes "
337 + "an integer, or \"HOST_CPUS\", optionally followed by [-|*]<float> "
338 + "(eg. HOST_CPUS*.5 to use half the available CPU cores)."
339 + "By default, (\"HOST_CPUS\"), Bazel will query system configuration to estimate "
340 + "number of CPU cores available for the locally executed build actions. "
341 + "Note: This is a no-op if --local_resources is set.",
342 converter = CpuResourceConverter.class)
343 public float localCpuResources;
344
345 @Option(
346 name = "local_ram_resources",
347 defaultValue = "HOST_RAM*.67",
348 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
349 effectTags = {OptionEffectTag.UNKNOWN},
350 help =
351 "Explicitly set the amount of local host RAM (in MB) available to Bazel. Takes "
352 + "an integer, or \"HOST_RAM\", optionally followed by [-|*]<float> "
353 + "(eg. HOST_RAM*.5 to use half the available RAM)."
354 + "By default, (\"HOST_RAM*.67\"), Bazel will query system configuration to estimate "
355 + "amount of RAM available for the locally executed build actions and will use 67% "
356 + "of available RAM. "
357 + "Note: This is a no-op if --ram_utilization_factor or --local_resources is set.",
358 converter = RamResourceConverter.class)
359 public float localRamResources;
360
361 @Option(
Josh Pieper7f3bddd2018-05-04 00:39:37 -0700362 name = "experimental_local_memory_estimate",
363 defaultValue = "false",
364 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
365 effectTags = {OptionEffectTag.UNKNOWN},
366 help =
367 "Estimate the actual memory available online. "
368 + "By default, Blaze assumes most actions use a fixed amount of memory, and counts "
369 + "that against the total available system memory, regardless of how much memory is "
370 + "actually available. This option enables online estimation of how much memory is "
371 + "available at any given time, and thus does not require accurate estimation of how "
372 + "much memory a given action will take."
373 )
374 public boolean localMemoryEstimate;
375
376 @Option(
Googler7859ff22018-12-21 10:12:48 -0800377 name = "local_test_jobs",
378 defaultValue = "auto",
379 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
380 effectTags = {OptionEffectTag.UNKNOWN},
381 help =
382 "The max number of local test jobs to run concurrently. "
383 + "Takes "
384 + ResourceConverter.FLAG_SYNTAX
385 + ". 0 means local resources will limit the number of local test jobs to run "
386 + "concurrently instead. Setting this greater than the value for --jobs "
387 + "is ineffectual.",
388 converter = LocalTestJobsConverter.class)
Mark Schallerdffb6ee2015-02-25 20:01:01 +0000389 public int localTestJobs;
390
391 public boolean usingLocalTestJobs() {
392 return localTestJobs != 0;
393 }
Philipp Wollermann4ca5dfa2017-02-01 13:45:55 +0000394
395 @Option(
396 name = "debug_print_action_contexts",
397 defaultValue = "false",
ccalvarin456adb22017-07-11 14:23:46 +0200398 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarin3bc15472017-06-27 17:58:35 +0200399 effectTags = {OptionEffectTag.UNKNOWN},
Philipp Wollermann4ca5dfa2017-02-01 13:45:55 +0000400 help = "Print the contents of the SpawnActionContext and ContextProviders maps."
401 )
402 public boolean debugPrintActionContexts;
Julio Merino7ac6d592017-03-16 19:12:32 +0000403
404 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700405 name = "cache_computed_file_digests",
406 defaultValue = "50000",
407 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
408 effectTags = {OptionEffectTag.UNKNOWN},
409 help =
410 "If greater than 0, configures Bazel to cache file digests in memory based on their "
411 + "metadata instead of recomputing the digests from disk every time they are needed. "
412 + "Setting this to 0 ensures correctness because not all file changes can be noted "
413 + "from file metadata. When not 0, the number indicates the size of the cache as the "
414 + "number of file digests to be cached.")
Julio Merino7ac6d592017-03-16 19:12:32 +0000415 public long cacheSizeForComputedFileDigests;
janakr1fb90fd2017-03-30 21:07:04 +0000416
janakr1fb90fd2017-03-30 21:07:04 +0000417 @Option(
418 name = "experimental_enable_critical_path_profiling",
419 defaultValue = "true",
ccalvarin456adb22017-07-11 14:23:46 +0200420 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarin3bc15472017-06-27 17:58:35 +0200421 effectTags = {OptionEffectTag.UNKNOWN},
janakr1fb90fd2017-03-30 21:07:04 +0000422 help =
423 "If set (the default), critical path profiling is enabled for the execution phase. "
424 + "This has a slight overhead in RAM and CPU, and may prevent Bazel from making certain"
425 + " aggressive RAM optimizations in some cases."
426 )
427 public boolean enableCriticalPathProfiling;
jcater2dd46e62018-02-20 14:00:33 -0800428
olaola913b66c2018-04-19 10:43:53 -0700429 @Option(
ulfjack97a3ee42018-11-20 05:40:35 -0800430 name = "experimental_stats_summary",
431 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
432 effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
433 defaultValue = "false",
434 help = "Enable a modernized summary of the build stats."
435 )
436 public boolean statsSummary;
437
438 @Option(
Googlerd03d3f32019-04-16 08:06:23 -0700439 name = "experimental_execution_log_file",
440 defaultValue = "null",
441 category = "verbosity",
442 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
443 effectTags = {OptionEffectTag.UNKNOWN},
444 converter = OptionsUtils.PathFragmentConverter.class,
445 help = "Log the executed spawns into this file as delimited Spawn protos.")
446 public PathFragment executionLogFile;
447
448 @Option(
449 name = "execution_log_binary_file",
450 defaultValue = "null",
451 category = "verbosity",
452 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
453 effectTags = {OptionEffectTag.UNKNOWN},
454 converter = OptionsUtils.PathFragmentConverter.class,
455 help = "Log the executed spawns into this file as delimited Spawn protos.")
456 public PathFragment executionLogBinaryFile;
457
458 @Option(
459 name = "execution_log_json_file",
460 defaultValue = "null",
461 category = "verbosity",
462 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
463 effectTags = {OptionEffectTag.UNKNOWN},
464 converter = OptionsUtils.PathFragmentConverter.class,
465 help =
466 "Log the executed spawns into this file as json representation of the delimited Spawn"
467 + " protos.")
468 public PathFragment executionLogJsonFile;
olaola913b66c2018-04-19 10:43:53 -0700469
ulfjack0858ae12018-07-27 02:37:53 -0700470 @Option(
ulfjack6da89822019-02-04 13:06:34 -0800471 name = "experimental_split_xml_generation",
472 defaultValue = "true",
473 documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY,
474 effectTags = {OptionEffectTag.EXECUTION},
475 help =
476 "If this flag is set, and a test action does not generate a test.xml file, then "
477 + "Bazel uses a separate action to generate a dummy test.xml file containing the "
478 + "test log. Otherwise, Bazel generates a test.xml as part of the test action.")
ulfjack0858ae12018-07-27 02:37:53 -0700479 public boolean splitXmlGeneration;
480
jcater2dd46e62018-02-20 14:00:33 -0800481 /** Converter for the --flaky_test_attempts option. */
482 public static class TestAttemptsConverter extends PerLabelOptions.PerLabelOptionsConverter {
483 private static final int MIN_VALUE = 1;
484 private static final int MAX_VALUE = 10;
485
486 private void validateInput(String input) throws OptionsParsingException {
487 if ("default".equals(input)) {
488 return;
489 } else {
490 Integer value = Integer.parseInt(input);
491 if (value < MIN_VALUE) {
492 throw new OptionsParsingException("'" + input + "' should be >= " + MIN_VALUE);
493 } else if (value < MIN_VALUE || value > MAX_VALUE) {
494 throw new OptionsParsingException("'" + input + "' should be <= " + MAX_VALUE);
495 }
496 return;
497 }
498 }
499
500 @Override
501 public PerLabelOptions convert(String input) throws OptionsParsingException {
502 try {
503 return parseAsInteger(input);
504 } catch (NumberFormatException ignored) {
505 return parseAsRegex(input);
506 }
507 }
508
509 private PerLabelOptions parseAsInteger(String input)
510 throws NumberFormatException, OptionsParsingException {
511 validateInput(input);
512 RegexFilter catchAll =
513 new RegexFilter(Collections.singletonList(".*"), Collections.<String>emptyList());
514 return new PerLabelOptions(catchAll, Collections.singletonList(input));
515 }
516
517 private PerLabelOptions parseAsRegex(String input) throws OptionsParsingException {
518 PerLabelOptions testRegexps = super.convert(input);
519 if (testRegexps.getOptions().size() != 1) {
520 throw new OptionsParsingException("'" + input + "' has multiple runs for a single pattern");
521 }
522 String runsPerTest = Iterables.getOnlyElement(testRegexps.getOptions());
523 try {
524 // Run this in order to catch errors.
525 validateInput(runsPerTest);
526 } catch (NumberFormatException e) {
527 throw new OptionsParsingException("'" + input + "' has a non-numeric value", e);
528 }
529 return testRegexps;
530 }
531
532 @Override
533 public String getTypeDescription() {
534 return "a positive integer, the string \"default\", or test_regex@attempts. "
535 + "This flag may be passed more than once";
536 }
537 }
ahumeskybe31bb82018-07-26 13:37:45 -0700538
Googler7859ff22018-12-21 10:12:48 -0800539 /** Converter for --local_test_jobs, which takes {@value FLAG_SYNTAX} */
540 public static class LocalTestJobsConverter extends ResourceConverter {
541 public LocalTestJobsConverter() throws OptionsParsingException {
542 super(/* autoSupplier= */ () -> 0, /* minValue= */ 0, /* maxValue= */ Integer.MAX_VALUE);
543 }
544 }
545
ahumeskybe31bb82018-07-26 13:37:45 -0700546 /** Converter for --subcommands */
547 public static class ShowSubcommandsConverter extends BoolOrEnumConverter<ShowSubcommands> {
548 public ShowSubcommandsConverter() {
549 super(
550 ShowSubcommands.class, "subcommand option", ShowSubcommands.TRUE, ShowSubcommands.FALSE);
551 }
552 }
553
steinman13a628a2019-01-09 08:39:32 -0800554 /**
555 * Converter for --local_cpu_resources, which takes an integer greater than or equal to 1, or
556 * "HOST_CPUS", optionally followed by [-|*]<float>.
557 */
558 public static class CpuResourceConverter extends ResourceConverter {
559 public CpuResourceConverter() {
560 super(
561 ImmutableMap.of(
562 "HOST_CPUS",
563 () -> (int) Math.ceil(LocalHostCapacity.getLocalHostCapacity().getCpuUsage())),
564 1,
565 Integer.MAX_VALUE);
566 }
567
568 @Override
569 public String getTypeDescription() {
570 return "an integer, or \"HOST_CPUS\", optionally followed by [-|*]<float>.";
571 }
572 }
573
574 /**
575 * Converter for --local_cpu_resources, which takes an integer greater than or equal to 1, or
576 * "HOST_RAM", optionally followed by [-|*]<float>.
577 */
578 public static class RamResourceConverter extends ResourceConverter {
579 public RamResourceConverter() {
580 super(
581 ImmutableMap.of(
582 "HOST_RAM",
lberkif1e5e872019-05-23 08:11:58 -0700583 () -> (int) Math.ceil(LocalHostCapacity.getLocalHostCapacity().getMemoryMb())),
steinman13a628a2019-01-09 08:39:32 -0800584 1,
585 Integer.MAX_VALUE);
586 }
587
588 @Override
589 public String getTypeDescription() {
590 return "an integer, or \"HOST_RAM\", optionally followed by [-|*]<float>.";
591 }
592 }
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100593}