diff options
-rwxr-xr-x | compile.sh | 2 | ||||
-rwxr-xr-x | scripts/bootstrap/bootstrap.sh | 12 | ||||
-rw-r--r-- | src/main/cpp/blaze_startup_options.cc | 4 | ||||
-rw-r--r-- | src/main/cpp/blaze_startup_options.h | 3 | ||||
-rw-r--r-- | src/main/cpp/option_processor.cc | 20 | ||||
-rw-r--r-- | src/main/cpp/option_processor.h | 1 |
6 files changed, 37 insertions, 5 deletions
diff --git a/compile.sh b/compile.sh index 163eb5c847..6bffcd231e 100755 --- a/compile.sh +++ b/compile.sh @@ -153,7 +153,7 @@ fi if [ $DO_TESTS ]; then new_step "Running tests" display "." - $BAZEL --blazerc=${BAZELRC} test \ + $BAZEL --blazerc=${BAZELRC} --nomaster_blazerc test \ --javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \ -k --test_output=errors //src/... //third_party/ijar/... //scripts/... \ || fail "Tests failed" diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh index 9d346b77b1..17a577df6b 100755 --- a/scripts/bootstrap/bootstrap.sh +++ b/scripts/bootstrap/bootstrap.sh @@ -39,11 +39,13 @@ function bazel_bootstrap() { if [[ ! ${BAZEL_SKIP_TOOL_COMPILATION-} =~ "$2" ]]; then log "Building $2" if [ -n "${4-}" ]; then - ${BAZEL} --blazerc=${BAZELRC} build ${BAZEL_ARGS} \ + ${BAZEL} --nomaster_blazerc --blazerc=${BAZELRC} \ + build ${BAZEL_ARGS} \ --javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \ "${EMBED_LABEL_ARG[@]}" $1 else - run_silent ${BAZEL} --blazerc=${BAZELRC} build ${BAZEL_ARGS} \ + run_silent ${BAZEL} --nomaster_blazerc --blazerc=${BAZELRC} \ + build ${BAZEL_ARGS} \ --javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \ "${EMBED_LABEL_ARG[@]}" $1 fi @@ -74,8 +76,10 @@ function bootstrap_test() { local BAZEL_BIN=$1 local BAZEL_SUM=$2 [ -x "${BAZEL_BIN}" ] || fail "syntax: bootstrap bazel-binary" - run_silent ${BAZEL_BIN} --blazerc=${BAZELRC} clean || return $? - run_silent ${BAZEL_BIN} --blazerc=${BAZELRC} build --fetch --nostamp \ + run_silent ${BAZEL_BIN} --nomaster_blazerc --blazerc=${BAZELRC} clean \ + || return $? + run_silent ${BAZEL_BIN} --nomaster_blazerc --blazerc=${BAZELRC} build \ + --fetch --nostamp \ --javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \ //src:bazel //src:tools || return $? if [ -n "${BAZEL_SUM}" ]; then diff --git a/src/main/cpp/blaze_startup_options.cc b/src/main/cpp/blaze_startup_options.cc index 1af062d742..6428e220f6 100644 --- a/src/main/cpp/blaze_startup_options.cc +++ b/src/main/cpp/blaze_startup_options.cc @@ -161,4 +161,8 @@ void BlazeStartupOptions::WorkspaceRcFileSearchPath( candidates->push_back("tools/bazel.rc"); } +string BlazeStartupOptions::SystemWideRcPath() { + return "/etc/bazel.bazelrc"; +} + } // namespace blaze diff --git a/src/main/cpp/blaze_startup_options.h b/src/main/cpp/blaze_startup_options.h index b62878eba6..dd1850ffd5 100644 --- a/src/main/cpp/blaze_startup_options.h +++ b/src/main/cpp/blaze_startup_options.h @@ -189,6 +189,9 @@ class BlazeStartupOptions { // Returns the basename for the rc file. static string RcBasename(); + // Returns the path for the system-wide rc file. + static string SystemWideRcPath(); + // Returns the search paths for the RC file in the workspace. static void WorkspaceRcFileSearchPath(std::vector<string>* candidates); diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc index 18a00e74e3..c15b57caac 100644 --- a/src/main/cpp/option_processor.cc +++ b/src/main/cpp/option_processor.cc @@ -183,6 +183,17 @@ string OptionProcessor::FindAlongsideBinaryBlazerc(const string& cwd, } +// 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 @@ blaze_exit_code::ExitCode OptionProcessor::ParseOptions( 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; diff --git a/src/main/cpp/option_processor.h b/src/main/cpp/option_processor.h index f5eb27e5ad..37a946fb83 100644 --- a/src/main/cpp/option_processor.h +++ b/src/main/cpp/option_processor.h @@ -64,6 +64,7 @@ class OptionProcessor { virtual string FindDepotBlazerc(const string& workspace); virtual string FindAlongsideBinaryBlazerc(const string& cwd, const string& arg0); + virtual string FindSystemWideBlazerc(); virtual blaze_exit_code::ExitCode FindUserBlazerc(const char* cmdLineRcFile, const string& rc_basename, const string& workspace, |