-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
50 lines (38 loc) · 1.6 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
DISABLE_PORT_RANDOMIZATION ?=
SHELL := /bin/bash
PROTO_SOURCES = $(shell find . -name '*.proto')
GENERATED_PROTO_SOURCES = $(shell echo "$(PROTO_SOURCES)" | sed 's/\.proto/\.pb\.go/g')
SOURCES = $(GENERATED_PROTO_SOURCES) $(shell find . -name '*[^_test].go')
REVISION_DATE := $(shell git log -1 --pretty=format:%ad --date=format:%Y%m%d.%H%M%S)
BUILD_DATE := $(shell date -u +%Y%m%d.%H%M%S)
VERSION ?= $$VERSION
LDFLAGS := -s -w -X github.com/getlantern/flashlight/common.RevisionDate=$(REVISION_DATE) -X github.com/getlantern/flashlight/common.BuildDate=$(BUILD_DATE) -X github.com/getlantern/flashlight/common.CompileTimePackageVersion=$(VERSION)
%.pb.go: %.proto
protoc --go_out=. --go_opt=paths=source_relative $<
test-and-cover: $(SOURCES)
@echo "mode: count" > profile.cov && \
TP=$$(go list ./...) && \
CP=$$(echo $$TP | tr ' ', ',') && \
set -x && \
for pkg in $$TP; do \
go test -race -v -tags="headless" -covermode=atomic -coverprofile=profile_tmp.cov -coverpkg "$$CP" $$pkg || exit 1; \
tail -n +2 profile_tmp.cov >> profile.cov; \
done
test:
go test -failfast -race -v -tags="headless" ./...
define prep-for-mobile
go env -w 'GOPRIVATE=github.com/getlantern/*'
go install golang.org/x/mobile/cmd/gomobile
gomobile init
endef
%.pb.go: %.proto
go build -o build/protoc-gen-go google.golang.org/protobuf/cmd/protoc-gen-go
protoc --go_out=. --plugin=build/protoc-gen-go --go_opt=paths=source_relative $<
clean:
rm -rf .gomobilecache
.PHONY: install-githooks
install-githooks:
cp githooks/* .git/hooks/
.PHONY: build-genconfig
build-genconfig:
go build -o ./genconfig/genconfig ./genconfig/genconfig.go