aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-10-16 19:21:08 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-10-18 10:27:48 +0200
commit93c080ad752d029f9f9f9466414430d609105257 (patch)
treeeec7484a61c401779372276a243dde765719a27e /src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
parent044bc6df1ab73206a955229bdd420795fb7fc2da (diff)
Accept command lines from tools invoking Bazel.
For tools that wrap Bazel in some way, the original way that the tool was invoked can be a useful piece of information to track when logging what Bazel did and why. In order to output this information in the same way that Bazel outputs its command lines, we accept --tool_command_line in the structure command line format that Bazel uses in the BEP. These structured command lines are protos that we expect as a base64 encoded byte array. For simple scripts that wish to use this feature without compiling the proto, we will also accept any old string (that cannot be interpreted as a base64 encoding) as a single "chunk" in a structured command line. This is experimental for now and users should not get attached to the format. We will remove the experimental_ prefix when it is stable. RELNOTES: None. PiperOrigin-RevId: 172341216
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
index 492cef9a1d..440271ef86 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.runtime;
+import com.google.devtools.build.lib.runtime.CommandLineEvent.ToolCommandLineEvent;
import com.google.devtools.build.lib.util.OptionsUtils;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.common.options.Converter;
@@ -53,10 +54,7 @@ public class CommonCommandOptions extends OptionsBase {
}
}
- /**
- * Converter for --default_override. The format is:
- * --default_override=blazerc:command=option.
- */
+ /** Converter for --default_override. The format is: --default_override=blazerc:command=option. */
public static class OptionOverrideConverter implements Converter<OptionOverride> {
static final String ERROR_MESSAGE = "option overrides must be in form "
+ " rcfile:command=option, where rcfile is a nonzero integer";
@@ -364,4 +362,26 @@ public class CommonCommandOptions extends OptionsBase {
+ "unset, these commands will immediately return with an error."
)
public boolean blockForLock;
+
+ // We could accept multiple of these, in the event where there's a chain of tools that led to a
+ // Bazel invocation. We would not want to expect anything from the order of these, and would need
+ // to guarantee that the "label" for each command line is unique. Unless a need is demonstrated,
+ // though, logs are a better place to track this information than flags, so let's try to avoid it.
+ @Option(
+ // In May 2018, this feature will have been out for 6 months. If the format we accept has not
+ // changed in that time, we can remove the "experimental" prefix and tag.
+ name = "experimental_tool_command_line",
+ defaultValue = "",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
+ // Keep this flag HIDDEN so that it is not listed with our reported command lines, it being
+ // reported separately.
+ metadataTags = {OptionMetadataTag.EXPERIMENTAL, OptionMetadataTag.HIDDEN},
+ converter = ToolCommandLineEvent.Converter.class,
+ help =
+ "An extra command line to report with this invocation's command line. Useful for tools "
+ + "that invoke Bazel and want the original information that the tool received to be "
+ + "logged with the rest of the Bazel invocation."
+ )
+ public ToolCommandLineEvent toolCommandLine;
}