mirror of
https://github.com/jimeh/rbheap.git
synced 2026-02-19 12:56:46 +00:00
Revamp Makefile
This commit is contained in:
53
Makefile
53
Makefile
@@ -1,8 +1,18 @@
|
|||||||
|
DEV_DEPS = github.com/mailru/easyjson/...
|
||||||
|
|
||||||
NAME = rbheapleak
|
NAME = rbheapleak
|
||||||
BINARY = bin/${NAME}
|
BINARY = bin/${NAME}
|
||||||
VERSION ?= $(shell cat VERSION)
|
VERSION ?= $(shell cat VERSION)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Main targets.
|
||||||
|
#
|
||||||
|
|
||||||
SOURCES = $(shell find . -name '*.go' -o -name 'Makefile' -o -name 'VERSION')
|
SOURCES = $(shell find . -name '*.go' -o -name 'Makefile' -o -name 'VERSION')
|
||||||
|
|
||||||
|
all: bootstrap generate build
|
||||||
|
bootstrap: dev-deps dep-ensure
|
||||||
|
|
||||||
$(BINARY): $(SOURCES)
|
$(BINARY): $(SOURCES)
|
||||||
CGO_ENABLED=0 go build -a -o ${BINARY} -ldflags \ "\
|
CGO_ENABLED=0 go build -a -o ${BINARY} -ldflags \ "\
|
||||||
-s -w \
|
-s -w \
|
||||||
@@ -13,16 +23,45 @@ $(BINARY): $(SOURCES)
|
|||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: $(BINARY)
|
build: $(BINARY)
|
||||||
|
|
||||||
.PHONY: run
|
|
||||||
run: $(BINARY)
|
|
||||||
$(BINARY)
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(eval BIN_DIR := $(shell dirname ${BINARY}))
|
$(eval BIN_DIR := $(shell dirname ${BINARY}))
|
||||||
if [ -f ${BINARY} ]; then rm ${BINARY}; fi
|
if [ -f ${BINARY} ]; then rm ${BINARY}; fi
|
||||||
if [ -d ${BIN_DIR} ]; then rmdir ${BIN_DIR}; fi
|
if [ -d ${BIN_DIR} ]; then rmdir ${BIN_DIR}; fi
|
||||||
|
|
||||||
.PHONY: docker
|
.PHONY: test
|
||||||
docker:
|
test:
|
||||||
docker build -t "$(shell whoami)/$(NAME)" .
|
go test
|
||||||
|
|
||||||
|
.PHONY: generate
|
||||||
|
generate: dev-deps
|
||||||
|
go generate
|
||||||
|
|
||||||
|
#
|
||||||
|
# EasyJSON targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
EASYJSON_FILES = $(shell find . -name '*_easyjson.go' -not -path '*/vendor/*')
|
||||||
|
|
||||||
|
define easyjson_file
|
||||||
|
$(1): $(subst _easyjson.go,.go,$(1))
|
||||||
|
easyjson -all $$^
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach file,$(EASYJSON_FILES),$(eval $(call easyjson_file,$(file))))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Dependency targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
.PHONY: dep-ensure
|
||||||
|
dep-ensure:
|
||||||
|
dep ensure
|
||||||
|
|
||||||
|
.PHONY: dev-deps
|
||||||
|
dev-deps:
|
||||||
|
@$(foreach DEP,$(DEV_DEPS),go get $(DEP);)
|
||||||
|
|
||||||
|
.PHONY: update-dev-deps
|
||||||
|
update-dev-deps:
|
||||||
|
@$(foreach DEP,$(DEV_DEPS),go get -u $(DEP);)
|
||||||
|
|||||||
Reference in New Issue
Block a user