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.runtime; |
| 15 | |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 16 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 17 | |
janakr | dfa0b12 | 2018-02-28 09:46:06 -0800 | [diff] [blame] | 18 | import com.google.devtools.build.lib.profiler.MemoryProfiler.MemoryProfileStableHeapParameters; |
Tobias Werth | 38877f9 | 2019-03-15 09:37:01 -0700 | [diff] [blame] | 19 | import com.google.devtools.build.lib.profiler.ProfilerTask; |
ccalvarin | 93c080a | 2017-10-16 19:21:08 +0200 | [diff] [blame] | 20 | import com.google.devtools.build.lib.runtime.CommandLineEvent.ToolCommandLineEvent; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 21 | import com.google.devtools.build.lib.util.OptionsUtils; |
| 22 | import com.google.devtools.build.lib.vfs.PathFragment; |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 23 | import com.google.devtools.common.options.Converter; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 24 | import com.google.devtools.common.options.Converters; |
adgar | f3e66ad | 2019-08-15 13:18:51 -0700 | [diff] [blame] | 25 | import com.google.devtools.common.options.Converters.AssignmentConverter; |
Tobias Werth | 38877f9 | 2019-03-15 09:37:01 -0700 | [diff] [blame] | 26 | import com.google.devtools.common.options.EnumConverter; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 27 | import com.google.devtools.common.options.Option; |
ccalvarin | e73f881 | 2017-06-26 21:40:04 +0200 | [diff] [blame] | 28 | import com.google.devtools.common.options.OptionDocumentationCategory; |
ccalvarin | c82a197 | 2017-07-17 21:13:39 +0200 | [diff] [blame] | 29 | import com.google.devtools.common.options.OptionEffectTag; |
| 30 | import com.google.devtools.common.options.OptionMetadataTag; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 31 | import com.google.devtools.common.options.OptionsBase; |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 32 | import com.google.devtools.common.options.OptionsParsingException; |
twerth | 532fc1b | 2019-11-08 03:08:42 -0800 | [diff] [blame] | 33 | import com.google.devtools.common.options.TriState; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 34 | import java.util.List; |
adgar | f3e66ad | 2019-08-15 13:18:51 -0700 | [diff] [blame] | 35 | import java.util.Map; |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 36 | import java.util.UUID; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 37 | import java.util.logging.Level; |
Googler | 9ba7613 | 2022-07-05 11:41:50 -0700 | [diff] [blame] | 38 | import javax.annotation.Nullable; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 39 | |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 40 | /** Options common to all commands. */ |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 41 | public class CommonCommandOptions extends OptionsBase { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 42 | |
lberki | 42c7518 | 2022-03-14 00:41:29 -0700 | [diff] [blame] | 43 | // 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. |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 45 | @Option( |
Yun Peng | 5975545 | 2019-08-27 02:26:35 -0700 | [diff] [blame] | 46 | 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 " |
aldersondrive | c35746d | 2019-12-17 07:08:20 -0800 | [diff] [blame] | 53 | + "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 Peng | 5975545 | 2019-08-27 02:26:35 -0700 | [diff] [blame] | 55 | + "--config=windows on Windows, etc.") |
| 56 | public boolean enablePlatformSpecificConfig; |
| 57 | |
| 58 | @Option( |
Googler | ea0c110 | 2020-03-27 09:30:59 -0700 | [diff] [blame] | 59 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 70 | public List<String> configs; |
| 71 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 72 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 73 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 79 | public Level verbosity; |
| 80 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 81 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 82 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 89 | public PathFragment clientCwd; |
| 90 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 91 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 92 | name = "announce_rc", |
| 93 | defaultValue = "false", |
| 94 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 95 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
| 96 | help = "Whether to announce rc options.") |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 97 | public boolean announceRcOptions; |
| 98 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 99 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 100 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 105 | public boolean alwaysProfileSlowOperations; |
| 106 | |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 107 | /** Converter for UUID. Accepts values as specified by {@link UUID#fromString(String)}. */ |
Googler | 883ce21 | 2022-07-06 10:01:59 -0700 | [diff] [blame] | 108 | public static class UUIDConverter extends Converter.Contextless<UUID> { |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 109 | |
| 110 | @Override |
Googler | 9ba7613 | 2022-07-05 11:41:50 -0700 | [diff] [blame] | 111 | @Nullable |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 112 | 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 | */ |
Googler | 883ce21 | 2022-07-06 10:01:59 -0700 | [diff] [blame] | 134 | public static class PrefixedUUIDConverter extends Converter.Contextless<String> { |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 135 | |
| 136 | @Override |
Googler | 9ba7613 | 2022-07-05 11:41:50 -0700 | [diff] [blame] | 137 | @Nullable |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 138 | 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 Gensure | b5a2f81 | 2018-09-19 12:32:51 -0700 | [diff] [blame] | 150 | String.format("Value '%s' does not end in a valid UUID.", input), e); |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 151 | } |
| 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( |
Googler | f2632d8 | 2019-07-30 11:28:50 -0700 | [diff] [blame] | 167 | 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.") |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 176 | public UUID invocationId; |
| 177 | |
| 178 | @Option( |
Googler | f2632d8 | 2019-07-30 11:28:50 -0700 | [diff] [blame] | 179 | 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.") |
ccalvarin | 2192b56 | 2017-12-14 10:37:41 -0800 | [diff] [blame] | 186 | public String buildRequestId; |
| 187 | |
Googler | 65ceda9 | 2017-05-31 18:09:32 +0200 | [diff] [blame] | 188 | @Option( |
adgar | f3e66ad | 2019-08-15 13:18:51 -0700 | [diff] [blame] | 189 | name = "build_metadata", |
| 190 | converter = AssignmentConverter.class, |
Googler | ea0c110 | 2020-03-27 09:30:59 -0700 | [diff] [blame] | 191 | defaultValue = "null", |
adgar | f3e66ad | 2019-08-15 13:18:51 -0700 | [diff] [blame] | 192 | 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( |
Googler | 372f412 | 2019-06-12 08:37:42 -0700 | [diff] [blame] | 199 | 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( |
twerth | 35c27f3e | 2020-12-03 06:23:41 -0800 | [diff] [blame] | 208 | name = "generate_json_trace_profile", |
| 209 | oldName = "experimental_generate_json_trace_profile", |
| 210 | defaultValue = "auto", |
twerth | 7bb536d | 2019-06-19 05:57:51 -0700 | [diff] [blame] | 211 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 212 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
twerth | 7bb536d | 2019-06-19 05:57:51 -0700 | [diff] [blame] | 213 | help = |
| 214 | "If enabled, Bazel profiles the build and writes a JSON-format profile into a file in" |
twerth | 35c27f3e | 2020-12-03 06:23:41 -0800 | [diff] [blame] | 215 | + " 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; |
ulfjack | 400fffe | 2018-06-12 12:21:25 -0700 | [diff] [blame] | 218 | |
| 219 | @Option( |
Tobias Werth | 38877f9 | 2019-03-15 09:37:01 -0700 | [diff] [blame] | 220 | name = "experimental_profile_additional_tasks", |
| 221 | converter = ProfilerTaskConverter.class, |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 222 | defaultValue = "null", |
Tobias Werth | 38877f9 | 2019-03-15 09:37:01 -0700 | [diff] [blame] | 223 | allowMultiple = true, |
| 224 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 225 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Tobias Werth | 38877f9 | 2019-03-15 09:37:01 -0700 | [diff] [blame] | 226 | help = "Specifies additional profile tasks to be included in the profile.") |
| 227 | public List<ProfilerTask> additionalProfileTasks; |
| 228 | |
| 229 | @Option( |
twerth | b5b8911 | 2020-04-07 09:00:09 -0700 | [diff] [blame] | 230 | name = "slim_profile", |
| 231 | oldName = "experimental_slim_json_profile", |
| 232 | defaultValue = "true", |
twerth | adea1a7 | 2019-03-21 09:28:24 -0700 | [diff] [blame] | 233 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 234 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
twerth | adea1a7 | 2019-03-21 09:28:24 -0700 | [diff] [blame] | 235 | help = |
| 236 | "Slims down the size of the JSON profile by merging events if the profile gets " |
| 237 | + " too large.") |
twerth | b5b8911 | 2020-04-07 09:00:09 -0700 | [diff] [blame] | 238 | public boolean slimProfile; |
twerth | adea1a7 | 2019-03-21 09:28:24 -0700 | [diff] [blame] | 239 | |
twerth | 2bc07c4 | 2019-04-11 08:14:00 -0700 | [diff] [blame] | 240 | @Option( |
twerth | d22bb66 | 2020-06-04 05:20:25 -0700 | [diff] [blame] | 241 | name = "experimental_profile_include_primary_output", |
| 242 | oldName = "experimental_include_primary_output", |
leba | f555419 | 2020-02-19 04:30:19 -0800 | [diff] [blame] | 243 | defaultValue = "false", |
| 244 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 245 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
leba | f555419 | 2020-02-19 04:30:19 -0800 | [diff] [blame] | 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 Balabanov | eb048fd | 2020-06-04 01:35:28 -0700 | [diff] [blame] | 252 | name = "experimental_profile_include_target_label", |
| 253 | defaultValue = "false", |
| 254 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 255 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Sergey Balabanov | eb048fd | 2020-06-04 01:35:28 -0700 | [diff] [blame] | 256 | help = "Includes target label in action events' JSON profile data.") |
| 257 | public boolean profileIncludeTargetLabel; |
| 258 | |
| 259 | @Option( |
twerth | f62586a | 2019-10-21 01:21:12 -0700 | [diff] [blame] | 260 | name = "experimental_announce_profile_path", |
twerth | ec3a562 | 2019-11-05 01:21:26 -0800 | [diff] [blame] | 261 | defaultValue = "false", |
twerth | f62586a | 2019-10-21 01:21:12 -0700 | [diff] [blame] | 262 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 263 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
twerth | f62586a | 2019-10-21 01:21:12 -0700 | [diff] [blame] | 264 | help = "If enabled, adds the JSON profile path to the log.") |
| 265 | public boolean announceProfilePath; |
| 266 | |
| 267 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 268 | name = "profile", |
| 269 | defaultValue = "null", |
| 270 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 271 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Keith Smiley | e521aad | 2021-07-28 06:12:59 -0700 | [diff] [blame] | 272 | converter = OptionsUtils.PathFragmentConverter.class, |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 273 | help = |
| 274 | "If set, profile Bazel and write data to the specified " |
| 275 | + "file. Use bazel analyze-profile to analyze the profile.") |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 276 | public PathFragment profilePath; |
| 277 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 278 | @Option( |
adonovan | 329ec6d | 2020-02-06 15:34:49 -0800 | [diff] [blame] | 279 | 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 Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 287 | name = "record_full_profiler_data", |
| 288 | defaultValue = "false", |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 289 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 290 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 296 | public boolean recordFullProfilerData; |
| 297 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 298 | @Option( |
Googler | be5354b | 2022-07-12 07:32:22 -0700 | [diff] [blame] | 299 | name = "experimental_collect_worker_data_in_profiler", |
| 300 | defaultValue = "false", |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 301 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 302 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Googler | b4dbed0 | 2022-08-18 08:47:46 -0700 | [diff] [blame] | 303 | help = "If enabled, the profiler collects worker's aggregated resource data.") |
Googler | be5354b | 2022-07-12 07:32:22 -0700 | [diff] [blame] | 304 | public boolean collectWorkerDataInProfiler; |
| 305 | |
| 306 | @Option( |
Googler | b4dbed0 | 2022-08-18 08:47:46 -0700 | [diff] [blame] | 307 | name = "experimental_collect_load_average_in_profiler", |
Googler | 390d212 | 2022-09-14 07:12:40 -0700 | [diff] [blame] | 308 | defaultValue = "true", |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 309 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 310 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Googler | b4dbed0 | 2022-08-18 08:47:46 -0700 | [diff] [blame] | 311 | help = "If enabled, the profiler collects the system's overall load average.") |
| 312 | public boolean collectLoadAverageInProfiler; |
| 313 | |
| 314 | @Option( |
Googler | e382cb2 | 2022-09-12 07:34:24 -0700 | [diff] [blame] | 315 | name = "experimental_collect_system_network_usage", |
| 316 | defaultValue = "false", |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 317 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 318 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Googler | e382cb2 | 2022-09-12 07:34:24 -0700 | [diff] [blame] | 319 | help = "If enabled, the profiler collects the system's network usage.") |
| 320 | public boolean collectSystemNetworkUsage; |
| 321 | |
| 322 | @Option( |
Googler | 2e2f5d9 | 2022-12-06 03:11:45 -0800 | [diff] [blame] | 323 | name = "experimental_collect_resource_estimation", |
| 324 | defaultValue = "false", |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 325 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 326 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Googler | 2e2f5d9 | 2022-12-06 03:11:45 -0800 | [diff] [blame] | 327 | help = "If enabled, the profiler collects CPU and memory usage estimation for local actions.") |
| 328 | public boolean collectResourceEstimation; |
| 329 | |
| 330 | @Option( |
Googler | 50446bc | 2023-02-15 00:48:17 -0800 | [diff] [blame] | 331 | 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( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 339 | name = "memory_profile", |
| 340 | defaultValue = "null", |
Googler | 54575fb | 2022-06-13 05:55:16 -0700 | [diff] [blame] | 341 | documentationCategory = OptionDocumentationCategory.LOGGING, |
Googler | 01ca1f7 | 2023-01-17 15:30:15 -0800 | [diff] [blame] | 342 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
Keith Smiley | e521aad | 2021-07-28 06:12:59 -0700 | [diff] [blame] | 343 | converter = OptionsUtils.PathFragmentConverter.class, |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 344 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 347 | public PathFragment memoryProfilePath; |
| 348 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 349 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 350 | 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 = |
Googler | 3dc6951 | 2022-11-02 11:20:38 -0700 | [diff] [blame] | 356 | "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") |
janakr | dfa0b12 | 2018-02-28 09:46:06 -0800 | [diff] [blame] | 361 | public MemoryProfileStableHeapParameters memoryProfileStableHeapParameters; |
| 362 | |
nharmata | 343ba43 | 2021-12-27 16:10:47 -0800 | [diff] [blame] | 363 | @Option( |
jhorvitz | bf6987d | 2021-06-04 18:12:13 -0700 | [diff] [blame] | 364 | name = "heap_dump_on_oom", |
jhorvitz | 10fe917 | 2021-05-03 11:53:56 -0700 | [diff] [blame] | 365 | defaultValue = "false", |
| 366 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 367 | effectTags = {OptionEffectTag.BAZEL_MONITORING}, |
| 368 | help = |
Googler | a3ba48e | 2023-08-01 08:27:08 -0700 | [diff] [blame] | 369 | "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" |
jhorvitz | bf6987d | 2021-06-04 18:12:13 -0700 | [diff] [blame] | 371 | + " <output_base>/<invocation_id>.heapdump.hprof. This option effectively replaces" |
Googler | a3ba48e | 2023-08-01 08:27:08 -0700 | [diff] [blame] | 372 | + " -XX:+HeapDumpOnOutOfMemoryError, which has no effect for manual OOMs.") |
jhorvitz | bf6987d | 2021-06-04 18:12:13 -0700 | [diff] [blame] | 373 | public boolean heapDumpOnOom; |
jhorvitz | 10fe917 | 2021-05-03 11:53:56 -0700 | [diff] [blame] | 374 | |
| 375 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 376 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 382 | public long startupTime; |
| 383 | |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 384 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 385 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 391 | public long extractDataTime; |
| 392 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 393 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 394 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 400 | public long waitTime; |
| 401 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 402 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 403 | 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.") |
Googler | 88e3104 | 2015-07-08 19:16:57 +0000 | [diff] [blame] | 408 | public String toolTag; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 409 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 410 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 411 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 417 | public String restartReason; |
| 418 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 419 | @Option( |
Dan Fabulich | 1d35ca0 | 2018-07-05 16:08:06 -0700 | [diff] [blame] | 420 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 426 | public String binaryPath; |
| 427 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 428 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 429 | 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 435 | public boolean allowProjectFiles; |
Lukacs Berki | ce1445f | 2016-04-19 15:52:55 +0000 | [diff] [blame] | 436 | |
ccalvarin | 2eaa02e | 2017-04-17 23:37:46 +0200 | [diff] [blame] | 437 | @Option( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 438 | 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 Berki | ce1445f | 2016-04-19 15:52:55 +0000 | [diff] [blame] | 446 | public boolean blockForLock; |
ccalvarin | 93c080a | 2017-10-16 19:21:08 +0200 | [diff] [blame] | 447 | |
| 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( |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 453 | // 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.") |
ccalvarin | 93c080a | 2017-10-16 19:21:08 +0200 | [diff] [blame] | 467 | public ToolCommandLineEvent toolCommandLine; |
ccalvarin | 0dd5a68 | 2017-11-10 01:40:01 +0100 | [diff] [blame] | 468 | |
| 469 | @Option( |
Googler | ea0c110 | 2020-03-27 09:30:59 -0700 | [diff] [blame] | 470 | 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.") |
ccalvarin | 0dd5a68 | 2017-11-10 01:40:01 +0100 | [diff] [blame] | 481 | public List<String> deprecationWarnings; |
janakr | dfa0b12 | 2018-02-28 09:46:06 -0800 | [diff] [blame] | 482 | |
felly | ac7d5f6 | 2018-05-15 10:57:33 -0700 | [diff] [blame] | 483 | @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 " |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 493 | + "to specify --batch when setting this to false.") |
felly | ac7d5f6 | 2018-05-15 10:57:33 -0700 | [diff] [blame] | 494 | 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 " |
Googler | d5a2904 | 2020-05-11 03:41:09 -0700 | [diff] [blame] | 504 | + "one.") |
felly | ac7d5f6 | 2018-05-15 10:57:33 -0700 | [diff] [blame] | 505 | public boolean keepStateAfterBuild; |
Tobias Werth | 38877f9 | 2019-03-15 09:37:01 -0700 | [diff] [blame] | 506 | |
Cristian Hancila | c2bdd03 | 2021-03-25 07:53:47 -0700 | [diff] [blame] | 507 | @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 | |
Googler | 658ba15 | 2022-12-16 13:30:29 -0800 | [diff] [blame] | 521 | @Option( |
Googler | e8a69f5 | 2023-02-14 13:05:23 -0800 | [diff] [blame] | 522 | name = "heuristically_drop_nodes", |
| 523 | oldName = "experimental_heuristically_drop_nodes", |
| 524 | oldNameWarning = false, |
Googler | 658ba15 | 2022-12-16 13:30:29 -0800 | [diff] [blame] | 525 | 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.") |
Googler | e8a69f5 | 2023-02-14 13:05:23 -0800 | [diff] [blame] | 533 | public boolean heuristicallyDropNodes; |
Googler | 658ba15 | 2022-12-16 13:30:29 -0800 | [diff] [blame] | 534 | |
Tobias Werth | 38877f9 | 2019-03-15 09:37:01 -0700 | [diff] [blame] | 535 | /** 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 Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 541 | } |