Add the vendor/ path, and add git submodules to the appropriate
subdirectory paths under vendor/ The intent is to make use of the golang 1.6 VENDOR extension to build. As seen, the bare example does not correctly build using bazel in this mode.
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@ -1 +1,5 @@
|
|||||||
bazel-*
|
bazel-bazel-*
|
||||||
|
bazel-bin
|
||||||
|
bazel-genfiles
|
||||||
|
bazel-out
|
||||||
|
bazel-testlogs
|
||||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -4,3 +4,9 @@
|
|||||||
[submodule "submodule/src/remote"]
|
[submodule "submodule/src/remote"]
|
||||||
path = submodule/src/remote
|
path = submodule/src/remote
|
||||||
url = git://github.com/laramiel/bazel-example-golang-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
|
||||||
|
@ -18,6 +18,10 @@ $ bazel run :bare
|
|||||||
$ git submodule update --init --recursive
|
$ git submodule update --init --recursive
|
||||||
$ bazel run //submodule:bare
|
$ bazel run //submodule:bare
|
||||||
$ bazel run //submodule:remote
|
$ bazel run //submodule:remote
|
||||||
|
|
||||||
|
$ bazel run //with_vendor:remote
|
||||||
|
$ bazel run //with_vendor:bare
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Explanation
|
# Explanation
|
||||||
@ -45,3 +49,5 @@ ways:
|
|||||||
using those paths. This accounts for the `//submodule:bare`
|
using those paths. This accounts for the `//submodule:bare`
|
||||||
and `//submodule:remote` targets.
|
and `//submodule:remote` targets.
|
||||||
|
|
||||||
|
3. Using the VENDOR extension introduced in go1.6.
|
||||||
|
|
||||||
|
7
vendor/github.com/laramiel/BUILD
generated
vendored
Normal file
7
vendor/github.com/laramiel/BUILD
generated
vendored
Normal file
@ -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"],
|
||||||
|
)
|
1
vendor/github.com/laramiel/bazel-example-golang-bare
generated
vendored
Submodule
1
vendor/github.com/laramiel/bazel-example-golang-bare
generated
vendored
Submodule
Submodule vendor/github.com/laramiel/bazel-example-golang-bare added at 3bd848fc12
1
vendor/github.com/laramiel/bazel-example-golang-remote
generated
vendored
Submodule
1
vendor/github.com/laramiel/bazel-example-golang-remote
generated
vendored
Submodule
Submodule vendor/github.com/laramiel/bazel-example-golang-remote added at 8f2e405bb9
24
with_vendor/BUILD
Normal file
24
with_vendor/BUILD
Normal file
@ -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",
|
||||||
|
],
|
||||||
|
)
|
11
with_vendor/bare.go
Normal file
11
with_vendor/bare.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/laramiel/bazel-example-golang-bare/bare"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello", bare.World())
|
||||||
|
}
|
11
with_vendor/remote.go
Normal file
11
with_vendor/remote.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/laramiel/bazel-example-golang-remote/remote"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello", remote.World())
|
||||||
|
}
|
Reference in New Issue
Block a user