aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2018-05-15 16:41:19 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-15 16:43:02 -0700
commit90e116c2358e2d1e71818f7d39ddb609581ee211 (patch)
tree998a51348dfe39c513d44a05bdc0935589fd9102 /src/main/java/com/google/devtools/build/lib
parent0015d18f57e3f94905b58967b9dd6a1e8b364596 (diff)
Add --ignore_all_rc_files startup options.
This overrides --bazelrc and --[no]master_bazelrc regardless of order. Like --bazelrc and --[no]master_bazelrc, it cannot be mentioned in an rc file, this would be a contradiction. This flag is useful for testing, and for having a version-agnostic way to turn off all rc files, such as in the canonical command line reporting. Now that blazerc and bazelrc are separate, this is necessary. If explicit values for --bazelrc or --master_bazelrc are provided which are now ignored, Bazel will warn the user. #4502 Alternatives considered - We could avoid this flag but would need to have some well-documented, reusable list of the startup flags that effectively come to the same effect. This would be necessary in our integration tests and in the CommandLineEvent and other places where rc files need to be completely disabled for correctness. We decided that this startup option was more straightforward and usable for both users and Bazel devs: it shouldn't be used when more fine-grained control is needed, but provides warnings if users are likely to be confused by the outcome. RELNOTES: None. PiperOrigin-RevId: 196750704
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java7
2 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
index a5b81be80b..90684c5946 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
@@ -290,6 +290,16 @@ public class BlazeServerStartupOptions extends OptionsBase {
public boolean batchCpuScheduling;
@Option(
+ name = "ignore_all_rc_files",
+ defaultValue = "false", // NOTE: purely decorative, rc files are read by the client.
+ documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
+ effectTags = {OptionEffectTag.CHANGES_INPUTS},
+ help =
+ "Disables all rc files, regardless of the values of other rc-modifying flags, even if "
+ + "these flags come later in the list of startup options.")
+ public boolean ignoreAllRcFiles;
+
+ @Option(
name = "blazerc",
defaultValue = "null", // NOTE: purely decorative, rc files are read by the client.
documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java
index afa68079ed..1bf99be2c4 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java
@@ -319,7 +319,7 @@ public abstract class CommandLineEvent implements BuildEventWithOrderConstraint
// Create the fake ones to prevent reapplication of the original rc file contents.
OptionsParser fakeOptions = OptionsParser.newOptionsParser(BlazeServerStartupOptions.class);
try {
- fakeOptions.parse("--nomaster_blazerc", "--blazerc=/dev/null");
+ fakeOptions.parse("--ignore_all_rc_files");
} catch (OptionsParsingException e) {
// Unless someone changes the definition of these flags, this is impossible.
throw new IllegalStateException(e);
@@ -336,8 +336,11 @@ public abstract class CommandLineEvent implements BuildEventWithOrderConstraint
.filter(
option -> {
String optionName = option.getOptionName();
- return !optionName.equals("blazerc")
+ return !optionName.equals("ignore_all_rc_files")
+ && !optionName.equals("blazerc")
&& !optionName.equals("master_blazerc")
+ && !optionName.equals("bazelrc")
+ && !optionName.equals("master_bazelrc")
&& !optionName.equals("invocation_policy");
})
.collect(Collectors.toList()))