-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from poerhiza/makefile
chore(build): add basic makefile to make life simpler
- Loading branch information
Showing
4 changed files
with
79 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
dist/ | ||
*.swp | ||
.idea/ | ||
chisel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
VERSION=$(shell git describe --abbrev=0 --tags) | ||
BUILD=$(shell git rev-parse HEAD) | ||
DIRBASE=./build | ||
DIR=${DIRBASE}/${VERSION}/${BUILD}/bin | ||
|
||
LDFLAGS=-ldflags "-s -w ${XBUILD} -buildid=${BUILD} -X github.com/jpillora/chisel/share.BuildVersion=${VERSION}" | ||
|
||
GOFILES=`go list ./...` | ||
GOFILESNOTEST=`go list ./... | grep -v test` | ||
|
||
# Make Directory to store executables | ||
$(shell mkdir -p ${DIR}) | ||
|
||
all: | ||
@goreleaser build --skip-validate --single-target --config .github/goreleaser.yml | ||
|
||
freebsd: lint | ||
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -trimpath ${LDFLAGS} ${GCFLAGS} ${ASMFLAGS} -o ${DIR}/chisel-freebsd_amd64 . | ||
|
||
linux: lint | ||
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -trimpath ${LDFLAGS} ${GCFLAGS} ${ASMFLAGS} -o ${DIR}/chisel-linux_amd64 . | ||
|
||
windows: lint | ||
env CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -trimpath ${LDFLAGS} ${GCFLAGS} ${ASMFLAGS} -o ${DIR}/chisel-windows_amd64 . | ||
|
||
darwin: | ||
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -trimpath ${LDFLAGS} ${GCFLAGS} ${ASMFLAGS} -o ${DIR}/chisel-darwin_amd64 . | ||
|
||
docker: | ||
@docker build . | ||
|
||
dep: ## Get the dependencies | ||
@go get -u github.com/goreleaser/goreleaser | ||
@go get -u github.com/boumenot/gocover-cobertura | ||
@go get -v -d ./... | ||
@go get -u all | ||
@go mod tidy | ||
|
||
lint: ## Lint the files | ||
@go fmt ${GOFILES} | ||
@go vet ${GOFILESNOTEST} | ||
|
||
test: ## Run unit tests | ||
@go test -coverprofile=${DIR}/coverage.out -race -short ${GOFILESNOTEST} | ||
@go tool cover -html=${DIR}/coverage.out -o ${DIR}/coverage.html | ||
@gocover-cobertura < ${DIR}/coverage.out > ${DIR}/coverage.xml | ||
|
||
release: lint test | ||
goreleaser release --config .github/goreleaser.yml | ||
|
||
clean: | ||
rm -rf ${DIRBASE}/* | ||
|
||
.PHONY: all freebsd linux windows docker dep lint test release clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters