diff --git a/.gitignore b/.gitignore index ac51a05..40a8965 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -bazel-* +bazel-bazel-* +bazel-bin +bazel-genfiles +bazel-out +bazel-testlogs diff --git a/.gitmodules b/.gitmodules index e461f83..dfb9f8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,9 @@ [submodule "submodule/src/remote"] path = submodule/src/remote url = git://github.com/laramiel/bazel-example-golang-remote +[submodule "vendor/github.com/laramiel/bazel-example-golang-remote"] + path = vendor/github.com/laramiel/bazel-example-golang-remote + url = git://github.com/laramiel/bazel-example-golang-remote +[submodule "vendor/github.com/laramiel/bazel-example-golang-bare"] + path = vendor/github.com/laramiel/bazel-example-golang-bare + url = git://github.com/laramiel/bazel-example-golang-bare diff --git a/README.md b/README.md index 1f90127..f2ef6bb 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ $ bazel run :bare $ git submodule update --init --recursive $ bazel run //submodule:bare $ bazel run //submodule:remote + +$ bazel run //with_vendor:remote +$ bazel run //with_vendor:bare + ``` # Explanation @@ -45,3 +49,5 @@ ways: using those paths. This accounts for the `//submodule:bare` and `//submodule:remote` targets. +3. Using the VENDOR extension introduced in go1.6. + diff --git a/vendor/github.com/laramiel/BUILD b/vendor/github.com/laramiel/BUILD new file mode 100644 index 0000000..26a863a --- /dev/null +++ b/vendor/github.com/laramiel/BUILD @@ -0,0 +1,7 @@ +load("@bazel_tools//tools/build_rules/go:def.bzl", "go_library") + +go_library( + name = "bare", + srcs = [ "bazel-example-golang-bare/bare.go" ], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/laramiel/bazel-example-golang-bare b/vendor/github.com/laramiel/bazel-example-golang-bare new file mode 160000 index 0000000..3bd848f --- /dev/null +++ b/vendor/github.com/laramiel/bazel-example-golang-bare @@ -0,0 +1 @@ +Subproject commit 3bd848fc12248975bfb9143607807b5bb56e30a8 diff --git a/vendor/github.com/laramiel/bazel-example-golang-remote b/vendor/github.com/laramiel/bazel-example-golang-remote new file mode 160000 index 0000000..8f2e405 --- /dev/null +++ b/vendor/github.com/laramiel/bazel-example-golang-remote @@ -0,0 +1 @@ +Subproject commit 8f2e405bb9a24a3b30a54f4c967b630a0bade236 diff --git a/with_vendor/BUILD b/with_vendor/BUILD new file mode 100644 index 0000000..647db8d --- /dev/null +++ b/with_vendor/BUILD @@ -0,0 +1,24 @@ +load("@bazel_tools//tools/build_rules/go:def.bzl", "go_prefix", "go_binary") + +package( + default_visibility = ["//visibility:public"], +) + +# BAZEL does not work correctly with BUILD files rooted elsewhere than +# the actual code directory. +# +#go_binary( +# name ="bare", +# srcs = [ "bare.go" ], +# deps = [ +# "//vendor/github.com/laramiel:bare", +# ], +#) + +go_binary( + name ="remote", + srcs = [ "remote.go" ], + deps = [ + "//vendor/github.com/laramiel/bazel-example-golang-remote:remote", + ], +) diff --git a/with_vendor/bare.go b/with_vendor/bare.go new file mode 100644 index 0000000..c2e06ac --- /dev/null +++ b/with_vendor/bare.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + + "github.com/laramiel/bazel-example-golang-bare/bare" +) + +func main() { + fmt.Println("Hello", bare.World()) +} diff --git a/with_vendor/remote.go b/with_vendor/remote.go new file mode 100644 index 0000000..836a104 --- /dev/null +++ b/with_vendor/remote.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + + "github.com/laramiel/bazel-example-golang-remote/remote" +) + +func main() { + fmt.Println("Hello", remote.World()) +}