blob: a4b79f6d22843da78fef05b9fc8953fd864d8836 [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.runtime;
15
ccalvarin2192b562017-12-14 10:37:41 -080016import static com.google.common.base.Strings.isNullOrEmpty;
17
janakrdfa0b122018-02-28 09:46:06 -080018import com.google.devtools.build.lib.profiler.MemoryProfiler.MemoryProfileStableHeapParameters;
Tobias Werth38877f92019-03-15 09:37:01 -070019import com.google.devtools.build.lib.profiler.ProfilerTask;
ccalvarin93c080a2017-10-16 19:21:08 +020020import com.google.devtools.build.lib.runtime.CommandLineEvent.ToolCommandLineEvent;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010021import com.google.devtools.build.lib.util.OptionsUtils;
22import com.google.devtools.build.lib.vfs.PathFragment;
ccalvarin2192b562017-12-14 10:37:41 -080023import com.google.devtools.common.options.Converter;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010024import com.google.devtools.common.options.Converters;
adgarf3e66ad2019-08-15 13:18:51 -070025import com.google.devtools.common.options.Converters.AssignmentConverter;
Tobias Werth38877f92019-03-15 09:37:01 -070026import com.google.devtools.common.options.EnumConverter;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010027import com.google.devtools.common.options.Option;
ccalvarine73f8812017-06-26 21:40:04 +020028import com.google.devtools.common.options.OptionDocumentationCategory;
ccalvarinc82a1972017-07-17 21:13:39 +020029import com.google.devtools.common.options.OptionEffectTag;
30import com.google.devtools.common.options.OptionMetadataTag;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010031import com.google.devtools.common.options.OptionsBase;
ccalvarin2192b562017-12-14 10:37:41 -080032import com.google.devtools.common.options.OptionsParsingException;
twerth532fc1b2019-11-08 03:08:42 -080033import com.google.devtools.common.options.TriState;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010034import java.util.List;
adgarf3e66ad2019-08-15 13:18:51 -070035import java.util.Map;
ccalvarin2192b562017-12-14 10:37:41 -080036import java.util.UUID;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010037import java.util.logging.Level;
Googler9ba76132022-07-05 11:41:50 -070038import javax.annotation.Nullable;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010039
Googlerd5a29042020-05-11 03:41:09 -070040/** Options common to all commands. */
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010041public class CommonCommandOptions extends OptionsBase {
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010042
lberki42c75182022-03-14 00:41:29 -070043 // It's by design that this field is unused: this command line option takes effect by reading its
44 // value during options parsing based on its (string) name.
ccalvarin2eaa02e2017-04-17 23:37:46 +020045 @Option(
Yun Peng59755452019-08-27 02:26:35 -070046 name = "enable_platform_specific_config",
47 defaultValue = "false",
48 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
49 effectTags = {OptionEffectTag.UNKNOWN},
50 help =
51 "If true, Bazel picks up host-OS-specific config lines from bazelrc files. For example, "
52 + "if the host OS is Linux and you run bazel build, Bazel picks up lines starting "
aldersondrivec35746d2019-12-17 07:08:20 -080053 + "with build:linux. Supported OS identifiers are linux, macos, windows, freebsd, "
54 + "and openbsd. Enabling this flag is equivalent to using --config=linux on Linux, "
Yun Peng59755452019-08-27 02:26:35 -070055 + "--config=windows on Windows, etc.")
56 public boolean enablePlatformSpecificConfig;
57
58 @Option(
Googlerea0c1102020-03-27 09:30:59 -070059 name = "config",
60 defaultValue = "null",
61 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
62 effectTags = {OptionEffectTag.UNKNOWN},
63 allowMultiple = true,
64 help =
65 "Selects additional config sections from the rc files; for every <command>, it "
66 + "also pulls in the options from <command>:<config> if such a section exists; "
67 + "if this section doesn't exist in any .rc file, Blaze fails with an error. "
68 + "The config sections and flag combinations they are equivalent to are "
69 + "located in the tools/*.blazerc config files.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010070 public List<String> configs;
71
ccalvarin2eaa02e2017-04-17 23:37:46 +020072 @Option(
Googlerd5a29042020-05-11 03:41:09 -070073 name = "logging",
74 defaultValue = "3", // Level.INFO
75 documentationCategory = OptionDocumentationCategory.LOGGING,
76 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
77 converter = Converters.LogLevelConverter.class,
78 help = "The logging level.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010079 public Level verbosity;
80
ccalvarin2eaa02e2017-04-17 23:37:46 +020081 @Option(
Googlerd5a29042020-05-11 03:41:09 -070082 name = "client_cwd",
83 defaultValue = "",
84 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
85 metadataTags = {OptionMetadataTag.HIDDEN},
86 effectTags = {OptionEffectTag.CHANGES_INPUTS},
87 converter = OptionsUtils.PathFragmentConverter.class,
88 help = "A system-generated parameter which specifies the client's working directory")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010089 public PathFragment clientCwd;
90
ccalvarin2eaa02e2017-04-17 23:37:46 +020091 @Option(
Googlerd5a29042020-05-11 03:41:09 -070092 name = "announce_rc",
93 defaultValue = "false",
94 documentationCategory = OptionDocumentationCategory.LOGGING,
95 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
96 help = "Whether to announce rc options.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010097 public boolean announceRcOptions;
98
ccalvarin2eaa02e2017-04-17 23:37:46 +020099 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700100 name = "always_profile_slow_operations",
101 defaultValue = "true",
102 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
103 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
104 help = "Whether profiling slow operations is always turned on")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100105 public boolean alwaysProfileSlowOperations;
106
ccalvarin2192b562017-12-14 10:37:41 -0800107 /** Converter for UUID. Accepts values as specified by {@link UUID#fromString(String)}. */
Googler883ce212022-07-06 10:01:59 -0700108 public static class UUIDConverter extends Converter.Contextless<UUID> {
ccalvarin2192b562017-12-14 10:37:41 -0800109
110 @Override
Googler9ba76132022-07-05 11:41:50 -0700111 @Nullable
ccalvarin2192b562017-12-14 10:37:41 -0800112 public UUID convert(String input) throws OptionsParsingException {
113 if (isNullOrEmpty(input)) {
114 return null;
115 }
116 try {
117 return UUID.fromString(input);
118 } catch (IllegalArgumentException e) {
119 throw new OptionsParsingException(
120 String.format("Value '%s' is not a value UUID.", input), e);
121 }
122 }
123
124 @Override
125 public String getTypeDescription() {
126 return "a UUID";
127 }
128 }
129
130 /**
131 * Converter for options (--build_request_id) that accept prefixed UUIDs. Since we do not care
132 * about the structure of this value after validation, we store it as a string.
133 */
Googler883ce212022-07-06 10:01:59 -0700134 public static class PrefixedUUIDConverter extends Converter.Contextless<String> {
ccalvarin2192b562017-12-14 10:37:41 -0800135
136 @Override
Googler9ba76132022-07-05 11:41:50 -0700137 @Nullable
ccalvarin2192b562017-12-14 10:37:41 -0800138 public String convert(String input) throws OptionsParsingException {
139 if (isNullOrEmpty(input)) {
140 return null;
141 }
142 // UUIDs that are accepted by UUID#fromString have 36 characters. Interpret the last 36
143 // characters as an UUID and the rest as a prefix. We do not check anything about the contents
144 // of the prefix.
145 try {
146 int uuidStartIndex = input.length() - 36;
147 UUID.fromString(input.substring(uuidStartIndex));
148 } catch (IllegalArgumentException | IndexOutOfBoundsException e) {
149 throw new OptionsParsingException(
George Gensureb5a2f812018-09-19 12:32:51 -0700150 String.format("Value '%s' does not end in a valid UUID.", input), e);
ccalvarin2192b562017-12-14 10:37:41 -0800151 }
152 return input;
153 }
154
155 @Override
156 public String getTypeDescription() {
157 return "An optionally prefixed UUID. The last 36 characters will be verified as a UUID.";
158 }
159 }
160
161 // Command ID and build request ID can be set either by flag or environment variable. In most
162 // cases, the internally generated ids should be sufficient, but we allow these to be set
163 // externally if required. Option wins over environment variable, if both are set.
164 // TODO(b/67895628) Stop reading ids from the environment after the compatibility window has
165 // passed.
166 @Option(
Googlerf2632d82019-07-30 11:28:50 -0700167 name = "invocation_id",
168 defaultValue = "",
169 converter = UUIDConverter.class,
170 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
171 effectTags = {OptionEffectTag.BAZEL_MONITORING, OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
172 help =
173 "Unique identifier, in UUID format, for the command being run. If explicitly specified"
174 + " uniqueness must be ensured by the caller. The UUID is printed to stderr, the BEP"
175 + " and remote execution protocol.")
ccalvarin2192b562017-12-14 10:37:41 -0800176 public UUID invocationId;
177
178 @Option(
Googlerf2632d82019-07-30 11:28:50 -0700179 name = "build_request_id",
180 defaultValue = "",
181 converter = PrefixedUUIDConverter.class,
182 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
183 effectTags = {OptionEffectTag.BAZEL_MONITORING, OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
184 metadataTags = {OptionMetadataTag.HIDDEN},
185 help = "Unique string identifier for the build being run.")
ccalvarin2192b562017-12-14 10:37:41 -0800186 public String buildRequestId;
187
Googler65ceda92017-05-31 18:09:32 +0200188 @Option(
adgarf3e66ad2019-08-15 13:18:51 -0700189 name = "build_metadata",
190 converter = AssignmentConverter.class,
Googlerea0c1102020-03-27 09:30:59 -0700191 defaultValue = "null",
adgarf3e66ad2019-08-15 13:18:51 -0700192 allowMultiple = true,
193 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
194 effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
195 help = "Custom key-value string pairs to supply in a build event.")
196 public List<Map.Entry<String, String>> buildMetadata;
197
198 @Option(
Googler372f4122019-06-12 08:37:42 -0700199 name = "oom_message",
200 defaultValue = "",
201 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
202 effectTags = {OptionEffectTag.BAZEL_MONITORING, OptionEffectTag.TERMINAL_OUTPUT},
203 metadataTags = {OptionMetadataTag.HIDDEN},
204 help = "Custom message to be emitted on an out of memory failure.")
205 public String oomMessage;
206
207 @Option(
twerth35c27f3e2020-12-03 06:23:41 -0800208 name = "generate_json_trace_profile",
209 oldName = "experimental_generate_json_trace_profile",
210 defaultValue = "auto",
twerth7bb536d2019-06-19 05:57:51 -0700211 documentationCategory = OptionDocumentationCategory.LOGGING,
212 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
213 help =
214 "If enabled, Bazel profiles the build and writes a JSON-format profile into a file in"
twerth35c27f3e2020-12-03 06:23:41 -0800215 + " the output base. View profile by loading into chrome://tracing. By default Bazel"
216 + " writes the profile for all build-like commands and query.")
217 public TriState enableTracer;
ulfjack400fffe2018-06-12 12:21:25 -0700218
219 @Option(
Tobias Werth38877f92019-03-15 09:37:01 -0700220 name = "experimental_profile_additional_tasks",
221 converter = ProfilerTaskConverter.class,
Googlerd5a29042020-05-11 03:41:09 -0700222 defaultValue = "null",
Tobias Werth38877f92019-03-15 09:37:01 -0700223 allowMultiple = true,
224 documentationCategory = OptionDocumentationCategory.LOGGING,
225 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
226 help = "Specifies additional profile tasks to be included in the profile.")
227 public List<ProfilerTask> additionalProfileTasks;
228
229 @Option(
twerthb5b89112020-04-07 09:00:09 -0700230 name = "slim_profile",
231 oldName = "experimental_slim_json_profile",
232 defaultValue = "true",
twerthadea1a72019-03-21 09:28:24 -0700233 documentationCategory = OptionDocumentationCategory.LOGGING,
234 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
235 help =
236 "Slims down the size of the JSON profile by merging events if the profile gets "
237 + " too large.")
twerthb5b89112020-04-07 09:00:09 -0700238 public boolean slimProfile;
twerthadea1a72019-03-21 09:28:24 -0700239
twerth2bc07c42019-04-11 08:14:00 -0700240 @Option(
twerthd22bb662020-06-04 05:20:25 -0700241 name = "experimental_profile_include_primary_output",
242 oldName = "experimental_include_primary_output",
lebaf5554192020-02-19 04:30:19 -0800243 defaultValue = "false",
244 documentationCategory = OptionDocumentationCategory.LOGGING,
245 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
246 help =
247 "Includes the extra \"out\" attribute in action events that contains the exec path "
248 + "to the action's primary output.")
249 public boolean includePrimaryOutput;
250
251 @Option(
Sergey Balabanoveb048fd2020-06-04 01:35:28 -0700252 name = "experimental_profile_include_target_label",
253 defaultValue = "false",
254 documentationCategory = OptionDocumentationCategory.LOGGING,
255 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
256 help = "Includes target label in action events' JSON profile data.")
257 public boolean profileIncludeTargetLabel;
258
259 @Option(
twerthf62586a2019-10-21 01:21:12 -0700260 name = "experimental_announce_profile_path",
twerthec3a5622019-11-05 01:21:26 -0800261 defaultValue = "false",
twerthf62586a2019-10-21 01:21:12 -0700262 documentationCategory = OptionDocumentationCategory.LOGGING,
263 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
264 help = "If enabled, adds the JSON profile path to the log.")
265 public boolean announceProfilePath;
266
267 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700268 name = "profile",
269 defaultValue = "null",
270 documentationCategory = OptionDocumentationCategory.LOGGING,
271 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
Keith Smileye521aad2021-07-28 06:12:59 -0700272 converter = OptionsUtils.PathFragmentConverter.class,
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700273 help =
274 "If set, profile Bazel and write data to the specified "
275 + "file. Use bazel analyze-profile to analyze the profile.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100276 public PathFragment profilePath;
277
ccalvarin2eaa02e2017-04-17 23:37:46 +0200278 @Option(
adonovan329ec6d2020-02-06 15:34:49 -0800279 name = "starlark_cpu_profile",
280 defaultValue = "",
281 documentationCategory = OptionDocumentationCategory.LOGGING,
282 effectTags = {OptionEffectTag.BAZEL_MONITORING},
283 help = "Writes into the specified file a pprof profile of CPU usage by all Starlark threads.")
284 public String starlarkCpuProfile;
285
286 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700287 name = "record_full_profiler_data",
288 defaultValue = "false",
289 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
290 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
291 help =
292 "By default, Bazel profiler will record only aggregated data for fast but numerous "
293 + "events (such as statting the file). If this option is enabled, profiler will "
294 + "record each event - resulting in more precise profiling data but LARGE "
295 + "performance hit. Option only has effect if --profile used as well.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100296 public boolean recordFullProfilerData;
297
ccalvarin2eaa02e2017-04-17 23:37:46 +0200298 @Option(
Googlerbe5354b2022-07-12 07:32:22 -0700299 name = "experimental_collect_worker_data_in_profiler",
300 defaultValue = "false",
301 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
302 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
Googlerb4dbed02022-08-18 08:47:46 -0700303 help = "If enabled, the profiler collects worker's aggregated resource data.")
Googlerbe5354b2022-07-12 07:32:22 -0700304 public boolean collectWorkerDataInProfiler;
305
306 @Option(
Googlerb4dbed02022-08-18 08:47:46 -0700307 name = "experimental_collect_load_average_in_profiler",
Googler390d2122022-09-14 07:12:40 -0700308 defaultValue = "true",
Googlerb4dbed02022-08-18 08:47:46 -0700309 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
310 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
311 help = "If enabled, the profiler collects the system's overall load average.")
312 public boolean collectLoadAverageInProfiler;
313
314 @Option(
Googlere382cb22022-09-12 07:34:24 -0700315 name = "experimental_collect_system_network_usage",
316 defaultValue = "false",
317 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
318 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
319 help = "If enabled, the profiler collects the system's network usage.")
320 public boolean collectSystemNetworkUsage;
321
322 @Option(
Googler2e2f5d92022-12-06 03:11:45 -0800323 name = "experimental_collect_resource_estimation",
324 defaultValue = "false",
325 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
326 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
327 help = "If enabled, the profiler collects CPU and memory usage estimation for local actions.")
328 public boolean collectResourceEstimation;
329
330 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700331 name = "memory_profile",
332 defaultValue = "null",
Googler54575fb2022-06-13 05:55:16 -0700333 documentationCategory = OptionDocumentationCategory.LOGGING,
Googlerd5a29042020-05-11 03:41:09 -0700334 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
Keith Smileye521aad2021-07-28 06:12:59 -0700335 converter = OptionsUtils.PathFragmentConverter.class,
Googlerd5a29042020-05-11 03:41:09 -0700336 help =
337 "If set, write memory usage data to the specified file at phase ends and stable heap to"
338 + " master log at end of build.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100339 public PathFragment memoryProfilePath;
340
ccalvarin2eaa02e2017-04-17 23:37:46 +0200341 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700342 name = "memory_profile_stable_heap_parameters",
343 defaultValue = "1,0",
344 documentationCategory = OptionDocumentationCategory.LOGGING,
345 effectTags = {OptionEffectTag.BAZEL_MONITORING},
346 converter = MemoryProfileStableHeapParameters.Converter.class,
347 help =
Googler3dc69512022-11-02 11:20:38 -0700348 "Tune memory profile's computation of stable heap at end of build. Should be and even"
349 + " number of integers separated by commas. In each pair the first integer is the"
350 + " number of GCs to perform. The second integer in each pair is the number of"
351 + " seconds to wait between GCs. Ex: 2,4,4,0 would 2 GCs with a 4sec pause, followed"
352 + " by 4 GCs with zero second pause")
janakrdfa0b122018-02-28 09:46:06 -0800353 public MemoryProfileStableHeapParameters memoryProfileStableHeapParameters;
354
355 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700356 name = "experimental_oom_more_eagerly_threshold",
357 defaultValue = "100",
358 documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY,
359 effectTags = {OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS},
360 help =
361 "If this flag is set to a value less than 100, Bazel will OOM if, after two full GC's, "
362 + "more than this percentage of the (old gen) heap is still occupied.")
janakrff746b42017-08-15 21:09:50 +0200363 public int oomMoreEagerlyThreshold;
364
365 @Option(
nharmata343ba432021-12-27 16:10:47 -0800366 name = "skyframe_high_water_mark_threshold",
367 defaultValue = "85",
368 documentationCategory = OptionDocumentationCategory.BUILD_TIME_OPTIMIZATION,
369 effectTags = {OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS},
370 help =
371 "Flag for advanced configuration of Bazel's internal Skyframe engine. If Bazel detects"
372 + " its retained heap percentage usage is at least this threshold, it will drop"
373 + " unnecessary temporary Skyframe state. Tweaking this may let you mitigate wall"
374 + " time impact of GC thrashing, when the GC thrashing is (i) caused by the memory"
375 + " usage of this temporary state and (ii) more costly than reconstituting the state"
376 + " when it is needed.")
377 public int skyframeHighWaterMarkMemoryThreshold;
378
379 @Option(
jhorvitzbf6987d2021-06-04 18:12:13 -0700380 name = "heap_dump_on_oom",
jhorvitz10fe9172021-05-03 11:53:56 -0700381 defaultValue = "false",
382 documentationCategory = OptionDocumentationCategory.LOGGING,
383 effectTags = {OptionEffectTag.BAZEL_MONITORING},
384 help =
jhorvitzbf6987d2021-06-04 18:12:13 -0700385 "Whether to manually output a heap dump if an OOM is thrown (including OOMs due to"
386 + " --experimental_oom_more_eagerly_threshold). The dump will be written to"
387 + " <output_base>/<invocation_id>.heapdump.hprof. This option effectively replaces"
388 + " -XX:+HeapDumpOnOutOfMemoryError, which has no effect because OOMs are caught and"
389 + " redirected to Runtime#halt.")
390 public boolean heapDumpOnOom;
jhorvitz10fe9172021-05-03 11:53:56 -0700391
392 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700393 name = "startup_time",
394 defaultValue = "0",
395 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
396 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
397 metadataTags = {OptionMetadataTag.HIDDEN},
398 help = "The time in ms the launcher spends before sending the request to the bazel server.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100399 public long startupTime;
400
Thiago Farina36c1d152016-05-04 14:24:14 +0000401 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700402 name = "extract_data_time",
403 defaultValue = "0",
404 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
405 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
406 metadataTags = {OptionMetadataTag.HIDDEN},
407 help = "The time in ms spent on extracting the new bazel version.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100408 public long extractDataTime;
409
ccalvarin2eaa02e2017-04-17 23:37:46 +0200410 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700411 name = "command_wait_time",
412 defaultValue = "0",
413 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
414 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
415 metadataTags = {OptionMetadataTag.HIDDEN},
416 help = "The time in ms a command had to wait on a busy Bazel server process.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100417 public long waitTime;
418
ccalvarin2eaa02e2017-04-17 23:37:46 +0200419 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700420 name = "tool_tag",
421 defaultValue = "",
422 documentationCategory = OptionDocumentationCategory.LOGGING,
423 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
424 help = "A tool name to attribute this Bazel invocation to.")
Googler88e31042015-07-08 19:16:57 +0000425 public String toolTag;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100426
ccalvarin2eaa02e2017-04-17 23:37:46 +0200427 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700428 name = "restart_reason",
429 defaultValue = "no_restart",
430 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
431 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
432 metadataTags = {OptionMetadataTag.HIDDEN},
433 help = "The reason for the server restart.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100434 public String restartReason;
435
ccalvarin2eaa02e2017-04-17 23:37:46 +0200436 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700437 name = "binary_path",
438 defaultValue = "",
439 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
440 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
441 metadataTags = {OptionMetadataTag.HIDDEN},
442 help = "The absolute path of the bazel binary.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100443 public String binaryPath;
444
ccalvarin2eaa02e2017-04-17 23:37:46 +0200445 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700446 name = "experimental_allow_project_files",
447 defaultValue = "false",
448 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
449 effectTags = {OptionEffectTag.CHANGES_INPUTS},
450 metadataTags = {OptionMetadataTag.EXPERIMENTAL, OptionMetadataTag.HIDDEN},
451 help = "Enable processing of +<file> parameters.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100452 public boolean allowProjectFiles;
Lukacs Berkice1445f2016-04-19 15:52:55 +0000453
ccalvarin2eaa02e2017-04-17 23:37:46 +0200454 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700455 name = "block_for_lock",
456 defaultValue = "true",
457 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
458 effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
459 metadataTags = {OptionMetadataTag.HIDDEN},
460 help =
461 "If set (the default), a command will block if there is another one running. If "
462 + "unset, these commands will immediately return with an error.")
Lukacs Berkice1445f2016-04-19 15:52:55 +0000463 public boolean blockForLock;
ccalvarin93c080a2017-10-16 19:21:08 +0200464
465 // We could accept multiple of these, in the event where there's a chain of tools that led to a
466 // Bazel invocation. We would not want to expect anything from the order of these, and would need
467 // to guarantee that the "label" for each command line is unique. Unless a need is demonstrated,
468 // though, logs are a better place to track this information than flags, so let's try to avoid it.
469 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700470 // In May 2018, this feature will have been out for 6 months. If the format we accept has not
471 // changed in that time, we can remove the "experimental" prefix and tag.
472 name = "experimental_tool_command_line",
473 defaultValue = "",
474 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
475 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
476 // Keep this flag HIDDEN so that it is not listed with our reported command lines, it being
477 // reported separately.
478 metadataTags = {OptionMetadataTag.EXPERIMENTAL, OptionMetadataTag.HIDDEN},
479 converter = ToolCommandLineEvent.Converter.class,
480 help =
481 "An extra command line to report with this invocation's command line. Useful for tools "
482 + "that invoke Bazel and want the original information that the tool received to be "
483 + "logged with the rest of the Bazel invocation.")
ccalvarin93c080a2017-10-16 19:21:08 +0200484 public ToolCommandLineEvent toolCommandLine;
ccalvarin0dd5a682017-11-10 01:40:01 +0100485
486 @Option(
Googlerea0c1102020-03-27 09:30:59 -0700487 name = "unconditional_warning",
488 defaultValue = "null",
489 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
490 effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
491 allowMultiple = true,
492 help =
493 "A warning that will unconditionally get printed with build warnings and errors. This is"
494 + " useful to deprecate bazelrc files or --config definitions. If the intent is to"
495 + " effectively deprecate some flag or combination of flags, this is NOT sufficient."
496 + " The flag or flags should use the deprecationWarning field in the option"
497 + " definition, or the bad combination should be checked for programmatically.")
ccalvarin0dd5a682017-11-10 01:40:01 +0100498 public List<String> deprecationWarnings;
janakrdfa0b122018-02-28 09:46:06 -0800499
fellyac7d5f62018-05-15 10:57:33 -0700500 @Option(
501 name = "track_incremental_state",
502 oldName = "keep_incrementality_data",
503 defaultValue = "true",
504 documentationCategory = OptionDocumentationCategory.BUILD_TIME_OPTIMIZATION,
505 effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE},
506 help =
507 "If false, Blaze will not persist data that allows for invalidation and re-evaluation "
508 + "on incremental builds in order to save memory on this build. Subsequent builds "
509 + "will not have any incrementality with respect to this one. Usually you will want "
Googlerd5a29042020-05-11 03:41:09 -0700510 + "to specify --batch when setting this to false.")
fellyac7d5f62018-05-15 10:57:33 -0700511 public boolean trackIncrementalState;
512
513 @Option(
514 name = "keep_state_after_build",
515 defaultValue = "true",
516 documentationCategory = OptionDocumentationCategory.BUILD_TIME_OPTIMIZATION,
517 effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE},
518 help =
519 "If false, Blaze will discard the inmemory state from this build when the build "
520 + "finishes. Subsequent builds will not have any incrementality with respect to this "
Googlerd5a29042020-05-11 03:41:09 -0700521 + "one.")
fellyac7d5f62018-05-15 10:57:33 -0700522 public boolean keepStateAfterBuild;
Tobias Werth38877f92019-03-15 09:37:01 -0700523
Cristian Hancilac2bdd032021-03-25 07:53:47 -0700524 @Option(
525 name = "repo_env",
526 converter = Converters.OptionalAssignmentConverter.class,
527 allowMultiple = true,
528 defaultValue = "null",
529 documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
530 effectTags = {OptionEffectTag.ACTION_COMMAND_LINES},
531 help =
532 "Specifies additional environment variables to be available only for repository rules."
533 + " Note that repository rules see the full environment anyway, but in this way"
534 + " configuration information can be passed to repositories through options without"
535 + " invalidating the action graph.")
536 public List<Map.Entry<String, String>> repositoryEnvironment;
537
Tobias Werth38877f92019-03-15 09:37:01 -0700538 /** The option converter to check that the user can only specify legal profiler tasks. */
539 public static class ProfilerTaskConverter extends EnumConverter<ProfilerTask> {
540 public ProfilerTaskConverter() {
541 super(ProfilerTask.class, "profiler task");
542 }
543 }
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100544}