2016-11-05 16:43:00 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
BUILD := gomtree
|
2017-01-20 15:28:19 +00:00
|
|
|
BUILDPATH := github.com/vbatts/go-mtree/cmd/gomtree
|
2016-11-07 14:53:24 +00:00
|
|
|
CWD := $(shell pwd)
|
2016-11-05 16:43:00 +00:00
|
|
|
SOURCE_FILES := $(shell find . -type f -name "*.go")
|
2016-08-25 18:17:08 +00:00
|
|
|
CLEAN_FILES := *~
|
2017-02-15 16:10:30 +00:00
|
|
|
TAGS :=
|
2023-10-22 21:43:33 +00:00
|
|
|
ARCHES := linux,386 linux,amd64 linux,arm linux,arm64 linux,mips64 linux,riscv64 openbsd,amd64 windows,amd64 windows,arm64 darwin,amd64 darwin,arm64
|
2020-04-02 15:49:21 +00:00
|
|
|
GO_VER := go1.14
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2017-02-15 16:10:30 +00:00
|
|
|
default: build validation
|
2016-11-05 16:43:00 +00:00
|
|
|
|
|
|
|
.PHONY: validation
|
2023-10-24 01:45:19 +00:00
|
|
|
validation: .test .vet .cli.test
|
2016-12-08 01:03:41 +00:00
|
|
|
|
|
|
|
.PHONY: validation.tags
|
2022-04-09 02:55:48 +00:00
|
|
|
validation.tags: .test.tags .vet.tags .cli.test .staticcheck
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2022-04-09 02:08:50 +00:00
|
|
|
.PHONY: gocyclo
|
|
|
|
gocyclo: .gocyclo
|
|
|
|
|
|
|
|
CLEAN_FILES += .gocyclo
|
|
|
|
|
|
|
|
.gocyclo:
|
|
|
|
gocyclo -avg -over 15 -ignore 'vendor/*' . && touch $@
|
|
|
|
|
2022-04-09 02:55:48 +00:00
|
|
|
.PHONY: staticcheck
|
|
|
|
staticcheck: .staticcheck
|
|
|
|
|
|
|
|
CLEAN_FILES += .staticcheck
|
|
|
|
|
|
|
|
.staticcheck:
|
|
|
|
staticcheck . && touch $@
|
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.PHONY: test
|
2016-12-08 01:03:41 +00:00
|
|
|
test: .test
|
2016-08-25 18:17:08 +00:00
|
|
|
|
|
|
|
CLEAN_FILES += .test .test.tags
|
2019-01-21 17:06:24 +00:00
|
|
|
NO_VENDOR_DIR := $(shell find . -type f -name '*.go' ! -path './vendor*' ! -path './.git*' ! -path './.vscode*' -exec dirname "{}" \; | sort -u)
|
2016-11-05 16:43:00 +00:00
|
|
|
|
|
|
|
.test: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
go test -v $(NO_VENDOR_DIR) && touch $@
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-08-25 18:17:08 +00:00
|
|
|
.test.tags: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
set -e ; for tag in $(TAGS) ; do go test -tags $$tag -v $(NO_VENDOR_DIR) ; done && touch $@
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.PHONY: lint
|
2016-12-08 01:03:41 +00:00
|
|
|
lint: .lint
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-12-08 01:03:41 +00:00
|
|
|
CLEAN_FILES += .lint
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.lint: $(SOURCE_FILES)
|
2023-10-24 01:45:19 +00:00
|
|
|
set -e ; golangci-lint run && touch $@
|
2016-11-05 16:43:00 +00:00
|
|
|
|
|
|
|
.PHONY: vet
|
2016-12-07 21:26:04 +00:00
|
|
|
vet: .vet .vet.tags
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-12-07 21:26:04 +00:00
|
|
|
CLEAN_FILES += .vet .vet.tags
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.vet: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
go vet $(NO_VENDOR_DIR) && touch $@
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-12-07 21:26:04 +00:00
|
|
|
.vet.tags: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
set -e ; for tag in $(TAGS) ; do go vet -tags $$tag -v $(NO_VENDOR_DIR) ; done && touch $@
|
2016-12-07 21:26:04 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
.PHONY: cli.test
|
|
|
|
cli.test: .cli.test
|
|
|
|
|
2016-12-08 01:03:41 +00:00
|
|
|
CLEAN_FILES += .cli.test .cli.test.tags
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
.cli.test: $(BUILD) $(wildcard ./test/cli/*.sh)
|
2022-04-04 03:15:40 +00:00
|
|
|
@go run ./test/cli-test/main.go ./test/cli/*.sh && touch $@
|
2016-11-07 14:53:24 +00:00
|
|
|
|
2016-12-08 01:03:41 +00:00
|
|
|
.cli.test.tags: $(BUILD) $(wildcard ./test/cli/*.sh)
|
2022-04-04 03:15:40 +00:00
|
|
|
@set -e ; for tag in $(TAGS) ; do go run -tags $$tag ./test/cli-test/main.go ./test/cli/*.sh ; done && touch $@
|
2016-12-08 01:03:41 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.PHONY: build
|
2016-11-07 14:53:24 +00:00
|
|
|
build: $(BUILD)
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
$(BUILD): $(SOURCE_FILES)
|
2023-03-22 15:14:24 +00:00
|
|
|
go build -ldflags="-X 'main.Version=$(shell git describe --always --dirty)'" -mod=vendor -o $(BUILD) $(BUILDPATH)
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2018-08-14 03:03:28 +00:00
|
|
|
install.tools:
|
2023-10-24 01:45:19 +00:00
|
|
|
@go install github.com/fatih/color@latest ; \
|
|
|
|
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest ; \
|
|
|
|
go install honnef.co/go/tools/cmd/staticcheck@latest ; \
|
|
|
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
2018-08-14 03:03:28 +00:00
|
|
|
|
2016-12-08 01:39:47 +00:00
|
|
|
./bin:
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
CLEAN_FILES += bin
|
|
|
|
|
|
|
|
build.arches: ./bin
|
|
|
|
@set -e ;\
|
|
|
|
for pair in $(ARCHES); do \
|
|
|
|
p=$$(echo $$pair | cut -d , -f 1);\
|
|
|
|
a=$$(echo $$pair | cut -d , -f 2);\
|
|
|
|
echo "Building $$p/$$a ...";\
|
2021-09-14 14:41:10 +00:00
|
|
|
GOOS=$$p GOARCH=$$a go build -mod=vendor -o ./bin/gomtree.$$p.$$a $(BUILDPATH) ;\
|
2022-04-23 16:38:03 +00:00
|
|
|
done ;\
|
|
|
|
cd bin ;\
|
|
|
|
sha1sum gomtree.* > SUMS ;\
|
|
|
|
sha512sum gomtree.* >> SUMS ;\
|
|
|
|
cd -
|
2016-12-08 01:39:47 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
clean:
|
2016-08-25 18:17:08 +00:00
|
|
|
rm -rf $(BUILD) $(CLEAN_FILES)
|
2016-11-05 16:43:00 +00:00
|
|
|
|