Updated Makefile

This commit is contained in:
2023-05-01 18:28:51 -05:00
parent 38234d8d00
commit a1de6a5f75
4 changed files with 74 additions and 19 deletions

View File

@@ -1,20 +1,50 @@
BINARY_NAME=tps
all: build test
build:
mkdir -p dist
GOOS=darwin GOARCH=arm64 go build -o dist/${BINARY_NAME}.darwin_arm64 main.go
GOOS=linux GOARCH=amd64 go build -o dist/${BINARY_NAME}.linux_amd64 main.go
GOOS=windows GOARCH=amd64 go build -o dist/${BINARY_NAME}.windows_amd64.exe main.go
test:
/usr/local/go/bin/go test -timeout 30s -run ^Test mortons.site/tps/internal/properties
run:
go build -o ${BINARY_NAME} main.go
./${BINARY_NAME}
XC_OS="linux darwin windows"
XC_ARCH="amd64 arm64"
XC_PARALLEL="2"
BIN="bin"
SRC=$(shell find . -path './vendor' -prune -o -name '*.go' -print)
ifeq (, $(shell which golangci-lint))
$(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh")
endif
ifeq (, $(shell which richgo))
$(warning "could not find richgo in $(PATH), run: go get github.com/kyoh86/richgo")
endif
ifeq (, $(shell which gox))
$(warning "could not find gox in $(PATH), run: go get github.com/mitchellh/gox")
endif
.PHONY: all build fmt lint test install_deps clean
default: all
all: fmt test build
build: install_deps
gox \
-os=$(XC_OS) \
-arch=$(XC_ARCH) \
-parallel=$(XC_PARALLEL) \
-output=$(BIN)/{{.Dir}}_{{.OS}}_{{.Arch}} \
;
fmt:
$(info ******************** checking formatting ********************)
@test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1)
lint:
$(info ******************** running lint tools ********************)
golangci-lint run -v
test: install_deps
$(info ******************** running tests ********************)
richgo test -v ./...
install_deps:
$(info ******************** downloading dependencies ********************)
go get -v ./...
clean:
go clean
rm -rf dist
rm -rf $(BIN)