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
diff --git a/src/main/cpp/option_processor.h b/src/main/cpp/option_processor.h
index 7054ac1..0fe45ba 100644
--- a/src/main/cpp/option_processor.h
+++ b/src/main/cpp/option_processor.h
@@ -28,6 +28,10 @@
 
 class WorkspaceLayout;
 
+// Broken down structure of the command line into logical components. The raw
+// arguments should not be referenced after this structure exists. This
+// breakdown should suffice to access the parts of the command line that the
+// client cares about, notably the binary and startup startup options.
 struct CommandLine {
   const std::string path_to_binary;
   const std::vector<std::string> startup_args;
@@ -63,7 +67,7 @@
   // result.path_to_binary = "output/bazel"
   // result.startup_args = {"--foo", "--bar=42", "--bar=blah"}
   // result.command = "build"
-  // result.command_args = {"--some_flag", "value", ":mytarget"}
+  // result.command_args = {"--myflag", "value", ":mytarget"}
   //
   // Note that result.startup_args is guaranteed to contain only valid
   // startup options (w.r.t. StartupOptions::IsUnary and
@@ -104,6 +108,11 @@
       const std::string& workspace, std::string* user_blazerc_file,
       std::string* error);
 
+  // Prints a message about the origin of startup options. This should be called
+  // if the server is not started or called, in case the options are related
+  // to the failure. Otherwise, the server will handle any required logging.
+  void PrintStartupOptionsProvenanceMessage() const;
+
  private:
   class RcOption {
    public:
@@ -123,7 +132,7 @@
     blaze_exit_code::ExitCode Parse(
         const std::string& workspace, const WorkspaceLayout* workspace_layout,
         std::vector<RcFile*>* rcfiles,
-        std::map<std::string, std::vector<RcOption> >* rcoptions,
+        std::map<std::string, std::vector<RcOption>>* rcoptions,
         std::string* error);
     const std::string& Filename() const { return filename_; }
     const int Index() const { return index_; }
@@ -133,7 +142,7 @@
         const std::string& workspace, const std::string& filename,
         const int index, const WorkspaceLayout* workspace_layout,
         std::vector<RcFile*>* rcfiles,
-        std::map<std::string, std::vector<RcOption> >* rcoptions,
+        std::map<std::string, std::vector<RcOption>>* rcoptions,
         std::list<std::string>* import_stack, std::string* error);
 
     std::string filename_;