-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
72 lines (52 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
65
66
67
68
69
70
71
72
.DEFAULT_GOAL := build
.PHONY: build go_build go_test_unit
# Project-specific variables
#
# Binary name
BINARY:=virgil
#
# General variables
#
# Packages covered with unit tests.
GO_UNIT_TESTED_PACKAGES=$(shell go list ./...)
ifneq ($(shell go env GOOS),darwin)
GO_BUILD_LDFLAGS+= -linkmode external -extldflags '-static'
endif
ifeq ($(shell go env GOOS),windows)
BINARY:=$(BINARY).exe
endif
ifeq ($(shell go env GOARCH), 386)
VIRGIL_PACKAGE_ARCH=i386
endif
ifeq ($(shell go env GOARCH), amd64)
VIRGIL_PACKAGE_ARCH=x86_64
endif
VERSION=$(shell cat VERSION)
OS=$(shell go env GOOS)
# Go build flags.
GO_BUILD_FLAGS=-v --ldflags "$(GO_BUILD_LDFLAGS)" -a -installsuffix cgo
#
# Build targets
#
build: go_get go_build
tests: go_test_functional
go_build:
@echo ">>> Building go binary."
go build $(GO_BUILD_FLAGS) -o $(BINARY)
go_get:
@echo ">>> Getting dependencies."
go get ./...
go_test_unit:
@echo ">>> Running unit tests."
@go test -cover $(GO_UNIT_TESTED_PACKAGES)
go_test_functional:
@echo ">>> Running functional tests."
@go test -v -tags="functional" ./test/functional
pack_artifacts:
@echo ">>> Archiving artifact"
mkdir -p artifacts
if [ "$(OS)" = "windows" ]; then \
zip artifacts/Virgil_$(VERSION)_$(OS)_$(VIRGIL_PACKAGE_ARCH).zip $(BINARY); \
else \
tar cvzf artifacts/Virgil_$(VERSION)_$(OS)_$(VIRGIL_PACKAGE_ARCH).tar.gz $(BINARY); \
fi