Skip to content

Instantly share code, notes, and snippets.

@pkieltyka
Created September 24, 2015 15:14
Show Gist options
  • Save pkieltyka/f5c493fb2f63ef7bc76b to your computer and use it in GitHub Desktop.
Save pkieltyka/f5c493fb2f63ef7bc76b to your computer and use it in GitHub Desktop.
.PHONY: help run test build dist clean tools dist-tools deps update-deps vendor
all:
@echo "make <cmd>"
@echo ""
@echo "commands:"
@echo " run - run in dev mode"
@echo " test - run go tests"
@echo " build - build binaries into bin/ directory"
@echo " clean - clean up bin/ directory"
@echo ""
@echo " dist - clean build with deps and tools"
@echo " tools - go get's a bunch of tools for dev"
@echo " deps - pull and setup dependencies"
@echo " update-deps - update deps lock file from ./..."
@echo " vendor - rebuild vendor/ directory from deps"
print-%: ; @echo $*=$($*)
##
## Tools
##
tools: dist-tools
go get github.com/pkieltyka/fresh
dist-tools:
@mkdir -p ./bin
go get github.com/pressly/glock
go get github.com/pressly/gv
##
## Development
##
run:
@(export cd ./cmd/myproject && fresh -w=../..)
test:
@GOGC=off go test $$(GO15VENDOREXPERIMENT=1 go list ./... | grep -v '/vendor/')
dist-test:
@GO15VENDOREXPERIMENT=1 $(MAKE) test
##
## Building
##
dist: clean
GO15VENDOREXPERIMENT=1 $(MAKE) build
build:
@mkdir -p ./bin
GOGC=off go build -i -ldflags "$(LDFLAGS)" -o ./bin/myproject ./cmd/myproject
clean:
@rm -rf $$GOPATH/pkg/*/github.com/pressly/myproject{,.*}
@rm -rf ./bin
##
## Dependency mgmt
##
deps:
@glock sync github.com/pressly/myproject
update-deps:
@echo "Updating Glockfile with package versions from GOPATH..."
@rm -rf ./vendor
@glock save github.com/pressly/myproject
@$(MAKE) vendor
vendor:
@echo "Syncing dependencies into vendor directory..."
@rm -rf ./vendor
@gv < Glockfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment