Skip to content

Commit

Permalink
Add build tags for Vault
Browse files Browse the repository at this point in the history
Instead of writing a 2 line sed script, the Vault team decided to
use special build tags if you want to depend on anything in Vault core.
  • Loading branch information
sethvargo committed Aug 11, 2016
1 parent d61c3f9 commit 985eee7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@ VERSIONPRE?=$(shell awk -F\" '/^\tVersionPrerelease/ { print $$2; exit }' versio
VERSION?=$(shell if [ "${VERSIONPRE}x" != x ]; then echo "${VERSIONMAJ}-${VERSIONPRE}"; else echo "${VERSIONMAJ}"; fi)
EXTERNAL_TOOLS=\
github.com/mitchellh/gox
BUILD_TAGS?=vault

default: test

# bin generates the binaries for all platforms.
bin: generate
@sh -c "'${CURDIR}/scripts/build.sh' '${NAME}'"
@BUILD_TAGS='${BUILD_TAGS}' sh -c "'${CURDIR}/scripts/build.sh' '${NAME}'"

# dev creates binares for testing locally - they are put into ./bin and $GOPATH.
dev: generate
@DEV=1 sh -c "'${CURDIR}/scripts/build.sh' '${NAME}'"
@BUILD_TAGS='${BUILD_TAGS}' DEV=1 sh -c "'${CURDIR}/scripts/build.sh' '${NAME}'"

# dist creates the binaries for distibution.
dist:
@sh -c "'${CURDIR}/scripts/dist.sh' '${NAME}' '${VERSION}'"
@BUILD_TAGS='${BUILD_TAGS}' sh -c "'${CURDIR}/scripts/dist.sh' '${NAME}' '${VERSION}'"

# test runs the test suite and vets the code.
test: generate
@echo "==> Running tests..."
@go list $(TEST) \
| grep -v "github.com/hashicorp/${NAME}/vendor" \
| xargs -n1 go test -timeout=60s -parallel=10 ${TESTARGS}
| grep -v "/vendor/" \
| xargs -n1 go test -tags='${BUILD_TAGS}' -timeout=60s -parallel=10 ${TESTARGS}

# testrace runs the race checker
testrace: generate
@echo "==> Running tests (race)..."
@go list $(TEST) \
| grep -v "github.com/hashicorp/${NAME}/vendor" \
| xargs -n1 go test -timeout=60s -race ${TESTARGS}
| grep -v "/vendor/" \
| xargs -n1 go test -tags='${BUILD_TAGS}' -timeout=60s -race ${TESTARGS}

# updatedeps installs all the dependencies needed to run and build.
updatedeps:
Expand All @@ -43,8 +44,8 @@ generate:
@echo "==> Generating..."
@find . -type f -name '.DS_Store' -delete
@go list ./... \
| grep -v "github.com/hashicorp/${NAME}/vendor" \
| xargs -n1 go generate
| grep -v "/vendor/" \
| xargs -n1 go generate -tags='${BUILDTAGS}'

# bootstrap installs the necessary go tools for development/build.
bootstrap:
Expand Down
1 change: 1 addition & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gox \
-osarch="${XC_EXCLUDE}" \
-ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}" \
-output "pkg/{{.OS}}_{{.Arch}}/${NAME}" \
-tags="${BUILD_TAGS}"
.

# Move all the compiled things to the $GOPATH/bin
Expand Down

0 comments on commit 985eee7

Please sign in to comment.