-
Notifications
You must be signed in to change notification settings - Fork 7
/
makefile
64 lines (54 loc) · 1.37 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Go parameters
GOCMD=go
GOGET=$(GOCMD) get
GOBUILD=$(GOCMD) build
GOINSTALL=$(GOCMD) install
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOLINT=golint
BUILD_TARGET=lockfree
# Pkgs
ALL_PKGS := $(shell go list ./... )
PKGS := $(shell go list ./... | grep -v /test/ )
# Package Info
PACKAGE_VERSION := $(shell git describe --tags)
PACKAGE_COMMIT_ID := $(shell git rev-parse HEAD)
GIT_STATUS := $(shell git status --porcelain)
ifdef GIT_STATUS
GIT_STATUS := "dirty"
else
GIT_STATUS := "clean"
endif
GO_VERSION := $(shell go version)
BUILD_TIME=$(shell date +%F-%Z/%T)
VersionImportPath := github.com/dustinxie/lockfree
PackageFlags += -X '$(VersionImportPath).PackageVersion=$(PACKAGE_VERSION)'
PackageFlags += -X '$(VersionImportPath).PackageCommitID=$(PACKAGE_COMMIT_ID)'
PackageFlags += -X '$(VersionImportPath).GitStatus=$(GIT_STATUS)'
PackageFlags += -X '$(VersionImportPath).GoVersion=$(GO_VERSION)'
PackageFlags += -X '$(VersionImportPath).BuildTime=$(BUILD_TIME)'
PackageFlags += -s -w
V ?= 0
ifeq ($(V),0)
ECHO_V = @
else
VERBOSITY_FLAG = -v
DEBUG_FLAG = -debug
endif
default: clean build test
.PHONY: build
build:
$(GOBUILD) -ldflags "$(PackageFlags)" -v ./...
.PHONY: fmt
fmt:
$(GOCMD) fmt ./...
.PHONY: lint
lint:
go list ./... | xargs $(GOLINT)
.PHONY: test
test: fmt
$(GOTEST) -short -race ./...
.PHONY: clean
clean:
@echo "Cleaning..."
$(ECHO_V)rm -rf ./bin/$(BUILD_TARGET)