diff options
Diffstat (limited to 'src/main/cpp')
-rw-r--r-- | src/main/cpp/blaze_startup_options.cc | 2 | ||||
-rw-r--r-- | src/main/cpp/blaze_startup_options_common.cc | 1 | ||||
-rw-r--r-- | src/main/cpp/blaze_util_darwin.cc | 9 | ||||
-rw-r--r-- | src/main/cpp/blaze_util_linux.cc | 4 | ||||
-rw-r--r-- | src/main/cpp/blaze_util_mingw.cc | 4 | ||||
-rw-r--r-- | src/main/cpp/blaze_util_platform.h | 3 |
6 files changed, 22 insertions, 1 deletions
diff --git a/src/main/cpp/blaze_startup_options.cc b/src/main/cpp/blaze_startup_options.cc index c58a42ccdd..57e89a84ec 100644 --- a/src/main/cpp/blaze_startup_options.cc +++ b/src/main/cpp/blaze_startup_options.cc @@ -70,7 +70,7 @@ string BlazeStartupOptions::GetProductName() { } string BlazeStartupOptions::GetOutputRoot() { - return "/var/tmp"; + return blaze::GetOutputRoot(); } void BlazeStartupOptions::AddExtraOptions(vector<string> *result) const {} diff --git a/src/main/cpp/blaze_startup_options_common.cc b/src/main/cpp/blaze_startup_options_common.cc index 1620ace32e..8561af1d9c 100644 --- a/src/main/cpp/blaze_startup_options_common.cc +++ b/src/main/cpp/blaze_startup_options_common.cc @@ -19,6 +19,7 @@ #include "blaze_exit_code.h" #include "blaze_util_platform.h" #include "blaze_util.h" +#include "util/file.h" #include "util/numbers.h" #include "util/strings.h" diff --git a/src/main/cpp/blaze_util_darwin.cc b/src/main/cpp/blaze_util_darwin.cc index f6eb39c8c2..566b8a8884 100644 --- a/src/main/cpp/blaze_util_darwin.cc +++ b/src/main/cpp/blaze_util_darwin.cc @@ -22,12 +22,21 @@ #include "blaze_exit_code.h" #include "blaze_util.h" #include "blaze_util_platform.h" +#include "util/file.h" #include "util/strings.h" namespace blaze { using std::string; +string GetOutputRoot() { + const char *home = getenv("HOME"); + if (home == NULL) { + return "/var/tmp"; + } + return blaze_util::JoinPath(home, "Library/Caches/Bazel"); +} + void WarnFilesystemType(const string& output_base) { // TODO(bazel-team): Should check for NFS. // TODO(bazel-team): Should check for case insensitive file systems? diff --git a/src/main/cpp/blaze_util_linux.cc b/src/main/cpp/blaze_util_linux.cc index 3c1bcebaa5..c5c32daafc 100644 --- a/src/main/cpp/blaze_util_linux.cc +++ b/src/main/cpp/blaze_util_linux.cc @@ -27,6 +27,10 @@ namespace blaze { using std::string; +string GetOutputRoot() { + return blaze_util::JoinPath(getenv("HOME"), ".cache/bazel"); +} + void WarnFilesystemType(const string& output_base) { struct statfs buf = {}; if (statfs(output_base.c_str(), &buf) < 0) { diff --git a/src/main/cpp/blaze_util_mingw.cc b/src/main/cpp/blaze_util_mingw.cc index 07fabe64e4..cb9031533c 100644 --- a/src/main/cpp/blaze_util_mingw.cc +++ b/src/main/cpp/blaze_util_mingw.cc @@ -49,6 +49,10 @@ string GetSelfPath() { return string(buffer); } +string GetOutputRoot() { + return "/var/tmp"; +} + pid_t GetPeerProcessId(int socket) { struct ucred creds = {}; socklen_t len = sizeof creds; diff --git a/src/main/cpp/blaze_util_platform.h b/src/main/cpp/blaze_util_platform.h index 1de65b44b9..c3c388de7b 100644 --- a/src/main/cpp/blaze_util_platform.h +++ b/src/main/cpp/blaze_util_platform.h @@ -23,6 +23,9 @@ namespace blaze { // Get the absolute path to the binary being executed. std::string GetSelfPath(); +// Returns the directory Bazel can use to store output. +std::string GetOutputRoot(); + // Returns the process id of the peer connected to this socket. pid_t GetPeerProcessId(int socket); |