blob: c93f667878df758ddd9a5ce3a4244478625559ab [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
ccalvarin93c080a2017-10-16 19:21:08 +020016import com.google.devtools.build.lib.runtime.CommandLineEvent.ToolCommandLineEvent;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010017import com.google.devtools.build.lib.util.OptionsUtils;
18import com.google.devtools.build.lib.vfs.PathFragment;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010019import com.google.devtools.common.options.Converters;
20import com.google.devtools.common.options.Option;
ccalvarine73f8812017-06-26 21:40:04 +020021import com.google.devtools.common.options.OptionDocumentationCategory;
ccalvarinc82a1972017-07-17 21:13:39 +020022import com.google.devtools.common.options.OptionEffectTag;
23import com.google.devtools.common.options.OptionMetadataTag;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010024import com.google.devtools.common.options.OptionsBase;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010025import java.util.List;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010026import java.util.logging.Level;
27
28/**
29 * Options common to all commands.
30 */
31public class CommonCommandOptions extends OptionsBase {
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010032
brandjon94261752017-03-31 20:05:26 +000033 // To create a new incompatible change, see the javadoc for AllIncompatibleChangesExpansion.
34 @Option(
35 name = "all_incompatible_changes",
36 defaultValue = "null",
37 category = "misc",
ccalvarin3bc15472017-06-27 17:58:35 +020038 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
ccalvarine73f8812017-06-26 21:40:04 +020039 effectTags = {OptionEffectTag.UNKNOWN},
40 metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
brandjon94261752017-03-31 20:05:26 +000041 expansionFunction = AllIncompatibleChangesExpansion.class,
42 help =
43 "Enables all options of the form --incompatible_*. Use this option to find places where "
44 + "your build may break in the future due to deprecations or other changes."
45 )
46 public Void allIncompatibleChanges;
47
ccalvarin2eaa02e2017-04-17 23:37:46 +020048 @Option(
49 name = "config",
50 defaultValue = "",
51 category = "misc",
ccalvarin3bc15472017-06-27 17:58:35 +020052 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
ccalvarine73f8812017-06-26 21:40:04 +020053 effectTags = {OptionEffectTag.UNKNOWN},
ccalvarin2eaa02e2017-04-17 23:37:46 +020054 allowMultiple = true,
55 help =
56 "Selects additional config sections from the rc files; for every <command>, it "
57 + "also pulls in the options from <command>:<config> if such a section exists; "
58 + "if the section does not exist, this flag is ignored. "
59 + "Note that it is currently only possible to provide these options on the "
60 + "command line, not in the rc files. The config sections and flag combinations "
61 + "they are equivalent to are located in the tools/*.blazerc config files."
62 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010063 public List<String> configs;
64
ccalvarin2eaa02e2017-04-17 23:37:46 +020065 @Option(
66 name = "logging",
67 defaultValue = "3", // Level.INFO
68 category = "verbosity",
ccalvarine73f8812017-06-26 21:40:04 +020069 documentationCategory = OptionDocumentationCategory.LOGGING,
70 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
ccalvarin2eaa02e2017-04-17 23:37:46 +020071 converter = Converters.LogLevelConverter.class,
72 help = "The logging level."
73 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010074 public Level verbosity;
75
ccalvarin2eaa02e2017-04-17 23:37:46 +020076 @Option(
ccalvarin2eaa02e2017-04-17 23:37:46 +020077 name = "client_cwd",
78 defaultValue = "",
ccalvarin456adb22017-07-11 14:23:46 +020079 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
80 metadataTags = {OptionMetadataTag.HIDDEN},
ccalvarine73f8812017-06-26 21:40:04 +020081 effectTags = {OptionEffectTag.CHANGES_INPUTS},
ccalvarin2eaa02e2017-04-17 23:37:46 +020082 converter = OptionsUtils.PathFragmentConverter.class,
83 help = "A system-generated parameter which specifies the client's working directory"
84 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010085 public PathFragment clientCwd;
86
ccalvarin2eaa02e2017-04-17 23:37:46 +020087 @Option(
88 name = "announce_rc",
89 defaultValue = "false",
90 category = "verbosity",
ccalvarine73f8812017-06-26 21:40:04 +020091 documentationCategory = OptionDocumentationCategory.LOGGING,
92 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
ccalvarin2eaa02e2017-04-17 23:37:46 +020093 help = "Whether to announce rc options."
94 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010095 public boolean announceRcOptions;
96
ccalvarin2eaa02e2017-04-17 23:37:46 +020097 @Option(
98 name = "always_profile_slow_operations",
99 defaultValue = "true",
ccalvarin456adb22017-07-11 14:23:46 +0200100 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200101 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200102 help = "Whether profiling slow operations is always turned on"
103 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100104 public boolean alwaysProfileSlowOperations;
105
ccalvarin2eaa02e2017-04-17 23:37:46 +0200106 @Option(
Googler65ceda92017-05-31 18:09:32 +0200107 name = "allow_undefined_configs",
108 defaultValue = "true",
109 category = "flags",
ccalvarin3bc15472017-06-27 17:58:35 +0200110 documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
ccalvarine73f8812017-06-26 21:40:04 +0200111 effectTags = {OptionEffectTag.EAGERNESS_TO_EXIT},
Googler65ceda92017-05-31 18:09:32 +0200112 help = "Do not throw an error when the config is not defined."
113 )
114 public boolean allowUndefinedConfigs;
115
116 @Option(
ccalvarin2eaa02e2017-04-17 23:37:46 +0200117 name = "profile",
118 defaultValue = "null",
119 category = "misc",
ccalvarine73f8812017-06-26 21:40:04 +0200120 documentationCategory = OptionDocumentationCategory.LOGGING,
121 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200122 converter = OptionsUtils.PathFragmentConverter.class,
123 help =
124 "If set, profile Blaze and write data to the specified "
125 + "file. Use blaze analyze-profile to analyze the profile."
126 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100127 public PathFragment profilePath;
128
ccalvarin2eaa02e2017-04-17 23:37:46 +0200129 @Option(
130 name = "record_full_profiler_data",
131 defaultValue = "false",
ccalvarin456adb22017-07-11 14:23:46 +0200132 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200133 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200134 help =
135 "By default, Blaze profiler will record only aggregated data for fast but numerous "
136 + "events (such as statting the file). If this option is enabled, profiler will record "
137 + "each event - resulting in more precise profiling data but LARGE performance "
138 + "hit. Option only has effect if --profile used as well."
139 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100140 public boolean recordFullProfilerData;
141
ccalvarin2eaa02e2017-04-17 23:37:46 +0200142 @Option(
143 name = "memory_profile",
144 defaultValue = "null",
ccalvarin456adb22017-07-11 14:23:46 +0200145 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200146 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200147 converter = OptionsUtils.PathFragmentConverter.class,
ccalvarine73f8812017-06-26 21:40:04 +0200148 help = "If set, write memory usage data to the specified file at phase ends."
ccalvarin2eaa02e2017-04-17 23:37:46 +0200149 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100150 public PathFragment memoryProfilePath;
151
ccalvarine73f8812017-06-26 21:40:04 +0200152 @Deprecated
ccalvarin2eaa02e2017-04-17 23:37:46 +0200153 @Option(
154 name = "gc_watchdog",
155 defaultValue = "false",
ccalvarin456adb22017-07-11 14:23:46 +0200156 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarin3bc15472017-06-27 17:58:35 +0200157 effectTags = {OptionEffectTag.NO_OP},
ccalvarine73f8812017-06-26 21:40:04 +0200158 metadataTags = {OptionMetadataTag.DEPRECATED},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200159 deprecationWarning = "Ignoring: this option is no longer supported",
160 help = "Deprecated."
161 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100162 public boolean gcWatchdog;
163
ccalvarin2eaa02e2017-04-17 23:37:46 +0200164 @Option(
janakrff746b42017-08-15 21:09:50 +0200165 name = "experimental_oom_more_eagerly_threshold",
166 defaultValue = "100",
167 documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY,
168 effectTags = {OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS},
169 help =
170 "If this flag is set to a value less than 100, Blaze will OOM if, after two full GC's, more"
171 + "than this percentage of the (old gen) heap is still occupied."
172 )
173 public int oomMoreEagerlyThreshold;
174
175 @Option(
ccalvarin2eaa02e2017-04-17 23:37:46 +0200176 name = "startup_time",
177 defaultValue = "0",
ccalvarin456adb22017-07-11 14:23:46 +0200178 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200179 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin456adb22017-07-11 14:23:46 +0200180 metadataTags = {OptionMetadataTag.HIDDEN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200181 help = "The time in ms the launcher spends before sending the request to the blaze server."
182 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100183 public long startupTime;
184
Thiago Farina36c1d152016-05-04 14:24:14 +0000185 @Option(
186 name = "extract_data_time",
187 defaultValue = "0",
ccalvarin456adb22017-07-11 14:23:46 +0200188 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200189 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin456adb22017-07-11 14:23:46 +0200190 metadataTags = {OptionMetadataTag.HIDDEN},
Thiago Farina36c1d152016-05-04 14:24:14 +0000191 help = "The time in ms spent on extracting the new blaze version."
192 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100193 public long extractDataTime;
194
ccalvarin2eaa02e2017-04-17 23:37:46 +0200195 @Option(
196 name = "command_wait_time",
197 defaultValue = "0",
ccalvarin456adb22017-07-11 14:23:46 +0200198 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200199 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin456adb22017-07-11 14:23:46 +0200200 metadataTags = {OptionMetadataTag.HIDDEN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200201 help = "The time in ms a command had to wait on a busy Blaze server process."
202 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100203 public long waitTime;
204
ccalvarin2eaa02e2017-04-17 23:37:46 +0200205 @Option(
206 name = "tool_tag",
207 defaultValue = "",
208 category = "misc",
ccalvarine73f8812017-06-26 21:40:04 +0200209 documentationCategory = OptionDocumentationCategory.LOGGING,
210 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200211 help = "A tool name to attribute this Blaze invocation to."
212 )
Googler88e31042015-07-08 19:16:57 +0000213 public String toolTag;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100214
ccalvarin2eaa02e2017-04-17 23:37:46 +0200215 @Option(
216 name = "restart_reason",
217 defaultValue = "no_restart",
ccalvarin456adb22017-07-11 14:23:46 +0200218 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200219 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin456adb22017-07-11 14:23:46 +0200220 metadataTags = {OptionMetadataTag.HIDDEN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200221 help = "The reason for the server restart."
222 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100223 public String restartReason;
224
ccalvarin2eaa02e2017-04-17 23:37:46 +0200225 @Option(
226 name = "binary_path",
227 defaultValue = "",
ccalvarin456adb22017-07-11 14:23:46 +0200228 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200229 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
ccalvarin456adb22017-07-11 14:23:46 +0200230 metadataTags = {OptionMetadataTag.HIDDEN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200231 help = "The absolute path of the blaze binary."
232 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100233 public String binaryPath;
234
ccalvarin2eaa02e2017-04-17 23:37:46 +0200235 @Option(
236 name = "experimental_allow_project_files",
237 defaultValue = "false",
ccalvarin456adb22017-07-11 14:23:46 +0200238 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200239 effectTags = {OptionEffectTag.CHANGES_INPUTS},
ccalvarin456adb22017-07-11 14:23:46 +0200240 metadataTags = {OptionMetadataTag.EXPERIMENTAL, OptionMetadataTag.HIDDEN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200241 help = "Enable processing of +<file> parameters."
242 )
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100243 public boolean allowProjectFiles;
Lukacs Berkice1445f2016-04-19 15:52:55 +0000244
ccalvarin2eaa02e2017-04-17 23:37:46 +0200245 @Option(
246 name = "block_for_lock",
247 defaultValue = "true",
ccalvarin456adb22017-07-11 14:23:46 +0200248 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
ccalvarine73f8812017-06-26 21:40:04 +0200249 effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
ccalvarin456adb22017-07-11 14:23:46 +0200250 metadataTags = {OptionMetadataTag.HIDDEN},
ccalvarin2eaa02e2017-04-17 23:37:46 +0200251 help =
252 "If set (the default), a command will block if there is another one running. If "
253 + "unset, these commands will immediately return with an error."
254 )
Lukacs Berkice1445f2016-04-19 15:52:55 +0000255 public boolean blockForLock;
ccalvarin93c080a2017-10-16 19:21:08 +0200256
257 // We could accept multiple of these, in the event where there's a chain of tools that led to a
258 // Bazel invocation. We would not want to expect anything from the order of these, and would need
259 // to guarantee that the "label" for each command line is unique. Unless a need is demonstrated,
260 // though, logs are a better place to track this information than flags, so let's try to avoid it.
261 @Option(
262 // In May 2018, this feature will have been out for 6 months. If the format we accept has not
263 // changed in that time, we can remove the "experimental" prefix and tag.
264 name = "experimental_tool_command_line",
265 defaultValue = "",
266 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
267 effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
268 // Keep this flag HIDDEN so that it is not listed with our reported command lines, it being
269 // reported separately.
270 metadataTags = {OptionMetadataTag.EXPERIMENTAL, OptionMetadataTag.HIDDEN},
271 converter = ToolCommandLineEvent.Converter.class,
272 help =
273 "An extra command line to report with this invocation's command line. Useful for tools "
274 + "that invoke Bazel and want the original information that the tool received to be "
275 + "logged with the rest of the Bazel invocation."
276 )
277 public ToolCommandLineEvent toolCommandLine;
ccalvarin0dd5a682017-11-10 01:40:01 +0100278
279 @Option(
280 name = "unconditional_warning",
281 defaultValue = "",
282 documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
283 effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
284 allowMultiple = true,
285 help =
286 "A warning that will unconditionally get printed with build warnings and errors. This is "
287 + "useful to deprecate bazelrc files or --config definitions. If the intent is to "
288 + "effectively deprecate some flag or combination of flags, this is NOT sufficient. "
289 + "The flag or flags should use the deprecationWarning field in the option definition, "
290 + "or the bad combination should be checked for programmatically."
291 )
292 public List<String> deprecationWarnings;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100293}