Skip to content

Commit

Permalink
Add back build prerequisite go_deps.bzl
Browse files Browse the repository at this point in the history
Make go_deps.bzl a non-phony prerequisite for build
Only update go_deps.bzl if `go.mod`  was changed, only reset `go_deps.bzl` if it does not exists or is empty
Add realclean target that also deletes `go_deps.bzl` in addition to the rest of the bazel cleanup
  • Loading branch information
FR4NK-W committed Jun 16, 2021
1 parent 3167407 commit c2a2f21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@

.PHONY: all bazel build clean gazelle package package_deb package_rpm
.PHONY: all bazel build clean realclean package package_deb package_rpm

build: bazel
#go build -ldflags "-X github.com/netsec-ethz/bootstrapper/config.versionString="$(./.bazel-build-env | awk '{print $2}')

bazel:
bazel: go_deps.bzl
rm -f bin/*
bazel build //:bootstrapper
cp bazel-bin/bootstrapper bin/

all: go_deps.bzl gazelle build test package
all: build test package

clean:
bazel clean
rm -f bin/*

realclean: clean
bazel clean --expunge
rm ~/.cache/bazel
rm -f go_deps.bzl

package: package_deb

package_deb: build
Expand All @@ -25,9 +30,6 @@ package_rpm: build
bazel build //:scion-bootstrapper-rpm
cp bazel-bin/scion-bootstrapper-*.*.rpm bin/

gazelle: go.mod go_deps.bzl
bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=go_deps.bzl%go_deps

define go_deps_boilerplate
# Generated from go.mod by gazelle. DO NOT EDIT
load("@bazel_gazelle//:deps.bzl", "go_repository")
Expand All @@ -36,8 +38,11 @@ def go_deps():
pass
endef

go_deps.bzl:
go_deps.bzl: go.mod
ifeq (,$(wildcard go_deps.bzl))
$(file > ./go_deps.bzl,$(go_deps_boilerplate))
endif
bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=go_deps.bzl%go_deps -prune

test: build
bazel test --config=unit --test_output=errors ...
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ The latter should return a file containing the requested TRC.
## Contributing

When contributing, please run `make all` in order to make sure that all targets build and to run the linter.
To update the `go_deps.bzl` file and the dependencies Bazel uses from the `go.mod` module file, run `make gazelle`.
To generate the `go_deps.bzl` file from scratch, delete it and run `make go_deps.bzl`.

0 comments on commit c2a2f21

Please sign in to comment.