aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/startup_options.cc
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-08-14 21:09:07 +0200
committerGravatar Irina Iancu <elenairina@google.com>2017-08-16 11:04:41 +0200
commit1cbe62a09b37f2db76e11ebb18fb46616076ef87 (patch)
treef02a66fc345507f3eb3ab3bbe404fdcb161cbabc /src/main/cpp/startup_options.cc
parentfc6412ca67a9d98c1b6b0c8b237c119e543bc266 (diff)
Send Bazel startup options to server.
Send the startup options tagged with their origin so that the server has correct information about the command line as the client received it. Removes the unconditional stderr printing of all bazelrc startup options in the bazel client. Instead, the startup options are sent to the server and the same informational printing is gated on the --announce_rc option. This avoids unconditional log spam to stderr early in startup. If the server is unreachable or there are errors parsing startup options, the message is still printed to stderr. Fixes https://github.com/bazelbuild/bazel/issues/2530. RELNOTES: --announce_rc now controls whether bazelrc startup options are printed to stderr. PiperOrigin-RevId: 165211007
Diffstat (limited to 'src/main/cpp/startup_options.cc')
-rw-r--r--src/main/cpp/startup_options.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc
index d54dbb2969..27c3d71848 100644
--- a/src/main/cpp/startup_options.cc
+++ b/src/main/cpp/startup_options.cc
@@ -90,7 +90,8 @@ StartupOptions::StartupOptions(const string &product_name,
invocation_policy(NULL),
client_debug(false),
java_logging_formatter(
- "com.google.devtools.build.lib.util.SingleLineFormatter") {
+ "com.google.devtools.build.lib.util.SingleLineFormatter"),
+ original_startup_options_(std::vector<RcStartupFlag>()) {
bool testing = !blaze::GetEnv("TEST_TMPDIR").empty();
if (testing) {
output_root = MakeAbsolute(blaze::GetEnv("TEST_TMPDIR"));
@@ -381,21 +382,31 @@ blaze_exit_code::ExitCode StartupOptions::ProcessArgs(
std::string *error) {
std::vector<RcStartupFlag>::size_type i = 0;
while (i < rcstartup_flags.size()) {
- bool is_space_separated;
- const bool is_last_elem = i == rcstartup_flags.size() - 1;
+ bool is_space_separated = false;
+ const std::string next_value =
+ (i == rcstartup_flags.size() - 1) ? "" : rcstartup_flags[i + 1].value;
const blaze_exit_code::ExitCode process_arg_exit_code =
- ProcessArg(rcstartup_flags[i].value,
- is_last_elem ? "" : rcstartup_flags[i + 1].value,
- rcstartup_flags[i].source,
- &is_space_separated,
- error);
- if (process_arg_exit_code != blaze_exit_code::SUCCESS) {
- return process_arg_exit_code;
- }
+ ProcessArg(rcstartup_flags[i].value, next_value,
+ rcstartup_flags[i].source, &is_space_separated, error);
+ // Store the provided option in --flag(=value)? form. Store these before
+ // propagating any error code, since we want to have the correct
+ // information for the output. The fact that the options aren't parseable
+ // doesn't matter for this step.
if (is_space_separated) {
+ const std::string combined_value =
+ rcstartup_flags[i].value + "=" + next_value;
+ original_startup_options_.push_back(
+ RcStartupFlag(rcstartup_flags[i].source, combined_value));
+ i += 2;
+ } else {
+ original_startup_options_.push_back(
+ RcStartupFlag(rcstartup_flags[i].source, rcstartup_flags[i].value));
i++;
}
- i++;
+
+ if (process_arg_exit_code != blaze_exit_code::SUCCESS) {
+ return process_arg_exit_code;
+ }
}
return blaze_exit_code::SUCCESS;
}