blob: 9657df3e263d68e8dddb9ae7db6e27828a5b01c2 [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,
Googler01ca1f72023-01-17 15:30:15 -0800212 effectTags = {OptionEffectTag.BAZEL_MONITORING},
twerth7bb536d2019-06-19 05:57:51 -0700213 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,
Googler01ca1f72023-01-17 15:30:15 -0800225 effectTags = {OptionEffectTag.BAZEL_MONITORING},
Tobias Werth38877f92019-03-15 09:37:01 -0700226 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,
Googler01ca1f72023-01-17 15:30:15 -0800234 effectTags = {OptionEffectTag.BAZEL_MONITORING},
twerthadea1a72019-03-21 09:28:24 -0700235 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,
Googler01ca1f72023-01-17 15:30:15 -0800245 effectTags = {OptionEffectTag.BAZEL_MONITORING},
lebaf5554192020-02-19 04:30:19 -0800246 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,
Googler01ca1f72023-01-17 15:30:15 -0800255 effectTags = {OptionEffectTag.BAZEL_MONITORING},
Sergey Balabanoveb048fd2020-06-04 01:35:28 -0700256 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,
Googler01ca1f72023-01-17 15:30:15 -0800263 effectTags = {OptionEffectTag.BAZEL_MONITORING},
twerthf62586a2019-10-21 01:21:12 -0700264 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,
Googler01ca1f72023-01-17 15:30:15 -0800271 effectTags = {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",
Googler01ca1f72023-01-17 15:30:15 -0800289 documentationCategory = OptionDocumentationCategory.LOGGING,
290 effectTags = {OptionEffectTag.BAZEL_MONITORING},
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700291 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",
Googler01ca1f72023-01-17 15:30:15 -0800301 documentationCategory = OptionDocumentationCategory.LOGGING,
302 effectTags = {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",
Googler01ca1f72023-01-17 15:30:15 -0800309 documentationCategory = OptionDocumentationCategory.LOGGING,
310 effectTags = {OptionEffectTag.BAZEL_MONITORING},
Googlerb4dbed02022-08-18 08:47:46 -0700311 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",
Googler01ca1f72023-01-17 15:30:15 -0800317 documentationCategory = OptionDocumentationCategory.LOGGING,
318 effectTags = {OptionEffectTag.BAZEL_MONITORING},
Googlere382cb22022-09-12 07:34:24 -0700319 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",
Googler01ca1f72023-01-17 15:30:15 -0800325 documentationCategory = OptionDocumentationCategory.LOGGING,
326 effectTags = {OptionEffectTag.BAZEL_MONITORING},
Googler2e2f5d92022-12-06 03:11:45 -0800327 help = "If enabled, the profiler collects CPU and memory usage estimation for local actions.")
328 public boolean collectResourceEstimation;
329
330 @Option(
Googler50446bc2023-02-15 00:48:17 -0800331 name = "experimental_collect_pressure_stall_indicators",
332 defaultValue = "false",
333 documentationCategory = OptionDocumentationCategory.LOGGING,
334 effectTags = {OptionEffectTag.BAZEL_MONITORING},
335 help = "If enabled, the profiler collects the Linux PSI data.")
336 public boolean collectPressureStallIndicators;
337
338 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700339 name = "memory_profile",
340 defaultValue = "null",
Googler54575fb2022-06-13 05:55:16 -0700341 documentationCategory = OptionDocumentationCategory.LOGGING,
Googler01ca1f72023-01-17 15:30:15 -0800342 effectTags = {OptionEffectTag.BAZEL_MONITORING},
Keith Smileye521aad2021-07-28 06:12:59 -0700343 converter = OptionsUtils.PathFragmentConverter.class,
Googlerd5a29042020-05-11 03:41:09 -0700344 help =
345 "If set, write memory usage data to the specified file at phase ends and stable heap to"
346 + " master log at end of build.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100347 public PathFragment memoryProfilePath;
348
ccalvarin2eaa02e2017-04-17 23:37:46 +0200349 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700350 name = "memory_profile_stable_heap_parameters",
351 defaultValue = "1,0",
352 documentationCategory = OptionDocumentationCategory.LOGGING,
353 effectTags = {OptionEffectTag.BAZEL_MONITORING},
354 converter = MemoryProfileStableHeapParameters.Converter.class,
355 help =
Googler3dc69512022-11-02 11:20:38 -0700356 "Tune memory profile's computation of stable heap at end of build. Should be and even"
357 + " number of integers separated by commas. In each pair the first integer is the"
358 + " number of GCs to perform. The second integer in each pair is the number of"
359 + " seconds to wait between GCs. Ex: 2,4,4,0 would 2 GCs with a 4sec pause, followed"
360 + " by 4 GCs with zero second pause")
janakrdfa0b122018-02-28 09:46:06 -0800361 public MemoryProfileStableHeapParameters memoryProfileStableHeapParameters;
362
nharmata343ba432021-12-27 16:10:47 -0800363 @Option(
jhorvitzbf6987d2021-06-04 18:12:13 -0700364 name = "heap_dump_on_oom",
jhorvitz10fe9172021-05-03 11:53:56 -0700365 defaultValue = "false",
366 documentationCategory = OptionDocumentationCategory.LOGGING,
367 effectTags = {OptionEffectTag.BAZEL_MONITORING},
368 help =
Googlera3ba48e2023-08-01 08:27:08 -0700369 "Whether to manually output a heap dump if an OOM is thrown (including manual OOMs due to"
370 + " reaching --gc_thrashing_limits). The dump will be written to"
jhorvitzbf6987d2021-06-04 18:12:13 -0700371 + " <output_base>/<invocation_id>.heapdump.hprof. This option effectively replaces"
Googlera3ba48e2023-08-01 08:27:08 -0700372 + " -XX:+HeapDumpOnOutOfMemoryError, which has no effect for manual OOMs.")
jhorvitzbf6987d2021-06-04 18:12:13 -0700373 public boolean heapDumpOnOom;
jhorvitz10fe9172021-05-03 11:53:56 -0700374
375 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700376 name = "startup_time",
377 defaultValue = "0",
378 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
379 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
380 metadataTags = {OptionMetadataTag.HIDDEN},
381 help = "The time in ms the launcher spends before sending the request to the bazel server.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100382 public long startupTime;
383
Thiago Farina36c1d152016-05-04 14:24:14 +0000384 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700385 name = "extract_data_time",
386 defaultValue = "0",
387 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
388 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
389 metadataTags = {OptionMetadataTag.HIDDEN},
390 help = "The time in ms spent on extracting the new bazel version.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100391 public long extractDataTime;
392
ccalvarin2eaa02e2017-04-17 23:37:46 +0200393 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700394 name = "command_wait_time",
395 defaultValue = "0",
396 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
397 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
398 metadataTags = {OptionMetadataTag.HIDDEN},
399 help = "The time in ms a command had to wait on a busy Bazel server process.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100400 public long waitTime;
401
ccalvarin2eaa02e2017-04-17 23:37:46 +0200402 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700403 name = "tool_tag",
404 defaultValue = "",
405 documentationCategory = OptionDocumentationCategory.LOGGING,
406 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
407 help = "A tool name to attribute this Bazel invocation to.")
Googler88e31042015-07-08 19:16:57 +0000408 public String toolTag;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100409
ccalvarin2eaa02e2017-04-17 23:37:46 +0200410 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700411 name = "restart_reason",
412 defaultValue = "no_restart",
413 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
414 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
415 metadataTags = {OptionMetadataTag.HIDDEN},
416 help = "The reason for the server restart.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100417 public String restartReason;
418
ccalvarin2eaa02e2017-04-17 23:37:46 +0200419 @Option(
Dan Fabulich1d35ca02018-07-05 16:08:06 -0700420 name = "binary_path",
421 defaultValue = "",
422 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
423 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
424 metadataTags = {OptionMetadataTag.HIDDEN},
425 help = "The absolute path of the bazel binary.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100426 public String binaryPath;
427
ccalvarin2eaa02e2017-04-17 23:37:46 +0200428 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700429 name = "experimental_allow_project_files",
430 defaultValue = "false",
431 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
432 effectTags = {OptionEffectTag.CHANGES_INPUTS},
433 metadataTags = {OptionMetadataTag.EXPERIMENTAL, OptionMetadataTag.HIDDEN},
434 help = "Enable processing of +<file> parameters.")
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100435 public boolean allowProjectFiles;
Lukacs Berkice1445f2016-04-19 15:52:55 +0000436
ccalvarin2eaa02e2017-04-17 23:37:46 +0200437 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700438 name = "block_for_lock",
439 defaultValue = "true",
440 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
441 effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
442 metadataTags = {OptionMetadataTag.HIDDEN},
443 help =
444 "If set (the default), a command will block if there is another one running. If "
445 + "unset, these commands will immediately return with an error.")
Lukacs Berkice1445f2016-04-19 15:52:55 +0000446 public boolean blockForLock;
ccalvarin93c080a2017-10-16 19:21:08 +0200447
448 // We could accept multiple of these, in the event where there's a chain of tools that led to a
449 // Bazel invocation. We would not want to expect anything from the order of these, and would need
450 // to guarantee that the "label" for each command line is unique. Unless a need is demonstrated,
451 // though, logs are a better place to track this information than flags, so let's try to avoid it.
452 @Option(
Googlerd5a29042020-05-11 03:41:09 -0700453 // In May 2018, this feature will have been out for 6 months. If the format we accept has not
454 // changed in that time, we can remove the "experimental" prefix and tag.
455 name = "experimental_tool_command_line",
456 defaultValue = "",
457 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
458 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
459 // Keep this flag HIDDEN so that it is not listed with our reported command lines, it being
460 // reported separately.
461 metadataTags = {OptionMetadataTag.EXPERIMENTAL, OptionMetadataTag.HIDDEN},
462 converter = ToolCommandLineEvent.Converter.class,
463 help =
464 "An extra command line to report with this invocation's command line. Useful for tools "
465 + "that invoke Bazel and want the original information that the tool received to be "
466 + "logged with the rest of the Bazel invocation.")
ccalvarin93c080a2017-10-16 19:21:08 +0200467 public ToolCommandLineEvent toolCommandLine;
ccalvarin0dd5a682017-11-10 01:40:01 +0100468
469 @Option(
Googlerea0c1102020-03-27 09:30:59 -0700470 name = "unconditional_warning",
471 defaultValue = "null",
472 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
473 effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
474 allowMultiple = true,
475 help =
476 "A warning that will unconditionally get printed with build warnings and errors. This is"
477 + " useful to deprecate bazelrc files or --config definitions. If the intent is to"
478 + " effectively deprecate some flag or combination of flags, this is NOT sufficient."
479 + " The flag or flags should use the deprecationWarning field in the option"
480 + " definition, or the bad combination should be checked for programmatically.")
ccalvarin0dd5a682017-11-10 01:40:01 +0100481 public List<String> deprecationWarnings;
janakrdfa0b122018-02-28 09:46:06 -0800482
fellyac7d5f62018-05-15 10:57:33 -0700483 @Option(
484 name = "track_incremental_state",
485 oldName = "keep_incrementality_data",
486 defaultValue = "true",
487 documentationCategory = OptionDocumentationCategory.BUILD_TIME_OPTIMIZATION,
488 effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE},
489 help =
490 "If false, Blaze will not persist data that allows for invalidation and re-evaluation "
491 + "on incremental builds in order to save memory on this build. Subsequent builds "
492 + "will not have any incrementality with respect to this one. Usually you will want "
Googlerd5a29042020-05-11 03:41:09 -0700493 + "to specify --batch when setting this to false.")
fellyac7d5f62018-05-15 10:57:33 -0700494 public boolean trackIncrementalState;
495
496 @Option(
497 name = "keep_state_after_build",
498 defaultValue = "true",
499 documentationCategory = OptionDocumentationCategory.BUILD_TIME_OPTIMIZATION,
500 effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE},
501 help =
502 "If false, Blaze will discard the inmemory state from this build when the build "
503 + "finishes. Subsequent builds will not have any incrementality with respect to this "
Googlerd5a29042020-05-11 03:41:09 -0700504 + "one.")
fellyac7d5f62018-05-15 10:57:33 -0700505 public boolean keepStateAfterBuild;
Tobias Werth38877f92019-03-15 09:37:01 -0700506
Cristian Hancilac2bdd032021-03-25 07:53:47 -0700507 @Option(
508 name = "repo_env",
509 converter = Converters.OptionalAssignmentConverter.class,
510 allowMultiple = true,
511 defaultValue = "null",
512 documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
513 effectTags = {OptionEffectTag.ACTION_COMMAND_LINES},
514 help =
515 "Specifies additional environment variables to be available only for repository rules."
516 + " Note that repository rules see the full environment anyway, but in this way"
517 + " configuration information can be passed to repositories through options without"
518 + " invalidating the action graph.")
519 public List<Map.Entry<String, String>> repositoryEnvironment;
520
Googler658ba152022-12-16 13:30:29 -0800521 @Option(
Googlere8a69f52023-02-14 13:05:23 -0800522 name = "heuristically_drop_nodes",
523 oldName = "experimental_heuristically_drop_nodes",
524 oldNameWarning = false,
Googler658ba152022-12-16 13:30:29 -0800525 defaultValue = "false",
526 documentationCategory = OptionDocumentationCategory.BUILD_TIME_OPTIMIZATION,
527 effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE},
528 help =
529 "If true, Blaze will remove FileState and DirectoryListingState nodes after related File"
530 + " and DirectoryListing node is done to save memory. We expect that it is less"
531 + " likely that these nodes will be needed again. If so, the program will re-evaluate"
532 + " them.")
Googlere8a69f52023-02-14 13:05:23 -0800533 public boolean heuristicallyDropNodes;
Googler658ba152022-12-16 13:30:29 -0800534
Tobias Werth38877f92019-03-15 09:37:01 -0700535 /** The option converter to check that the user can only specify legal profiler tasks. */
536 public static class ProfilerTaskConverter extends EnumConverter<ProfilerTask> {
537 public ProfilerTaskConverter() {
538 super(ProfilerTask.class, "profiler task");
539 }
540 }
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100541}