Added /etc/bazel.bazelrc as a global Bazel's master rc.

This will allow system-wide configuration for system-wide
installation of Bazel.

--
Change-Id: I71b7232e648f2690766c3b9184f863dc888524c0
Reviewed-on: https://bazel-review.googlesource.com/#/c/1540/
MOS_MIGRATED_REVID=95994630
diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc
index 18a00e7..c15b57c 100644
--- a/src/main/cpp/option_processor.cc
+++ b/src/main/cpp/option_processor.cc
@@ -183,6 +183,17 @@
 }
 
 
+// Return the path of the bazelrc file that sits in /etc.
+// This allows for installing Bazel on system-wide directory.
+string OptionProcessor::FindSystemWideBlazerc() {
+  string path = BlazeStartupOptions::SystemWideRcPath();
+  if (!path.empty() && !access(path.c_str(), R_OK)) {
+    return path;
+  }
+  return "";
+}
+
+
 // Return the path the the user rc file.  If cmdLineRcFile != NULL,
 // use it, dying if it is not readable.  Otherwise, return the first
 // readable file called rc_basename from [workspace, $HOME]
@@ -279,6 +290,15 @@
         return parse_exit_code;
       }
     }
+    string system_wide_blazerc = FindSystemWideBlazerc();
+    if (!system_wide_blazerc.empty()) {
+      blazercs_.push_back(new RcFile(system_wide_blazerc, blazercs_.size()));
+      blaze_exit_code::ExitCode parse_exit_code =
+          blazercs_.back()->Parse(&blazercs_, &rcoptions_, error);
+      if (parse_exit_code != blaze_exit_code::SUCCESS) {
+        return parse_exit_code;
+      }
+    }
   }
 
   string user_blazerc_path;