Use custom util instead of std::to_string.
std::to_string is not avcaliable on mingw.
--
MOS_MIGRATED_REVID=98923935
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index b314f23..caa95b2 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -304,7 +304,7 @@
if (!globals->options.batch) {
result.push_back("--max_idle_secs");
- result.push_back(std::to_string(globals->options.max_idle_secs));
+ result.push_back(ToString(globals->options.max_idle_secs));
} else {
// --batch must come first in the arguments to Java main() because
// the code expects it to be at args[0] if it's been set.
@@ -333,7 +333,7 @@
}
if (globals->options.webstatus_port) {
result.push_back("--use_webstatusserver=" + \
- std::to_string(globals->options.webstatus_port));
+ ToString(globals->options.webstatus_port));
}
// This is only for Blaze reporting purposes; the real interpretation of the
@@ -369,14 +369,14 @@
// Add commom command options for logging to the given argument array.
static void AddLoggingArgs(vector<string>* args) {
- args->push_back("--startup_time=" + std::to_string(globals->startup_time));
+ args->push_back("--startup_time=" + ToString(globals->startup_time));
if (globals->command_wait_time != 0) {
args->push_back("--command_wait_time=" +
- std::to_string(globals->command_wait_time));
+ ToString(globals->command_wait_time));
}
if (globals->extract_data_time != 0) {
args->push_back("--extract_data_time=" +
- std::to_string(globals->extract_data_time));
+ ToString(globals->extract_data_time));
}
if (globals->restart_reason != NO_RESTART) {
const char *reasons[] = {
@@ -896,7 +896,7 @@
uint64_t st = MonotonicClock();
// Work in a temp dir to avoid races.
string tmp_install = globals->options.install_base + ".tmp." +
- std::to_string(getpid());
+ ToString(getpid());
string tmp_binaries = tmp_install + "/_embedded_binaries";
ActuallyExtractData(self_path, tmp_binaries);
@@ -1483,7 +1483,7 @@
ftruncate(globals->lockfd, 0);
const char *tty = ttyname(STDIN_FILENO); // NOLINT (single-threaded)
string msg = "owner=" + globals->options.GetProductName() + " launcher\npid="
- + std::to_string(getpid()) + "\ntty=" + (tty ? tty : "") + "\n";
+ + ToString(getpid()) + "\ntty=" + (tty ? tty : "") + "\n";
// Don't bother checking for error, since it's unlikely and unimportant.
// The contents are currently meant only for debugging.
write(globals->lockfd, msg.data(), msg.size());
diff --git a/src/main/cpp/blaze_util.h b/src/main/cpp/blaze_util.h
index 9d53d7d..4cf6dc9 100644
--- a/src/main/cpp/blaze_util.h
+++ b/src/main/cpp/blaze_util.h
@@ -21,6 +21,7 @@
#include <sys/types.h>
+#include <sstream>
#include <string>
#include <vector>
@@ -103,6 +104,16 @@
bool CheckJavaVersionIsAtLeast(const string &jvm_version,
const string &version_spec);
+// Converts a project identifier to string.
+// Workaround for mingw where std::to_string is not implemented.
+// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015.
+template <typename T>
+string ToString(const T& value) {
+ std::ostringstream oss;
+ oss << value;
+ return oss.str();
+}
+
} // namespace blaze
#endif // BAZEL_SRC_MAIN_CPP_BLAZE_UTIL_H_
diff --git a/src/main/cpp/blaze_util_linux.cc b/src/main/cpp/blaze_util_linux.cc
index e18a853..8f0218a 100644
--- a/src/main/cpp/blaze_util_linux.cc
+++ b/src/main/cpp/blaze_util_linux.cc
@@ -132,7 +132,7 @@
string GetProcessCWD(int pid) {
char server_cwd[PATH_MAX] = {};
if (readlink(
- ("/proc/" + std::to_string(pid) + "/cwd").c_str(),
+ ("/proc/" + ToString(pid) + "/cwd").c_str(),
server_cwd, sizeof(server_cwd)) < 0) {
return "";
}
diff --git a/src/main/cpp/blaze_util_mingw.cc b/src/main/cpp/blaze_util_mingw.cc
index f9eab3c..9c3ba8a 100644
--- a/src/main/cpp/blaze_util_mingw.cc
+++ b/src/main/cpp/blaze_util_mingw.cc
@@ -85,7 +85,7 @@
string GetProcessCWD(int pid) {
char server_cwd[PATH_MAX] = {};
if (readlink(
- ("/proc/" + std::to_string(pid) + "/cwd").c_str(),
+ ("/proc/" + ToString(pid) + "/cwd").c_str(),
server_cwd, sizeof(server_cwd)) < 0) {
return "";
}
diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc
index a46a721..5f4fd2a 100644
--- a/src/main/cpp/option_processor.cc
+++ b/src/main/cpp/option_processor.cc
@@ -446,16 +446,16 @@
for (int ii = 0; ii < it->second.size(); ii++) {
const RcOption& rcoption = it->second[ii];
command_arguments_.push_back(
- "--default_override=" + std::to_string(rcoption.rcfile_index()) + ":"
+ "--default_override=" + ToString(rcoption.rcfile_index()) + ":"
+ it->first + "=" + rcoption.option());
}
}
// Splice the terminal options.
command_arguments_.push_back(
- "--isatty=" + std::to_string(IsStandardTerminal()));
+ "--isatty=" + ToString(IsStandardTerminal()));
command_arguments_.push_back(
- "--terminal_columns=" + std::to_string(GetTerminalColumns()));
+ "--terminal_columns=" + ToString(GetTerminalColumns()));
// Pass the client environment to the server in server mode.
if (batch) {