question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please add proto_library attrs to adjust its "virtual path"

See original GitHub issue

When a .proto file contains import "foo/bar/baz.proto", that path doesn’t actually have to exist as-is on the filesystem. It can be mapped to any arbitrary path by protoc by using an equals sign in --proto_path: protoc --proto_path=foo/bar/baz.proto=some/other/path.proto.

Please add attributes to proto_library() to adjust the virtual path used to locate its source proto, similar to how cc_library() allows changing the include path. Good attributes would be:

  • import_prefix to add a prefix to the virtual path.
  • strip_import_prefix to remove a prefix from the virtual path.

The main use case is cross-repo includes, where we want to use nice short names in the filesystem but URL-prefixed names in the import paths:

# ./external/base/proto/BUILD
proto_library(
  name = "build_info",
  srcs = ["build_info.proto"],
  import_prefix = "github.com/myorg/base",
)

# ./proto/BUILD
proto_library(
  name = "helloworld",
  srcs = ["helloworld.proto"],
  deps = ["@base//proto:build_info],
)

# CURRENT ./proto/helloworld.proto
import "proto/build_info.proto";

# DESIRED ./proto/helloworld.proto
import "github.com/myorg/base/proto/build_info.proto";

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:24 (18 by maintainers)

github_iconTop GitHub Comments

8reactions
tomwilkiecommented, Nov 21, 2017

Hi there; just to chime in - this issue is preventing us vendoring proto libraries which depend on other proto libraries in go projects - see bazelbuild/rules_go#900. A good example is the go Kubernetes Client library. Is there any chance someone might work on this any time soon, or should I take a stab?

7reactions
jayconrodcommented, May 4, 2018

Any chance this could be implemented soon?

This blocks Kubernetes and a number of related projects from using proto_library. They are having to pre-generate code with a separate system and check it in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TFS Build release IIS Deployment Virtual path should begin ...
Please check the settings with the step IIS Web App Manage. Seems you did not set the Virtual path correctly. Virtual path:.
Read more >
Configuring a Virtual Path
Note: A virtual path is a relative path that represents the actual mapped path to the physical file location. Virtual Path example: Loading...
Read more >
question about virtual paths in UI for ASP.NET AJAX - Telerik
Yes, this is possible - RadFileExplorer works with virtual folders. You just need to set the corresponding virtual path in the configuration. for...
Read more >
There is something about "Paths" for Asp.net beginners
Naturally, the server controls also have corresponding attributes that accepts the path values as relative URLs, and, set those into the ...
Read more >
JBoss 6 Virtual Directory-Virtual Path
jsf , I have to include a xml file which is in Jboss data dir. I think I have to create a virtual/mapping...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found