refactor: update makefile command.
This commit is contained in:
parent
df45f85a1c
commit
6540d16e3e
56
Makefile
56
Makefile
|
@ -5,9 +5,6 @@ GO ?= go
|
||||||
DEPLOY_ACCOUNT := appleboy
|
DEPLOY_ACCOUNT := appleboy
|
||||||
DEPLOY_IMAGE := $(EXECUTABLE)
|
DEPLOY_IMAGE := $(EXECUTABLE)
|
||||||
GOFMT ?= gofmt "-s"
|
GOFMT ?= gofmt "-s"
|
||||||
EXTERNAL_TOOLS=\
|
|
||||||
github.com/mitchellh/gox \
|
|
||||||
github.com/kardianos/govendor
|
|
||||||
|
|
||||||
TARGETS ?= linux darwin windows
|
TARGETS ?= linux darwin windows
|
||||||
ARCHS ?= amd64 386
|
ARCHS ?= amd64 386
|
||||||
|
@ -18,6 +15,9 @@ TAGS ?=
|
||||||
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
||||||
TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'tempdir')
|
TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'tempdir')
|
||||||
NODE_PROTOC_PLUGIN := $(shell which grpc_tools_node_protoc_plugin)
|
NODE_PROTOC_PLUGIN := $(shell which grpc_tools_node_protoc_plugin)
|
||||||
|
GOVENDOR := $(GOPATH)/bin/govendor
|
||||||
|
GOX := $(GOPATH)/bin/gox
|
||||||
|
MISSPELL := $(GOPATH)/bin/misspell
|
||||||
|
|
||||||
ifneq ($(shell uname), Darwin)
|
ifneq ($(shell uname), Darwin)
|
||||||
EXTLDFLAGS = -extldflags "-static" $(null)
|
EXTLDFLAGS = -extldflags "-static" $(null)
|
||||||
|
@ -45,12 +45,14 @@ ifeq ($(ANDROID_TEST_TOKEN),)
|
||||||
endif
|
endif
|
||||||
@echo "Already set ANDROID_API_KEY and ANDROID_TEST_TOKEN globale variable."
|
@echo "Already set ANDROID_API_KEY and ANDROID_TEST_TOKEN globale variable."
|
||||||
|
|
||||||
# bootstrap the build by downloading additional tools
|
$(GOVENDOR):
|
||||||
bootstrap:
|
$(GO) get -u github.com/kardianos/govendor
|
||||||
@for tool in $(EXTERNAL_TOOLS) ; do \
|
|
||||||
echo "Installing/Updating $$tool" ; \
|
$(GOX):
|
||||||
go get -u $$tool; \
|
$(GO) get -u github.com/mitchellh/gox
|
||||||
done
|
|
||||||
|
$(MISSPELL):
|
||||||
|
$(GO) get -u github.com/client9/misspell/cmd/misspell
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
$(GOFMT) -w $(GOFILES)
|
$(GOFMT) -w $(GOFILES)
|
||||||
|
@ -91,13 +93,11 @@ unconvert:
|
||||||
fi
|
fi
|
||||||
for PKG in $(PACKAGES); do unconvert -v $$PKG || exit 1; done;
|
for PKG in $(PACKAGES); do unconvert -v $$PKG || exit 1; done;
|
||||||
|
|
||||||
# Install from source.
|
.PHONY: install
|
||||||
install: $(SOURCES)
|
install: $(SOURCES)
|
||||||
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
||||||
@echo "==> Installed gorush ${GOPATH}/bin/gorush"
|
@echo "==> Installed gorush ${GOPATH}/bin/gorush"
|
||||||
.PHONY: install
|
|
||||||
|
|
||||||
# build from source
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: $(EXECUTABLE)
|
build: $(EXECUTABLE)
|
||||||
|
|
||||||
|
@ -105,34 +105,25 @@ $(EXECUTABLE): $(SOURCES)
|
||||||
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/$@
|
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/$@
|
||||||
|
|
||||||
.PHONY: misspell-check
|
.PHONY: misspell-check
|
||||||
misspell-check:
|
misspell-check: $(MISSPELL)
|
||||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
$(MISSPELL) -error $(GOFILES)
|
||||||
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
|
||||||
fi
|
|
||||||
misspell -error $(GOFILES)
|
|
||||||
|
|
||||||
.PHONY: misspell
|
.PHONY: misspell
|
||||||
misspell:
|
misspell: $(MISSPELL)
|
||||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
$(MISSPELL) -w $(GOFILES)
|
||||||
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
|
||||||
fi
|
|
||||||
misspell -w $(GOFILES)
|
|
||||||
|
|
||||||
test: fmt-check
|
test: fmt-check
|
||||||
for PKG in $(PACKAGES); do $(GO) test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
|
for PKG in $(PACKAGES); do $(GO) test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
|
||||||
|
|
||||||
.PHONY: test-vendor
|
.PHONY: test-vendor
|
||||||
test-vendor:
|
test-vendor: $(GOVENDOR)
|
||||||
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
$(GOVENDOR) list +unused | tee "$(TMPDIR)/wc-gitea-unused"
|
||||||
$(GO) get -u github.com/kardianos/govendor; \
|
|
||||||
fi
|
|
||||||
govendor list +unused | tee "$(TMPDIR)/wc-gitea-unused"
|
|
||||||
[ $$(cat "$(TMPDIR)/wc-gitea-unused" | wc -l) -eq 0 ] || echo "Warning: /!\\ Some vendor are not used /!\\"
|
[ $$(cat "$(TMPDIR)/wc-gitea-unused" | wc -l) -eq 0 ] || echo "Warning: /!\\ Some vendor are not used /!\\"
|
||||||
|
|
||||||
govendor list +outside | tee "$(TMPDIR)/wc-gitea-outside"
|
$(GOVENDOR) list +outside | tee "$(TMPDIR)/wc-gitea-outside"
|
||||||
[ $$(cat "$(TMPDIR)/wc-gitea-outside" | wc -l) -eq 0 ] || exit 1
|
[ $$(cat "$(TMPDIR)/wc-gitea-outside" | wc -l) -eq 0 ] || exit 1
|
||||||
|
|
||||||
govendor status || exit 1
|
$(GOVENDOR) status || exit 1
|
||||||
|
|
||||||
redis_test: init
|
redis_test: init
|
||||||
$(GO) test -v -cover ./storage/redis/...
|
$(GO) test -v -cover ./storage/redis/...
|
||||||
|
@ -160,11 +151,8 @@ release: release-dirs release-build release-copy release-check
|
||||||
release-dirs:
|
release-dirs:
|
||||||
mkdir -p $(DIST)/binaries $(DIST)/release
|
mkdir -p $(DIST)/binaries $(DIST)/release
|
||||||
|
|
||||||
release-build:
|
release-build: $(GOX)
|
||||||
@hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
$(GOX) -os="$(TARGETS)" -arch="$(ARCHS)" -tags="$(TAGS)" -ldflags="$(EXTLDFLAGS)-s -w $(LDFLAGS)" -output="$(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
||||||
$(GO) get -u github.com/mitchellh/gox; \
|
|
||||||
fi
|
|
||||||
gox -os="$(TARGETS)" -arch="$(ARCHS)" -tags="$(TAGS)" -ldflags="$(EXTLDFLAGS)-s -w $(LDFLAGS)" -output="$(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
|
||||||
|
|
||||||
release-copy:
|
release-copy:
|
||||||
$(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
|
$(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
|
||||||
|
|
Loading…
Reference in New Issue