Compare commits
10
Commits
a40db899c9
...
6f40b3a405
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f40b3a405 | ||
|
|
328aa0b8f5 | ||
|
|
d37b5ce6c1 | ||
|
|
aecf949a2a | ||
|
|
decd76f19d | ||
|
|
dad6f57d6d | ||
|
|
f189432d24 | ||
|
|
53207a1865 | ||
|
|
dfd84d2172 | ||
|
|
a2e269c3f3 |
No files matched your search
+5
-1
@@ -1 +1,5 @@
|
||||
bazel-*
|
||||
bazel-bazel-*
|
||||
bazel-bin
|
||||
bazel-genfiles
|
||||
bazel-out
|
||||
bazel-testlogs
|
||||
@@ -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
|
||||
@@ -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(
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_prefix("github.com/laramiel/bazel-example-golang/")
|
||||
|
||||
go_binary(
|
||||
name ="hello",
|
||||
srcs = [ "hello.go" ],
|
||||
)
|
||||
|
||||
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",
|
||||
],
|
||||
name = "hello",
|
||||
srcs = ["hello.go"],
|
||||
deps = [
|
||||
"//cmd",
|
||||
]
|
||||
)
|
||||
@@ -8,15 +8,47 @@ This requires bazel release > `bazel-0.20`.
|
||||
```
|
||||
$ git clone https://github.com/laramiel/bazel-example-golang.git
|
||||
$ cd bazel-example-golang
|
||||
$ git submodule init
|
||||
$ git submodule foreach git pull origin master
|
||||
|
||||
$ 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
|
||||
|
||||
$ bazel run //with_vendor:remote
|
||||
$ bazel run //with_vendor:bare
|
||||
|
||||
```
|
||||
|
||||
# Explanation
|
||||
|
||||
This repository works in conjunction with other git repositories to
|
||||
provide a demonstration of Bazel BUILD rules for golang.
|
||||
|
||||
* [bazel-example-golang](https://github.com/laramiel/bazel-example-golang)
|
||||
The main repository, demonstrating binary, local, and remote repository usage.
|
||||
|
||||
* [bazel-example-golang-remote](https://github.com/laramiel/bazel-example-golang-remote)
|
||||
An example remote repository which includes Bazel rules.
|
||||
|
||||
* [bazel-example-golang-bare](https://github.com/laramiel/bazel-example-golang-bare)
|
||||
An example remote repository without any Bazel rules.
|
||||
|
||||
|
||||
Each of the remote repositories is linked into `go_binary()` targets in several
|
||||
ways:
|
||||
|
||||
1. Using the WORKSPACE file to define `git_repository()` rules.
|
||||
This accounts for the `:remote` and `:bare` targets.
|
||||
|
||||
2. Using git submodules to import the repository source, and
|
||||
using those paths. This accounts for the `//submodule:bare`
|
||||
and `//submodule:remote` targets.
|
||||
|
||||
3. Using the VENDOR extension introduced in go1.6.
|
||||
|
||||
@@ -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(
|
||||
name = "remote",
|
||||
remote = "https://github.com/laramiel/bazel-example-golang-remote.git",
|
||||
commit = "8f2e405",
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
|
||||
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 = """
|
||||
load("@bazel_tools//tools/build_rules/go:def.bzl", "go_prefix", "go_library")
|
||||
go_rules_dependencies()
|
||||
|
||||
go_prefix("github.com/laramiel/bazel-example-golang-bare")
|
||||
|
||||
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
|
||||
)
|
||||
go_register_toolchains(version = "1.19.3")
|
||||
@@ -1,10 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/laramiel/bazel-example-golang-bare/bare"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello", bare.World())
|
||||
}
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/private/var/tmp/_bazel_christian/3262850bcac806b0124f7f44b81dceb1/execroot/__main__
|
||||
@@ -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"
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello World. Cmd")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"leadership","sphere_name":"Leadership","position":1,"code":"01001","name":"Aragorn","traits":"Dúnedain. Noble. Ranger.","keywords":"Sentinel.","text":"Sentinel.<b>Response:</b> After Aragorn commits to a quest, spend 1 resource from his resource pool to ready him.\n","flavor":"\"I am Aragorn son of Arathorn; and if by life or death I can save you, I will.\"\r\n-The Fellowship of the Ring","is_unique":true,"threat":12,"willpower":2,"attack":3,"defense":2,"health":5,"quantity":1,"deck_limit":1,"illustrator":"John Stanko","octgnid":"51223bd0-ffd1-11df-a976-0801200c9001","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Aragorn-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Aragorn.jpg","versions":[{"set_name":"Core Set","year":"2011","url":"https://hallofbeorn.com/LotR/Details/Aragorn-Core"},{"set_name":"The Old Forest","year":"2014","url":"https://hallofbeorn.com/LotR/Details/Aragorn-TOF"},{"set_name":"Fog on the Barrow-downs","year":"2015","url":"https://hallofbeorn.com/LotR/Details/Aragorn-FotBD"},{"set_name":"Two-Player Limited Edition Starter","year":"2018","url":"https://hallofbeorn.com/LotR/Details/Aragorn-TPLES"},{"set_name":"Revised Core Set","year":"2022","url":"https://hallofbeorn.com/LotR/Details/Aragorn-RevCore"}]},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"leadership","sphere_name":"Leadership","position":2,"code":"01002","name":"Théodred","traits":"Noble. Rohan. Warrior.","text":"<b>Response:</b> After Théodred commits to a quest, choose a hero committed to that quest. Add 1 resource to that hero's resource pool.","flavor":"\"Not all is dark. Take courage, Lord of the Mark...\"\r\n-Gandalf, The Two Towers","is_unique":true,"threat":8,"willpower":1,"attack":2,"defense":1,"health":4,"quantity":1,"deck_limit":1,"illustrator":"Jeff Himmelman","octgnid":"51223bd0-ffd1-11df-a976-0801200c9002","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Theodred-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Theodred.jpg","versions":[{"set_name":"Core Set","year":"2011","url":"https://hallofbeorn.com/LotR/Details/Theodred-Core"},{"set_name":"Revised Core Set","year":"2022","url":"https://hallofbeorn.com/LotR/Details/Theodred-RevCore"}]},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"leadership","sphere_name":"Leadership","position":3,"code":"01003","name":"Glóin","traits":"Dwarf. Noble.","text":"<b>Response:</b> After Glóin suffers damage, add 1 resource to his resource pool for each point of damage he just suffered.\n","flavor":"His beard, very long and forked, was white, nearly as white as the snow-white cloth of his garments.\r\n-The Fellowship of the Ring","is_unique":true,"threat":9,"willpower":2,"attack":2,"defense":1,"health":4,"quantity":1,"deck_limit":1,"illustrator":"Tom Garden","octgnid":"51223bd0-ffd1-11df-a976-0801200c9003","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Gloin-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Gloin.jpg","versions":[{"set_name":"Core Set","year":"2011","url":"https://hallofbeorn.com/LotR/Details/Gloin-Core"},{"set_name":"Revised Core Set","year":"2022","url":"https://hallofbeorn.com/LotR/Details/Gloin-RevCore"}]},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"tactics","sphere_name":"Tactics","position":4,"code":"01004","name":"Gimli","traits":"Dwarf. Noble. Warrior.","text":"Gimli gets +1 [attack] for each damage token on him.\n","flavor":"\"Men need many words before deeds. My axe is restless in my hands\"\r\n-The Two Towers","is_unique":true,"threat":11,"willpower":2,"attack":2,"defense":2,"health":5,"quantity":1,"deck_limit":1,"illustrator":"Tony Foti","octgnid":"51223bd0-ffd1-11df-a976-0801200c9004","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Gimli-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Gimli.jpg","versions":[{"set_name":"Core Set","year":"2011","url":"https://hallofbeorn.com/LotR/Details/Gimli-Core"},{"set_name":"The Ruins of Belegost","year":"2015","url":"https://hallofbeorn.com/LotR/Details/Gimli-TRoB"},{"set_name":"Revised Core Set","year":"2022","url":"https://hallofbeorn.com/LotR/Details/Gimli-RevCore"}]},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"tactics","sphere_name":"Tactics","position":5,"code":"01005","name":"Legolas","traits":"Noble. Silvan. Warrior.","keywords":"Ranged.","text":"Ranged.\n<b>Response:</b> After Legolas participates in an attack that destroys an enemy, place 2 progress tokens on the current quest.\n","flavor":"\"I can waLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
[{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"leadership","sphere_name":"Leadership","position":1,"code":"01001","name":"Aragorn","traits":"Dúnedain. Noble. Ranger.","keywords":"Sentinel.","text":"Sentinel.\r\n<b>Response:</b> After Aragorn commits to a quest, spend 1 resource from his resource pool to ready him.","flavor":"\"I am Aragorn son of Arathorn; and if by life or death I can save you, I will.\"\r\n-The Fellowship of the Ring","is_unique":true,"threat":12,"willpower":2,"attack":3,"defense":2,"health":5,"quantity":1,"deck_limit":1,"illustrator":"John Stanko","octgnid":"51223bd0-ffd1-11df-a976-0801200c9001","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Aragorn-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Aragorn.jpg"},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"leadership","sphere_name":"Leadership","position":2,"code":"01002","name":"Théodred","traits":"Noble. Rohan. Warrior.","text":"<b>Response:</b> After Théodred commits to a quest, choose a hero committed to that quest. Add 1 resource to that hero's resource pool.","flavor":"\"Not all is dark. Take courage, Lord of the Mark...\"\r\n-Gandalf, The Two Towers","is_unique":true,"threat":8,"willpower":1,"attack":2,"defense":1,"health":4,"quantity":1,"deck_limit":1,"illustrator":"Jeff Himmelman","octgnid":"51223bd0-ffd1-11df-a976-0801200c9002","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Theodred-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Theodred.jpg"},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"leadership","sphere_name":"Leadership","position":3,"code":"01003","name":"Glóin","traits":"Dwarf. Noble.","text":"<b>Response:</b> After Glóin suffers damage, add 1 resource to his resource pool for each point of damage he just suffered.","flavor":"His beard, very long and forked, was white, nearly as white as the snow-white cloth of his garments.\r\n-The Fellowship of the Ring","is_unique":true,"threat":9,"willpower":2,"attack":2,"defense":1,"health":4,"quantity":1,"deck_limit":1,"illustrator":"Tom Garden","octgnid":"51223bd0-ffd1-11df-a976-0801200c9003","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Gloin-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Gloin.jpg"},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"tactics","sphere_name":"Tactics","position":4,"code":"01004","name":"Gimli","traits":"Dwarf. Noble. Warrior.","text":"Gimli gets +1 [attack] for each damage token on him.","flavor":"\"Men need many words before deeds. My axe is restless in my hands\"\r\n-The Two Towers","is_unique":true,"threat":11,"willpower":2,"attack":2,"defense":2,"health":5,"quantity":1,"deck_limit":1,"illustrator":"Tony Foti","octgnid":"51223bd0-ffd1-11df-a976-0801200c9004","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Gimli-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Gimli.jpg"},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"tactics","sphere_name":"Tactics","position":5,"code":"01005","name":"Legolas","traits":"Noble. Silvan. Warrior.","keywords":"Ranged.","text":"Ranged.\r\n<b>Response:</b> After Legolas participates in an attack that destroys an enemy, place 2 progress tokens on the current quest.","flavor":"\"I can walk this path, but others have not this skill.\"\r\n-The Fellowship of the Ring","is_unique":true,"threat":9,"willpower":1,"attack":3,"defense":1,"health":4,"quantity":1,"deck_limit":1,"illustrator":"Magali Villeneuve","octgnid":"51223bd0-ffd1-11df-a976-0801200c9005","has_errata":false,"url":"https://hallofbeorn.com/LotR/Details/Legolas-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/Core-Set/Legolas.jpg"},{"pack_code":"Core","pack_name":"Core Set","is_official":true,"type_code":"hero","type_name":"Hero","sphere_code":"tactics","sphere_name":"Tactics","position":6,"code":"01006","name":"Thalin","traits":"Dwarf. Warrior.","text":"While Thalin is committed to a quest, deal 1 damage to each enemy as it is revealed by the encounter deck.","flavor":"There hammer on the anvil smote,\r\nThere chisel clove, and graver wrote;\r\nThere forged was blade, and bound was hilt;\r\nThe delver mined, the mason built.\r\n-The Fellowship of the Ring","is_unique":true,"threat":9,"willpower":1,"attack":2,"defense":2,"health":4,"quantity":1,"deck_limit":1,"illustrator":"Jen Zee","octgnid":"51223bd0-ffd1-11df-a976-0801200c9006","has_errata":true,"url":"https://hallofbeorn.com/LotR/Details/Thalin-Core","imagesrc":"https://s3.amazonaws.com/hallofbeorn-resources/Images/Cards/CoreLine truncated
|
||||
@@ -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!"
|
||||
}
|
||||
@@ -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
@@ -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"],
|
||||
)
|
||||
File renamed without changes.
+1
Submodule vendor/github.com/laramiel/bazel-example-golang-remote added at 4a9199be6e.
Reference in new issue
Block a user