the Go rules were made to interoperate with the "go" tool, which
expects that code which is imported is placed under
vendor/
github.com/golang/protobuf/
with BUILD files that have references that are fully qualified within
the Bazel repository.
In such a scenario, it is not Bazel who does the downloading, but
rather the project owner, and on downloading and committing the code
to the repository, they would have to update the BUILD files. Since
BUILD files (especially the ones for Go) can be created/updated
automatically, this is feasible. Unfortunately, I haven't gotten round
to exporting the tooling for that. I could try to prioritize it
though.
The upside is that it is completely compatible with the Go ecosystem,
and the downside is that it does mesh well with Bazel's download
functionality.
If you want to fix this up from the Bazel side, you would have to
revamp go_library() and friends, such that they become macros and a
label
//src/protoc:main
would be translated to
//external/golang-protoc/src/protoc:main
so Bazel accepts the BUILD files. Then, the rule implementation would
translate the //external/golang-protoc/src/protoc label to an
importmap entry "
github.com/golang/protobuf/src/protoc".
The problem is where to store the 2 mappings, in such a way that they
can be accessed in the right places, ie.
1) in BUILD files under external/golang-protoc , //src/... labels in
macro arguments should be interpreted as
//external/golang-protoc/src/...
2) references to //external/golang-protoc/src should import as
"
github.com/golang/protobuf/src"
for 1), you could move the original extension to somewhere else, have
the macros and translation mapping in /tools/build_rules/go/def.bzl
for 2), you could extend go_prefix to take a dict argument, which
would hold the mapping for the entire workspace.
The mappings in 1) and 2) have to match what WORKSPACE tries to
download, so this solution is pretty fragile, and is certainly not
straightforward for new users.
> --
> You received this message because you are subscribed to the Google Groups
> "bazel-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
bazel-discus...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/bazel-discuss/78dd3d92-c4e0-4e34-b766-0b9dfc72ca22%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
--
Han-Wen Nienhuys
Google Munich
han...@google.com