first commit
This commit is contained in:
65
Makefile
Normal file
65
Makefile
Normal file
@ -0,0 +1,65 @@
|
||||
VERSION := $(shell git describe --tags)
|
||||
BUILD := $(shell git rev-parse --short HEAD)
|
||||
PROJECTNAME := $(shell basename "$(PWD)")
|
||||
BINARY_NAME := "mysubarumq"
|
||||
|
||||
# Go related variables.
|
||||
GOOS := darwin
|
||||
GOBASE := $(shell pwd)
|
||||
GOBIN := $(GOBASE)/bin
|
||||
GOFILES := $(wildcard *.go)
|
||||
|
||||
# Redirect error output to a file, so we can show it in development mode.
|
||||
STDERR := /tmp/.$(PROJECTNAME)-stderr.txt
|
||||
|
||||
.PHONY: help
|
||||
|
||||
all: help
|
||||
|
||||
help:
|
||||
@echo ""
|
||||
@echo " Choose a command run in "$(PROJECTNAME)":"
|
||||
@echo ""
|
||||
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
|
||||
@echo ""
|
||||
|
||||
## archive: Archive binary to a .zip file
|
||||
archive:
|
||||
@echo " > Archiving a file..."
|
||||
@zip $(PROJECTNAME).zip $(PROJECTNAME)
|
||||
|
||||
## install: Install missing dependencies. Runs `go get` internally. e.g; make install get=github.com/foo/bar
|
||||
install: go-get
|
||||
|
||||
## compile: Compile the binary.
|
||||
compile:
|
||||
@-touch $(STDERR)
|
||||
@-rm $(STDERR)
|
||||
@-$(MAKE) -s go-compile 2> $(STDERR)
|
||||
@cat $(STDERR) | sed -e '1s/.*/\nError:\n/' | sed 's/make\[.*/ /' | sed "/^/s/^/ /" 1>&2
|
||||
|
||||
go-compile: go-get go-test go-build
|
||||
|
||||
go-build:
|
||||
@echo " > Building binary..."
|
||||
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) GOOS=$(GOOS) go build $(LDFLAGS) -mod=mod -o ${BINARY_NAME} $(GOFILES)
|
||||
GOARCH=amd64 GOOS=darwin go build -o ${BINARY_NAME}-darwin .
|
||||
GOARCH=amd64 GOOS=linux go build -o ${BINARY_NAME}-linux main.go
|
||||
GOARCH=amd64 GOOS=window go build -o ${BINARY_NAME}-windows main.go
|
||||
|
||||
go-get:
|
||||
@echo " > Checking if there is any missing dependencies..."
|
||||
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get -u $(get)
|
||||
|
||||
go-test:
|
||||
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test ./...
|
||||
|
||||
go-test_coverage:
|
||||
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test ./... -coverprofile=coverage.out
|
||||
|
||||
go-clean:
|
||||
@echo " > Cleaning build cache"
|
||||
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean
|
||||
rm ${BINARY_NAME}-darwin
|
||||
rm ${BINARY_NAME}-linux
|
||||
rm ${BINARY_NAME}-windows
|
Reference in New Issue
Block a user