aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/cpp/option_processor.cc6
-rw-r--r--src/main/cpp/workspace_layout.cc33
-rw-r--r--src/main/cpp/workspace_layout.h18
3 files changed, 17 insertions, 40 deletions
diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc
index 83a184cca5..93f1c4cd67 100644
--- a/src/main/cpp/option_processor.cc
+++ b/src/main/cpp/option_processor.cc
@@ -237,9 +237,9 @@ blaze_exit_code::ExitCode OptionProcessor::ParseOptions(
// paths to the rc files. This list may contain duplicates.
vector<string> candidate_blazerc_paths;
if (use_master_blazerc) {
- workspace_layout_->FindCandidateBlazercPaths(
- workspace, cwd, cmd_line_->path_to_binary, cmd_line_->startup_args,
- &candidate_blazerc_paths);
+ candidate_blazerc_paths =
+ workspace_layout_->FindCandidateBlazercPaths(
+ workspace, cwd, cmd_line_->path_to_binary, cmd_line_->startup_args);
}
string user_blazerc_path;
diff --git a/src/main/cpp/workspace_layout.cc b/src/main/cpp/workspace_layout.cc
index cc02c78113..9748cf4309 100644
--- a/src/main/cpp/workspace_layout.cc
+++ b/src/main/cpp/workspace_layout.cc
@@ -56,21 +56,6 @@ string WorkspaceLayout::GetPrettyWorkspaceName(
return blaze_util::Basename(workspace);
}
-static string FindDepotBlazerc(const blaze::WorkspaceLayout* workspace_layout,
- const string& workspace) {
- // Package semantics are ignored here, but that's acceptable because
- // blaze.blazerc is a configuration file.
- vector<string> candidates;
- workspace_layout->WorkspaceRcFileSearchPath(&candidates);
- for (const auto& candidate : candidates) {
- string blazerc = blaze_util::JoinPath(workspace, candidate);
- if (blaze_util::CanReadFile(blazerc)) {
- return blazerc;
- }
- }
- return "";
-}
-
static string FindAlongsideBinaryBlazerc(const string& cwd,
const string& path_to_binary) {
// TODO(b/32115171): This doesn't work on Windows. Fix this together with the
@@ -86,20 +71,16 @@ static string FindAlongsideBinaryBlazerc(const string& cwd,
return "";
}
-void WorkspaceLayout::FindCandidateBlazercPaths(
+vector<string> WorkspaceLayout::FindCandidateBlazercPaths(
const string& workspace,
const string& cwd,
const string& path_to_binary,
- const vector<string>& startup_args,
- std::vector<string>* result) const {
- result->push_back(FindDepotBlazerc(this, workspace));
- result->push_back(FindAlongsideBinaryBlazerc(cwd, path_to_binary));
- result->push_back(FindSystemWideBlazerc());
-}
-
-void WorkspaceLayout::WorkspaceRcFileSearchPath(
- vector<string>* candidates) const {
- candidates->push_back("tools/bazel.rc");
+ const vector<string>& startup_args) const {
+ return {
+ blaze_util::JoinPath(workspace, "tools/bazel.rc"),
+ FindAlongsideBinaryBlazerc(cwd, path_to_binary),
+ FindSystemWideBlazerc(),
+ };
}
bool WorkspaceLayout::WorkspaceRelativizeRcFilePath(const string &workspace,
diff --git a/src/main/cpp/workspace_layout.h b/src/main/cpp/workspace_layout.h
index a8dd6d1ace..edb2c292e1 100644
--- a/src/main/cpp/workspace_layout.h
+++ b/src/main/cpp/workspace_layout.h
@@ -48,23 +48,19 @@ class WorkspaceLayout {
// Returns if workspace is a valid build workspace.
virtual bool InWorkspace(const std::string& workspace) const;
- // Returns the candidate pathnames for the RC files.
- virtual void FindCandidateBlazercPaths(
+ // Returns the candidate master RC file absolute paths.
+ // All readable files from the result will be used. Empty or nonexistant files
+ // will be ignored. It is ok if no usable candidate exists.
+ virtual std::vector<std::string> FindCandidateBlazercPaths(
const std::string& workspace,
const std::string& cwd,
const std::string& path_to_binary,
- const std::vector<std::string>& startup_args,
- std::vector<std::string>* result) const;
-
- // Returns the candidate pathnames for the RC file in the workspace,
- // the first readable one of which will be chosen.
- // It is ok if no usable candidate exists.
- virtual void WorkspaceRcFileSearchPath(std::vector<std::string>* candidates)
- const;
+ const std::vector<std::string>& startup_args) const;
// Turn a %workspace%-relative import into its true name in the filesystem.
// path_fragment is modified in place.
- // Unlike WorkspaceRcFileSearchPath, it is an error if no import file exists.
+ // Unlike FindCandidateBlazercPaths, it is an error if no import file
+ // exists.
virtual bool WorkspaceRelativizeRcFilePath(const std::string& workspace,
std::string* path_fragment) const;