-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (70 loc) · 1.72 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
85
86
87
88
89
90
91
92
#
# Variables
#
# Go Packages
PKGS = \
cmd/gpio \
cmd/sipo \
cmd/battcaverna
ARMPKGS = $(PKGS:%=arm-%)
BUILDPKGS = $(PKGS:%=build-%)
DEBUGPKGS = $(PKGS:%=debug-%)
# Programs
INSTALL ?= /usr/bin/install
# Misc
SHELL = /bin/bash
VERSION = $(shell git describe --long --dirty --always) ($(shell env TZ=UTC git log -1 --format="%cd" --date=iso-local))
INFO = @printf "\e[01;32m*** Make: $@\e[00m\n"
BUILD = go build -ldflags '-X "main.version=$(VERSION)"'
#
# Build
#
# default
all: $(BUILDPKGS)
$(BUILDPKGS):
$(INFO)
cd $(@:build-%=%) && $(BUILD)
.PHONY: all $(BUILDPKGS)
# ARM
arm: $(ARMPKGS)
$(ARMPKGS):
$(INFO)
cd $(@:arm-%=%) && GOARCH=arm GOARM=7 GOOS=linux $(BUILD)
.PHONY: arm $(ARMPKGS)
# debug
debug: $(DEBUGPKGS)
$(DEBUGPKGS):
$(INFO)
cd $(@:debug-%=%) && $(BUILD) -race
.PHONY: debug $(DEBUGPKGS)
# test
test:
go test -race ./... | grep --line-buffered -v 'no test files'
.PHONY: test
# cover
initcover:
@echo "mode: count" > cover.out
cover: initcover
go test -race -coverprofile=cover.out ./...
coveralls: cover
goveralls -coverprofile=cover.out -service=circle-ci -repotoken=$(COVERALLS_TOKEN)
.PHONY: initcover cover coveralls
#
# Help
#
help:
# Common targets:
# all - Build all executables for the current architecture
# debug - Like "all" but also enables Go's race detector
# arm - Build ARM executables#
# Test targets:
# test - Run tests
# cover - Run tests collecting coverage information
# coveralls - Sends coverage data to Coveralls
#
# Release targets:
# install - Build ARM executables and copies them in repositories used to produce microSD cards
# release - Commit binaries copied over by the "install" target
# release-amend - Amend release
#
.PHONY: help