-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
84 lines (71 loc) · 2.53 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
########################################################################################################################
# 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 -set_exit_status
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
BUILD_TARGET_SERVER=antenna-go
# Pkgs
ALL_PKGS := $(shell go list ./... )
PKGS := $(shell go list ./... | grep -v /vendor/ )
ROOT_PKG := "github.com/iotexproject/iotex-antenna-go"
# 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: test build clean
.PHONY: build
build:
$(GOBUILD) -ldflags "$(PackageFlags)" -v ./...
.PHONY: fmt
fmt:
$(GOCMD) fmt ./...
.PHONY: test
test: lint fmt
$(GOTEST) ./... -v -short -race
.PHONY: lint
lint:
go list ./... | grep -v /vendor/ | xargs $(GOLINT)
.PHONY: mockgen
mockgen:
mockgen -destination=./iotex/interfaces_mock.go -source=./iotex/interfaces.go -package=iotex
.PHONY: examples
examples:
$(GOBUILD) -o ./examples/chaininfo/chaininfo ./examples/chaininfo
$(GOBUILD) -o ./examples/openoracle/openoracle ./examples/openoracle
$(GOBUILD) -o ./examples/xrc20tokens/xrc20tokens ./examples/xrc20tokens
.PHONY: clean
clean:
@echo "Cleaning..."
$(ECHO_V)rm -rf ./$(BUILD_TARGET_SERVER)
$(ECHO_V)$(GOCLEAN) -i $(PKGS)