Compare commits
11 Commits
a40db899c9
...
lotr
Author | SHA1 | Date | |
---|---|---|---|
7fc09053a4 | |||
6f40b3a405 | |||
328aa0b8f5 | |||
d37b5ce6c1 | |||
aecf949a2a | |||
decd76f19d | |||
dad6f57d6d | |||
f189432d24 | |||
53207a1865 | |||
dfd84d2172 | |||
a2e269c3f3 |
38
.gitignore
vendored
38
.gitignore
vendored
@ -1 +1,37 @@
|
|||||||
bazel-*
|
# ---> Bazel
|
||||||
|
# gitignore template for Bazel build system
|
||||||
|
# website: https://bazel.build/
|
||||||
|
|
||||||
|
# Ignore all bazel-* symlinks. There is no full list since this can change
|
||||||
|
# based on the name of the directory bazel is cloned into.
|
||||||
|
/bazel-*
|
||||||
|
|
||||||
|
# Directories for the Bazel IntelliJ plugin containing the generated
|
||||||
|
# IntelliJ project files and plugin configuration. Seperate directories are
|
||||||
|
# for the IntelliJ, Android Studio and CLion versions of the plugin.
|
||||||
|
/.ijwb/
|
||||||
|
/.aswb/
|
||||||
|
/.clwb/
|
||||||
|
|
||||||
|
# ---> Go
|
||||||
|
# If you prefer the allow list template instead of the deny list, see community template:
|
||||||
|
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||||
|
#
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Test binary, built with `go test -c`
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Dependency directories (remove the comment below to include it)
|
||||||
|
# vendor/
|
||||||
|
|
||||||
|
# Go workspace file
|
||||||
|
go.work
|
||||||
|
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
|
||||||
|
35
BUILD
35
BUILD
@ -1,36 +1,13 @@
|
|||||||
load("@bazel_tools//tools/build_rules/go:def.bzl", "go_prefix", "go_binary")
|
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
|
||||||
|
|
||||||
package(
|
package(
|
||||||
default_visibility = ["//visibility:public"],
|
default_visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
go_prefix("github.com/laramiel/bazel-example-golang/")
|
|
||||||
|
|
||||||
go_binary(
|
go_binary(
|
||||||
name ="hello",
|
name = "hello",
|
||||||
srcs = [ "hello.go" ],
|
srcs = ["hello.go"],
|
||||||
)
|
deps = [
|
||||||
|
"//cmd",
|
||||||
go_binary(
|
]
|
||||||
name ="local",
|
|
||||||
srcs = [ "local.go" ],
|
|
||||||
deps = [
|
|
||||||
"//local",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_binary(
|
|
||||||
name ="remote",
|
|
||||||
srcs = [ "remote.go" ],
|
|
||||||
deps = [
|
|
||||||
"@remote//:remote",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_binary(
|
|
||||||
name ="bare",
|
|
||||||
srcs = [ "bare.go" ],
|
|
||||||
deps = [
|
|
||||||
"@bare//:bare",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
22
README.md
22
README.md
@ -1,22 +1,2 @@
|
|||||||
# bazel-example-golang
|
# lotr
|
||||||
|
|
||||||
An example project demonstrating bazel build rules for go with
|
|
||||||
a local binary (go_binary) and a local library (go_library).
|
|
||||||
|
|
||||||
This requires bazel release > `bazel-0.20`.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ git clone https://github.com/laramiel/bazel-example-golang.git
|
|
||||||
$ cd bazel-example-golang
|
|
||||||
|
|
||||||
$ bazel run :hello
|
|
||||||
|
|
||||||
$ bazel run :local
|
|
||||||
$ bazel run :remote
|
|
||||||
$ bazel run :bare
|
|
||||||
|
|
||||||
$ git submodule update --init --recursive
|
|
||||||
$ bazel run //submodule:bare
|
|
||||||
$ bazel run //submodule:remote
|
|
||||||
```
|
|
||||||
|
|
||||||
|
41
WORKSPACE
41
WORKSPACE
@ -1,30 +1,23 @@
|
|||||||
load("@bazel_tools//tools/build_rules/go:def.bzl", "go_repositories")
|
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||||
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
go_repositories()
|
# git_repository(
|
||||||
|
# name = "io_bazel_rules_go",
|
||||||
|
# remote = "https://github.com/bazelbuild/rules_go.git",
|
||||||
|
# branch = "master",
|
||||||
|
# )
|
||||||
|
|
||||||
git_repository(
|
http_archive(
|
||||||
name = "remote",
|
name = "io_bazel_rules_go",
|
||||||
remote = "https://github.com/laramiel/bazel-example-golang-remote.git",
|
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
|
||||||
commit = "8f2e405",
|
urls = [
|
||||||
|
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
|
||||||
|
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||||
|
|
||||||
BARE_BUILD = """
|
go_rules_dependencies()
|
||||||
load("@bazel_tools//tools/build_rules/go:def.bzl", "go_prefix", "go_library")
|
|
||||||
|
|
||||||
go_prefix("github.com/laramiel/bazel-example-golang-bare")
|
go_register_toolchains(version = "1.19.3")
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "bare",
|
|
||||||
srcs = [ "bare.go" ],
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
new_git_repository(
|
|
||||||
name = "bare",
|
|
||||||
remote = "https://github.com/laramiel/bazel-example-golang-bare.git",
|
|
||||||
commit = "3bd848f",
|
|
||||||
build_file_content = BARE_BUILD
|
|
||||||
)
|
|
||||||
|
10
bare.go
10
bare.go
@ -1,10 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/laramiel/bazel-example-golang-bare/bare"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello", bare.World())
|
|
||||||
}
|
|
1
bazel-lotr
Symbolic link
1
bazel-lotr
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/private/var/tmp/_bazel_christian/3262850bcac806b0124f7f44b81dceb1/execroot/__main__
|
8
cmd/BUILD
Normal file
8
cmd/BUILD
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name ="cmd",
|
||||||
|
srcs = [ "cmd.go" ],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
importpath= "github.com/squk/lotr/cmd"
|
||||||
|
)
|
9
cmd/cmd.go
Normal file
9
cmd/cmd.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello World. Cmd")
|
||||||
|
}
|
1
data/Bot.Cards.json
Normal file
1
data/Bot.Cards.json
Normal file
File diff suppressed because one or more lines are too long
1
data/Export.Cards.json
Normal file
1
data/Export.Cards.json
Normal file
File diff suppressed because one or more lines are too long
10
local.go
10
local.go
@ -1,10 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/laramiel/bazel-example-golang/local/local"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello ", local.World())
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
load("@bazel_tools//tools/build_rules/go:def.bzl", "go_library")
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name ="local",
|
|
||||||
srcs = [ "local.go" ],
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
@ -1,5 +0,0 @@
|
|||||||
package local
|
|
||||||
|
|
||||||
func World() string {
|
|
||||||
return "local.World!"
|
|
||||||
}
|
|
10
remote.go
10
remote.go
@ -1,10 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/laramiel/bazel-example-golang-remote/remote"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello ", remote.World())
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
load("@bazel_tools//tools/build_rules/go:def.bzl", "go_prefix", "go_binary")
|
|
||||||
|
|
||||||
package(
|
|
||||||
default_visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_binary(
|
|
||||||
name ="bare",
|
|
||||||
srcs = [ "bare.go" ],
|
|
||||||
deps = [
|
|
||||||
"//submodule/src:bare",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_binary(
|
|
||||||
name ="remote",
|
|
||||||
srcs = [ "remote.go" ],
|
|
||||||
deps = [
|
|
||||||
"//submodule/src/remote",
|
|
||||||
],
|
|
||||||
)
|
|
@ -1,10 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/laramiel/bazel-example-golang-bare/bare"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello", bare.World())
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/laramiel/bazel-example-golang-remote/remote"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello", remote.World())
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
load("@bazel_tools//tools/build_rules/go:def.bzl", "go_prefix", "go_library")
|
|
||||||
|
|
||||||
go_prefix("github.com/laramiel/bazel-example-golang-bare/")
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "bare",
|
|
||||||
srcs = [ "bare/bare.go" ],
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
Submodule submodule/src/remote deleted from 8f2e405bb9
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("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "bare",
|
||||||
|
srcs = ["bazel-example-golang-bare/bare.go"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
0
submodule/src/bare → vendor/github.com/laramiel/bazel-example-golang-bare
generated
vendored
0
submodule/src/bare → vendor/github.com/laramiel/bazel-example-golang-bare
generated
vendored
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 4a9199be6e
Reference in New Issue
Block a user