aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-06-23 10:54:52 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-06-23 10:54:52 -0700
commit5fec4bf5f34792e30d2691024cbd9914626db0a3 (patch)
treee1e07586bc1745c32139011fde6c7fe4e61812a7 /src/compiler
parente16907e5a1fb7e61b24d4d141cbad021e96252bf (diff)
parentb309bc94bfd3bdd067e4f0a62d0cd9f29cf3a288 (diff)
Merge branch 'master' into grpc_trace_granularity
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/node_generator.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/node_generator.cc b/src/compiler/node_generator.cc
index 986b97c26e..1fe090d17a 100644
--- a/src/compiler/node_generator.cc
+++ b/src/compiler/node_generator.cc
@@ -74,8 +74,16 @@ grpc::string GetJSMessageFilename(const grpc::string& filename) {
// Given a filename like foo/bar/baz.proto, returns the root directory
// path ../../
-grpc::string GetRootPath(const grpc::string& filename) {
- size_t slashes = std::count(filename.begin(), filename.end(), '/');
+grpc::string GetRootPath(const grpc::string& from_filename,
+ const grpc::string& to_filename) {
+ if (to_filename.find("google/protobuf") == 0) {
+ // Well-known types (.proto files in the google/protobuf directory) are
+ // assumed to come from the 'google-protobuf' npm package. We may want to
+ // generalize this exception later by letting others put generated code in
+ // their own npm packages.
+ return "google-protobuf/";
+ }
+ size_t slashes = std::count(from_filename.begin(), from_filename.end(), '/');
if (slashes == 0) {
return "./";
}
@@ -90,7 +98,7 @@ grpc::string GetRootPath(const grpc::string& filename) {
// from_file, assuming that both paths are relative to the same directory
grpc::string GetRelativePath(const grpc::string& from_file,
const grpc::string& to_file) {
- return GetRootPath(from_file) + to_file;
+ return GetRootPath(from_file, to_file) + to_file;
}
/* Finds all message types used in all services in the file, and returns them