Skip to content

Commit

Permalink
bazel: generate pkg/generated/bindata.go at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
ixdy committed Apr 25, 2018
1 parent aab5cb4 commit b9a029d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions build/root/BUILD.root
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ filegroup(
"//staging:all-srcs",
"//test:all-srcs",
"//third_party:all-srcs",
"//translations:all-srcs",
"//vendor:all-srcs",
],
tags = ["automanaged"],
Expand Down
4 changes: 2 additions & 2 deletions hack/generate-bindata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pushd "${KUBE_ROOT}" >/dev/null
# These are files for e2e tests.
BINDATA_OUTPUT="test/e2e/generated/bindata.go"
go-bindata -nometadata -o "${BINDATA_OUTPUT}.tmp" -pkg generated \
-ignore .jpg -ignore .png -ignore .md \
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
"test/e2e/testing-manifests/..." \
"test/images/..." \
"test/fixtures/..."
Expand All @@ -64,7 +64,7 @@ rm -f "${BINDATA_OUTPUT}.tmp"
# These are files for runtime code
BINDATA_OUTPUT="pkg/generated/bindata.go"
go-bindata -nometadata -nocompress -o "${BINDATA_OUTPUT}.tmp" -pkg generated \
-ignore .jpg -ignore .png -ignore .md \
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
"translations/..."

gofmt -s -w "${BINDATA_OUTPUT}.tmp"
Expand Down
18 changes: 18 additions & 0 deletions pkg/generated/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ load(
"go_library",
)

genrule(
name = "bindata",
srcs = [
"//translations:all-srcs",
],
outs = ["bindata.go"],
cmd = """
$(location //vendor/github.com/jteeuwen/go-bindata/go-bindata:go-bindata) \
-nometadata -nocompress -o "$(OUTS)" -pkg generated \
-prefix $$(pwd) \
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
$(SRCS)
""",
tools = [
"//vendor/github.com/jteeuwen/go-bindata/go-bindata",
],
)

go_library(
name = "go_default_library",
srcs = [
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/generated/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ genrule(
$(location //vendor/github.com/jteeuwen/go-bindata/go-bindata:go-bindata) \
-nometadata -o "$(OUTS)" -pkg generated \
-prefix $$(pwd) \
-ignore .jpg -ignore .png -ignore .md \
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
$(SRCS)
""",
tools = [
Expand Down
13 changes: 13 additions & 0 deletions translations/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

0 comments on commit b9a029d

Please sign in to comment.