aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/option_processor.cc
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/cpp/option_processor.cc
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/cpp/option_processor.cc')
-rw-r--r--src/main/cpp/option_processor.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc
index 6fa48fee2a..7df0af7203 100644
--- a/src/main/cpp/option_processor.cc
+++ b/src/main/cpp/option_processor.cc
@@ -292,15 +292,19 @@ blaze_exit_code::ExitCode OptionProcessor::ParseOptions(
return blaze_exit_code::BAD_ARGV;
}
- // Read the rc files. This depends on the startup options in argv since these
- // may contain rc-modifying options. For all other options, the precedence of
+ // Read the rc files, unless --ignore_all_rc_files was provided on the command
+ // line. This depends on the startup options in argv since these may contain
+ // other rc-modifying options. For all other options, the precedence of
// options will be rc first, then command line options, though, despite this
// exception.
std::vector<std::unique_ptr<RcFile>> rc_files;
- const blaze_exit_code::ExitCode rc_parsing_exit_code = GetRcFiles(
- workspace_layout_, workspace, cwd, cmd_line_.get(), &rc_files, error);
- if (rc_parsing_exit_code != blaze_exit_code::SUCCESS) {
- return rc_parsing_exit_code;
+ if (!SearchNullaryOption(cmd_line_->startup_args, "ignore_all_rc_files",
+ false)) {
+ const blaze_exit_code::ExitCode rc_parsing_exit_code = GetRcFiles(
+ workspace_layout_, workspace, cwd, cmd_line_.get(), &rc_files, error);
+ if (rc_parsing_exit_code != blaze_exit_code::SUCCESS) {
+ return rc_parsing_exit_code;
+ }
}
// Parse the startup options in the correct priority order.