Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Bazel Authors. All rights reserved. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 2 | // |
| 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. |
| 14 | package com.google.devtools.build.lib.exec; |
| 15 | |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 16 | import com.google.common.collect.ImmutableMap; |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 17 | import com.google.common.collect.Iterables; |
ahumesky | be31bb8 | 2018-07-26 13:37:45 -0700 | [diff] [blame] | 18 | import com.google.devtools.build.lib.actions.ActionExecutionContext.ShowSubcommands; |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 19 | import com.google.devtools.build.lib.actions.LocalHostCapacity; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 20 | import com.google.devtools.build.lib.actions.ResourceSet; |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 21 | import com.google.devtools.build.lib.analysis.config.PerLabelOptions; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 22 | import com.google.devtools.build.lib.util.OptionsUtils; |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 23 | import com.google.devtools.build.lib.util.RegexFilter; |
Googler | 7859ff2 | 2018-12-21 10:12:48 -0800 | [diff] [blame] | 24 | import com.google.devtools.build.lib.util.ResourceConverter; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 25 | import com.google.devtools.build.lib.vfs.PathFragment; |
ahumesky | be31bb8 | 2018-07-26 13:37:45 -0700 | [diff] [blame] | 26 | import com.google.devtools.common.options.BoolOrEnumConverter; |
philwo | 207ac6e | 2019-02-20 12:44:06 -0800 | [diff] [blame] | 27 | import com.google.devtools.common.options.Converters.AssignmentToListOfValuesConverter; |
| 28 | import com.google.devtools.common.options.Converters.CommaSeparatedNonEmptyOptionListConverter; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 29 | import com.google.devtools.common.options.Option; |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 30 | import com.google.devtools.common.options.OptionDocumentationCategory; |
ccalvarin | c82a197 | 2017-07-17 21:13:39 +0200 | [diff] [blame] | 31 | import com.google.devtools.common.options.OptionEffectTag; |
philwo | 849113c | 2019-02-20 15:09:30 -0800 | [diff] [blame] | 32 | import com.google.devtools.common.options.OptionMetadataTag; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 33 | import com.google.devtools.common.options.Options; |
| 34 | import com.google.devtools.common.options.OptionsBase; |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 35 | import com.google.devtools.common.options.OptionsParsingException; |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 36 | import java.util.Collections; |
| 37 | import java.util.List; |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 38 | import java.util.Map; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Options affecting the execution phase of a build. |
| 42 | * |
Googler | c023bc2 | 2015-03-20 16:26:08 +0000 | [diff] [blame] | 43 | * These options are interpreted by the BuildTool to choose an Executor to |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 44 | * be used for the build. |
| 45 | * |
Googler | c023bc2 | 2015-03-20 16:26:08 +0000 | [diff] [blame] | 46 | * Note: from the user's point of view, the characteristic function of this |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 47 | * 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 | */ |
| 56 | public class ExecutionOptions extends OptionsBase { |
| 57 | |
| 58 | public static final ExecutionOptions DEFAULTS = Options.getDefaults(ExecutionOptions.class); |
| 59 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 60 | @Option( |
philwo | 849113c | 2019-02-20 15:09:30 -0800 | [diff] [blame] | 61 | name = "incompatible_list_based_execution_strategy_selection", |
ishikhman | 3703333 | 2019-05-16 10:27:29 -0700 | [diff] [blame] | 62 | defaultValue = "true", |
philwo | 849113c | 2019-02-20 15:09:30 -0800 | [diff] [blame] | 63 | 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( |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 73 | name = "spawn_strategy", |
| 74 | defaultValue = "", |
philwo | 207ac6e | 2019-02-20 12:44:06 -0800 | [diff] [blame] | 75 | converter = CommaSeparatedNonEmptyOptionListConverter.class, |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 76 | 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).") |
philwo | 207ac6e | 2019-02-20 12:44:06 -0800 | [diff] [blame] | 83 | public List<String> spawnStrategy; |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 84 | |
| 85 | @Option( |
| 86 | name = "genrule_strategy", |
| 87 | defaultValue = "", |
philwo | 849113c | 2019-02-20 15:09:30 -0800 | [diff] [blame] | 88 | converter = CommaSeparatedNonEmptyOptionListConverter.class, |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 89 | 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.") |
philwo | 207ac6e | 2019-02-20 12:44:06 -0800 | [diff] [blame] | 95 | public List<String> genruleStrategy; |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 96 | |
| 97 | @Option( |
| 98 | name = "strategy", |
| 99 | allowMultiple = true, |
philwo | 207ac6e | 2019-02-20 12:44:06 -0800 | [diff] [blame] | 100 | converter = AssignmentToListOfValuesConverter.class, |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 101 | 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. ") |
philwo | 207ac6e | 2019-02-20 12:44:06 -0800 | [diff] [blame] | 108 | public List<Map.Entry<String, List<String>>> strategy; |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 109 | |
| 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'. ") |
philwo | 207ac6e | 2019-02-20 12:44:06 -0800 | [diff] [blame] | 128 | public List<Map.Entry<RegexFilter, List<String>>> strategyByRegexp; |
philwo | 784557b | 2019-01-04 05:33:12 -0800 | [diff] [blame] | 129 | |
| 130 | @Option( |
tomlu | 09fe062 | 2018-06-19 12:55:39 -0700 | [diff] [blame] | 131 | 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( |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 141 | name = "verbose_failures", |
| 142 | defaultValue = "false", |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 143 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 144 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 145 | help = "If a command fails, print out the full command line." |
| 146 | ) |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 147 | public boolean verboseFailures; |
| 148 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 149 | @Option( |
| 150 | name = "subcommands", |
| 151 | abbrev = 's', |
| 152 | defaultValue = "false", |
ahumesky | be31bb8 | 2018-07-26 13:37:45 -0700 | [diff] [blame] | 153 | converter = ShowSubcommandsConverter.class, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 154 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 155 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 156 | help = "Display the subcommands executed during a build." |
| 157 | ) |
ahumesky | be31bb8 | 2018-07-26 13:37:45 -0700 | [diff] [blame] | 158 | public ShowSubcommands showSubcommands; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 159 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 160 | @Option( |
| 161 | name = "check_up_to_date", |
| 162 | defaultValue = "false", |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 163 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 164 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 165 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 170 | public boolean checkUpToDate; |
| 171 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 172 | @Option( |
| 173 | name = "check_tests_up_to_date", |
| 174 | defaultValue = "false", |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 175 | implicitRequirements = {"--check_up_to_date"}, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 176 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 177 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 178 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 184 | public boolean testCheckUpToDate; |
| 185 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 186 | @Option( |
| 187 | name = "test_strategy", |
| 188 | defaultValue = "", |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 189 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 190 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 191 | help = "Specifies which strategy to use when running tests." |
| 192 | ) |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 193 | public String testStrategy; |
| 194 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 195 | @Option( |
| 196 | name = "test_keep_going", |
| 197 | defaultValue = "true", |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 198 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 199 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 200 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 204 | public boolean testKeepGoing; |
| 205 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 206 | @Option( |
| 207 | name = "runs_per_test_detects_flakes", |
| 208 | defaultValue = "false", |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 209 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 210 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 211 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 215 | public boolean runsPerTestDetectsFlakes; |
| 216 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 217 | @Option( |
| 218 | name = "flaky_test_attempts", |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 219 | allowMultiple = true, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 220 | defaultValue = "default", |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 221 | converter = TestAttemptsConverter.class, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 222 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 223 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 224 | 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 | ) |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 233 | public List<PerLabelOptions> testAttempts; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 234 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 235 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 236 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 242 | public PathFragment testTmpDir; |
| 243 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 244 | @Option( |
| 245 | name = "test_output", |
| 246 | defaultValue = "summary", |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 247 | converter = TestStrategy.TestOutputFormat.Converter.class, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 248 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 249 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 250 | 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 | ) |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 257 | public TestStrategy.TestOutputFormat testOutput; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 258 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 259 | @Option( |
| 260 | name = "test_summary", |
| 261 | defaultValue = "short", |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 262 | converter = TestStrategy.TestSummaryFormat.Converter.class, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 263 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 264 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 265 | 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 Aehlig | 1d71c0c | 2017-08-30 14:58:28 +0200 | [diff] [blame] | 268 | + "unsuccessful tests that were run, 'detailed' to print detailed information about " |
| 269 | + "failed test cases, and 'none' to omit the summary." |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 270 | ) |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 271 | public TestStrategy.TestSummaryFormat testSummary; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 272 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 273 | @Option( |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 274 | name = "resource_autosense", |
| 275 | defaultValue = "false", |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 276 | documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, |
| 277 | effectTags = {OptionEffectTag.UNKNOWN}, |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 278 | help = "This flag has no effect, and is deprecated" |
| 279 | ) |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 280 | public boolean useResourceAutoSense; |
| 281 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 282 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 283 | name = "ram_utilization_factor", |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 284 | defaultValue = "0", |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 285 | 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. " |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 292 | + "Using a value higher than 67 is NOT recommended. " |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 293 | + "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 " |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 296 | + "server itself will use. " |
| 297 | + "Setting this value overrides --local_ram_resources") |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 298 | public int ramUtilizationPercentage; |
| 299 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 300 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 301 | 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, " |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 311 | + "Bazel will ignore --ram_utilization_factor, --local_cpu_resources, and " |
| 312 | + "--local_ram_resources.", |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 313 | converter = ResourceSet.ResourceSetConverter.class) |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 314 | public ResourceSet availableResources; |
Mark Schaller | dffb6ee | 2015-02-25 20:01:01 +0000 | [diff] [blame] | 315 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 316 | @Option( |
steinman | 3501b21 | 2019-03-25 12:36:43 -0700 | [diff] [blame] | 317 | 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( |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 331 | 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 Pieper | 7f3bddd | 2018-05-04 00:39:37 -0700 | [diff] [blame] | 362 | 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( |
Googler | 7859ff2 | 2018-12-21 10:12:48 -0800 | [diff] [blame] | 377 | 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 Schaller | dffb6ee | 2015-02-25 20:01:01 +0000 | [diff] [blame] | 389 | public int localTestJobs; |
| 390 | |
| 391 | public boolean usingLocalTestJobs() { |
| 392 | return localTestJobs != 0; |
| 393 | } |
Philipp Wollermann | 4ca5dfa | 2017-02-01 13:45:55 +0000 | [diff] [blame] | 394 | |
| 395 | @Option( |
| 396 | name = "debug_print_action_contexts", |
| 397 | defaultValue = "false", |
ccalvarin | 456adb2 | 2017-07-11 14:23:46 +0200 | [diff] [blame] | 398 | documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 399 | effectTags = {OptionEffectTag.UNKNOWN}, |
Philipp Wollermann | 4ca5dfa | 2017-02-01 13:45:55 +0000 | [diff] [blame] | 400 | help = "Print the contents of the SpawnActionContext and ContextProviders maps." |
| 401 | ) |
| 402 | public boolean debugPrintActionContexts; |
Julio Merino | 7ac6d59 | 2017-03-16 19:12:32 +0000 | [diff] [blame] | 403 | |
| 404 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 405 | 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 Merino | 7ac6d59 | 2017-03-16 19:12:32 +0000 | [diff] [blame] | 415 | public long cacheSizeForComputedFileDigests; |
janakr | 1fb90fd | 2017-03-30 21:07:04 +0000 | [diff] [blame] | 416 | |
janakr | 1fb90fd | 2017-03-30 21:07:04 +0000 | [diff] [blame] | 417 | @Option( |
| 418 | name = "experimental_enable_critical_path_profiling", |
| 419 | defaultValue = "true", |
ccalvarin | 456adb2 | 2017-07-11 14:23:46 +0200 | [diff] [blame] | 420 | documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 421 | effectTags = {OptionEffectTag.UNKNOWN}, |
janakr | 1fb90fd | 2017-03-30 21:07:04 +0000 | [diff] [blame] | 422 | 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; |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 428 | |
olaola | 913b66c | 2018-04-19 10:43:53 -0700 | [diff] [blame] | 429 | @Option( |
ulfjack | 97a3ee4 | 2018-11-20 05:40:35 -0800 | [diff] [blame] | 430 | 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( |
Googler | d03d3f3 | 2019-04-16 08:06:23 -0700 | [diff] [blame] | 439 | 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; |
olaola | 913b66c | 2018-04-19 10:43:53 -0700 | [diff] [blame] | 469 | |
ulfjack | 0858ae1 | 2018-07-27 02:37:53 -0700 | [diff] [blame] | 470 | @Option( |
ulfjack | 6da8982 | 2019-02-04 13:06:34 -0800 | [diff] [blame] | 471 | 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.") |
ulfjack | 0858ae1 | 2018-07-27 02:37:53 -0700 | [diff] [blame] | 479 | public boolean splitXmlGeneration; |
| 480 | |
jcater | 2dd46e6 | 2018-02-20 14:00:33 -0800 | [diff] [blame] | 481 | /** 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 | } |
ahumesky | be31bb8 | 2018-07-26 13:37:45 -0700 | [diff] [blame] | 538 | |
Googler | 7859ff2 | 2018-12-21 10:12:48 -0800 | [diff] [blame] | 539 | /** 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 | |
ahumesky | be31bb8 | 2018-07-26 13:37:45 -0700 | [diff] [blame] | 546 | /** 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 | |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 554 | /** |
| 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", |
lberki | f1e5e87 | 2019-05-23 08:11:58 -0700 | [diff] [blame] | 583 | () -> (int) Math.ceil(LocalHostCapacity.getLocalHostCapacity().getMemoryMb())), |
steinman | 13a628a | 2019-01-09 08:39:32 -0800 | [diff] [blame] | 584 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 593 | } |