aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/option_processor.cc
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2016-03-22 17:04:09 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-03-23 12:19:49 +0000
commit044adedc70de040475443e52eb1a3c692159790e (patch)
treeb2de6881eff90d0b07772ded5db4e7a3f1c9f465 /src/main/cpp/option_processor.cc
parentcd6ca1d7a8bf947eb7c68a82ec2f1c0512d18169 (diff)
Make client-provided options an rc source
The client provides information about whether the terminal is a tty, and which width the output should be formatted for. Passing this information as explicit command-line arguments has the disadvantage that it overrides any setting in configuration files. While usually there is no one-size-fits-all value for terminal width, it doesn't make sense either to have an option where the user cannot set a default. Fix this by providing the client options as least imported rc-source. -- Change-Id: Iad9eddbb3ff1777f4b423053e21aeac9fd7c466f Reviewed-on: https://bazel-review.googlesource.com/#/c/3092 MOS_MIGRATED_REVID=117833645
Diffstat (limited to 'src/main/cpp/option_processor.cc')
-rw-r--r--src/main/cpp/option_processor.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc
index 0696b5a8a5..6237fb43dd 100644
--- a/src/main/cpp/option_processor.cc
+++ b/src/main/cpp/option_processor.cc
@@ -424,6 +424,14 @@ blaze_exit_code::ExitCode OptionProcessor::ParseStartupOptions(string *error) {
// the command and the arguments. NB: Keep the options added here in sync with
// BlazeCommandDispatcher.INTERNAL_COMMAND_OPTIONS!
void OptionProcessor::AddRcfileArgsAndOptions(bool batch, const string& cwd) {
+ // Provide terminal options as coming from the least important rc file.
+ command_arguments_.push_back("--rc_source=client");
+ command_arguments_.push_back("--default_override=0:common=--isatty=" +
+ ToString(IsStandardTerminal()));
+ command_arguments_.push_back(
+ "--default_override=0:common=--terminal_columns=" +
+ ToString(GetTerminalColumns()));
+
// Push the options mapping .blazerc numbers to filenames.
for (int i_blazerc = 0; i_blazerc < blazercs_.size(); i_blazerc++) {
const RcFile* blazerc = blazercs_[i_blazerc];
@@ -441,17 +449,12 @@ void OptionProcessor::AddRcfileArgsAndOptions(bool batch, const string& cwd) {
for (int ii = 0; ii < it->second.size(); ii++) {
const RcOption& rcoption = it->second[ii];
- command_arguments_.push_back(
- "--default_override=" + ToString(rcoption.rcfile_index()) + ":"
- + it->first + "=" + rcoption.option());
+ command_arguments_.push_back("--default_override=" +
+ ToString(rcoption.rcfile_index() + 1) + ":" +
+ it->first + "=" + rcoption.option());
}
}
- // Splice the terminal options.
- command_arguments_.push_back(
- "--isatty=" + ToString(IsStandardTerminal()));
- command_arguments_.push_back(
- "--terminal_columns=" + ToString(GetTerminalColumns()));
// Pass the client environment to the server in server mode.
if (batch) {