diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-10-23 13:43:06 +0200 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2017-10-23 17:16:23 +0200 |
commit | 1a27c9f03381047ff378e43eb6085c028ba10dc3 (patch) | |
tree | db9385fc28ae647639539ae4843893b0c2618142 /src/main/cpp | |
parent | 0446714686119dd97f8d1f99290f98db91a65e44 (diff) |
client: deduplicate classpath for Bazel server
Fixes https://github.com/bazelbuild/bazel/issues/3938
Change-Id: Ic837f1b97cf8469434118f2660fb15d14c035a14
PiperOrigin-RevId: 173100466
Diffstat (limited to 'src/main/cpp')
-rw-r--r-- | src/main/cpp/blaze.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index 32b21a12e3..287f9b7004 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -44,8 +44,9 @@ #include <algorithm> #include <chrono> // NOLINT (gRPC requires this) #include <cinttypes> -#include <mutex> // NOLINT +#include <mutex> // NOLINT #include <set> +#include <sstream> #include <string> #include <thread> // NOLINT #include <utility> @@ -352,23 +353,30 @@ static vector<string> GetArgumentArray() { die(jvm_args_exit_code, "%s", error.c_str()); } - // We put all directories on the java.library.path that contain .so files. - string java_library_path = "-Djava.library.path="; + // We put all directories on java.library.path that contain .so/.dll files. + set<string> java_library_paths; + std::stringstream java_library_path; + java_library_path << "-Djava.library.path="; string real_install_dir = GetEmbeddedBinariesRoot(globals->options->install_base); bool first = true; for (const auto &it : globals->extracted_binaries) { if (IsSharedLibrary(it)) { - if (!first) { - java_library_path += kListSeparator; + string libpath(blaze::PathAsJvmFlag( + blaze_util::JoinPath(real_install_dir, blaze_util::Dirname(it)))); + // Only add the library path if it's not added yet. + if (java_library_paths.find(libpath) == java_library_paths.end()) { + java_library_paths.insert(libpath); + if (!first) { + java_library_path << kListSeparator; + } + first = false; + java_library_path << libpath; } - first = false; - java_library_path += blaze::PathAsJvmFlag( - blaze_util::JoinPath(real_install_dir, blaze_util::Dirname(it))); } } - result.push_back(java_library_path); + result.push_back(java_library_path.str()); // Force use of latin1 for file names. result.push_back("-Dfile.encoding=ISO-8859-1"); |