Thus far, I have been using go
tool to fetch dependencies. I've set $GOPATH
to ~/projects/holygrail
, and I've checked out my code into src/mycodehosting.foo/myuser/holygrail
.
Given that I actually depend on things such as gRPC, which means I need to build protoc
from protobuf v3's source, I've written a small script that helps me do this. I would strongly prefer to not have to pre-prepare layout when I check out my source code, and I would strongly prefer not to use a bash script to fetch my dependencies, and then build them.
Current tentative solution:
go get
knows how to do)GO15VENDOREXPERIMENT
variable to 1Unfortunately, I am slightly stuck.
~/.bazel/base_workspace
new_local_repository
(later to be switched to use new_git_repository
) inside Bazel's WORKSPACE
, specifying a custom BUILD
file for one of the dependenciesBUILD
-files for git-submodule
-downloaded repositories in vendor/
folder, and expose them to Bazel.Am I on the right track? Am I correct to use submodules? Am I correct to use vendor/
subfolder to store Go libraries?
BUILD
-file-less Go repository (without actually importing the upstream code)?Some more research into this:
BUILD
file for many dependencies (even though they are not submodules, that does not make a difference).go_package()
rule. But this seems to come from Kythe itself.As of few versions ago, Bazel supports slashes in rule names. Along with hacked-in support for custom package names (https://github.com/bazelbuild/rules_go/issues/16) this seems to cover my use case.
tl;dr I have //vendor:BUILD
file which has rules such as go_library(name='github.com/blah/blah', ...)
. Directories are named, e.g., //vendor/github.com/blah/blah
. Each subpackage has a separate rule. I've manually specified dependencies.