From ae293ba44505a678d6a63f667b36339a1864a92d Mon Sep 17 00:00:00 2001 From: Radu Berinde Date: Fri, 30 Aug 2024 08:46:58 -0700 Subject: [PATCH] add Makefile, bazel support Add a Makefile and support generating bazel files to allow overriding the dependency in CRDB. --- .gitignore | 3 +++ Makefile | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 6eb7626..1934c4c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ go.work.sum .idea/ +# Bazel files, generated with 'make gen-bazel'. +/WORKSPACE +BUILD.bazel diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fbd123b --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +GO := go +PKG := ./... +GOFLAGS := +STRESSFLAGS := +TAGS := crlib_invariants +TESTS := . + +.PHONY: gen-bazel +gen-bazel: + @echo "Generating WORKSPACE" + @echo 'workspace(name = "com_github_cockroachdb_crlib")' > WORKSPACE + @echo 'Running gazelle...' + ${GO} run github.com/bazelbuild/bazel-gazelle/cmd/gazelle@v0.37.0 update --go_prefix=github.com/cockroachdb/crlib --repo_root=. + @echo 'You should now be able to build Cockroach using:' + @echo ' ./dev build short -- --override_repository=com_github_cockroachdb_crlib=${CURDIR}' + +.PHONY: clean-bazel +clean-bazel: + git clean -dxf WORKSPACE BUILD.bazel '**/BUILD.bazel' + +.PHONY: test +test: + ${GO} test -tags '$(TAGS)' ${testflags} -run ${TESTS} ${PKG} + +.PHONY: lint +lint: + ${GO} test -tags '$(TAGS)' -run ${TESTS} ./internal/lint + +.PHONY: stress +stress: + ${GO} test -tags '$(TAGS)' -exec 'stress -p 2 -maxruns 1000' -v -run ${TESTS} ${PKG}