-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
69 lines (59 loc) · 2.02 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
65
66
67
68
69
########################################################################################################################
# Copyright (c) 2019 IoTeX
# This is an alpha (internal) release and is not suitable for production. This source code is provided 'as is' and no
# warranties are given as to title or non-infringement, merchantability or fitness for purpose and, to the extent
# permitted by law, all liability for your use of the code is disclaimed. This source code is governed by Apache
# License 2.0 that can be found in the LICENSE file.
########################################################################################################################
# Go parameters
GOCMD=go
GOLINT=golint
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
# Pkgs
ALL_PKGS := $(shell go list ./... )
PKGS := $(shell go list ./... | grep -v /vendor/ )
# Docker parameters
DOCKERCMD=docker
# Package Info
PACKAGE_VERSION := $(shell git describe --tags --always)
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/iotexproject/iotex-antenna/version
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
all: clean test
.PHONY: fmt
fmt:
$(GOCMD) fmt ./...
.PHONY: test
test: fmt lint
$(GOTEST) ./... -v -short -race
.PHONY: lint
lint:
@echo "Installing golint..."
go get golang.org/x/lint/golint
go list ./... | grep -v /vendor/ | xargs $(GOLINT)
.PHONY: clean
clean:
@echo "Cleaning..."
$(ECHO_V)$(GOCLEAN) -i $(PKGS)