Bazel client: fix reporting of ignored RC files
(This commit is a roll-forward of commit e9a908560133770614eca89ef64681bdf3f04b3e
that was rolled back by commit 37335187bf31dac48155e77f404bd11008d68ea7. The culprit
of the breakage is fixed in the Google-internal
depot.)
Compute the difference between the read RC files
and the ignored ones based on their canonical
paths, not on the textual value of the path.
This aids for proper reporting of ignored RC
files, while reporting them with a path familiar
to the user (e.g. paths the user passed with flags
rather than the potentially different canonical
version of the same path).
Also: respect $HOME on Windows when Bazel is
running inside of a test, to avoid picking up the
real RC file from the user's home directory. This
fixes //src/test/cpp:rc_file_test on Windows.
Fixes https://github.com/bazelbuild/bazel/issues/6138
Fixes https://github.com/bazelbuild/bazel/issues/6469
Closes #6910.
PiperOrigin-RevId: 225832065
diff --git a/src/main/cpp/rc_file.h b/src/main/cpp/rc_file.h
index 0d462dc..5f1eee7 100644
--- a/src/main/cpp/rc_file.h
+++ b/src/main/cpp/rc_file.h
@@ -42,7 +42,9 @@
std::string workspace, ParseError* error, std::string* error_text);
// Returns all relevant rc sources for this file (including itself).
- const std::deque<std::string>& sources() const { return rcfile_paths_; }
+ const std::deque<std::string>& canonical_source_paths() const {
+ return canonical_rcfile_paths_;
+ }
// Command -> all options for that command (in order of appearance).
using OptionMap = std::unordered_map<std::string, std::vector<RcOption>>;
@@ -68,9 +70,12 @@
const std::string workspace_;
// Full closure of rcfile paths imported from this file (including itself).
+ // These are all canonical paths, created with blaze_util::MakeCanonical.
+ // This also means all of these paths should exist.
+ //
// The RcOption structs point to the strings in here so they need to be stored
// in a container that offers stable pointers, like a deque (and not vector).
- std::deque<std::string> rcfile_paths_;
+ std::deque<std::string> canonical_rcfile_paths_;
// All options parsed from the file.
OptionMap options_;
};