~jonas-drange/ubuntu-push/lp1577723-skiptest

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
GOPATH := $(shell cd ../../..; pwd)
export GOPATH

PROJECT = launchpad.net/ubuntu-push

ifneq ($(CURDIR),$(GOPATH)/src/launchpad.net/ubuntu-push)
$(error unexpected curdir and/or layout)
endif

GODEPS = launchpad.net/gocheck
GODEPS += launchpad.net/go-dbus/v1
GODEPS += launchpad.net/go-xdg/v0
GODEPS += code.google.com/p/gosqlite/sqlite3
GODEPS += code.google.com/p/go-uuid/uuid

# cgocheck=0 is a workaround for lp:1555198
GOTEST := GODEBUG=cgocheck=0 ./scripts/goctest

TOTEST = $(shell env GOPATH=$(GOPATH) go list $(PROJECT)/...|grep -v acceptance|grep -v http13client )
TOBUILD = $(shell grep -lr '^package main')

all: fetchdeps bootstrap build-client build-server-dev

fetchdeps: .has-fetched-deps

.has-fetched-deps: PACKAGE_DEPS
	@$(MAKE) --no-print-directory refetchdeps
	@touch $@

refetchdeps:
	sudo apt-get install $$( grep -v '^#' PACKAGE_DEPS )

bootstrap: dependencies.tsv
	$(RM) -r $(GOPATH)/pkg
	mkdir -p $(GOPATH)/bin
	mkdir -p $(GOPATH)/pkg
	go get -u launchpad.net/godeps
	go get -d -u $(GODEPS)
	$(GOPATH)/bin/godeps -u dependencies.tsv
	go install $(GODEPS)

dependencies.tsv:
	$(GOPATH)/bin/godeps -t $(TOTEST) $(foreach i,$(TOBUILD),$(dir $(PROJECT)/$(i))) 2>/dev/null | cat > $@

check:
	$(GOTEST) $(TESTFLAGS) $(TOTEST)

check-race:
	$(GOTEST) $(TESTFLAGS) -race $(TOTEST)

acceptance:
	cd server/acceptance; ./acceptance.sh

build-client: ubuntu-push-client signing-helper/signing-helper

%.deps: %
	$(SH) scripts/deps.sh $<

%: %.go
	go build -o $@ $<

include $(TOBUILD:.go=.go.deps)

signing-helper/Makefile: signing-helper/CMakeLists.txt signing-helper/signing-helper.cpp signing-helper/signing.h
	cd signing-helper && (make clean || true) && cmake .

signing-helper/signing-helper: signing-helper/Makefile signing-helper/signing-helper.cpp signing-helper/signing.h
	cd signing-helper && make

build-server-dev: push-server-dev

run-server-dev: push-server-dev
	./$< sampleconfigs/dev.json

push-server-dev: server/dev/server
	mv $< $@

# very basic cleanup stuff; needs more work
clean:
	$(RM) -r coverhtml
	$(MAKE) -C signing-helper clean || true
	$(RM) push-server-dev
	$(RM) $(TOBUILD:.go=)

distclean:
	bzr clean-tree --verbose --ignored --force

coverage-summary:
	$(GOTEST) $(TESTFLAGS) -a -cover $(TOTEST)

coverage-html:
	mkdir -p coverhtml
	for pkg in $(TOTEST); do \
		relname="$${pkg#$(PROJECT)/}" ; \
		mkdir -p coverhtml/$$(dirname $${relname}) ; \
		$(GOTEST) $(TESTFLAGS) -a -coverprofile=coverhtml/$${relname}.out $$pkg ; \
		if [ -f coverhtml/$${relname}.out ] ; then \
	           go tool cover -html=coverhtml/$${relname}.out -o coverhtml/$${relname}.html ; \
	           go tool cover -func=coverhtml/$${relname}.out -o coverhtml/$${relname}.txt ; \
		fi \
	done

format:
	go fmt $(PROJECT)/...

check-format:
	scripts/check_fmt $(PROJECT)

protocol-diagrams: protocol/state-diag-client.svg protocol/state-diag-session.svg
%.svg: %.gv
	# requires graphviz installed
	dot -Tsvg $< > $@

.PHONY: bootstrap check check-race format check-format \
	acceptance build-client build-server-dev run-server-dev \
	coverage-summary coverage-html protocol-diagrams \
	fetchdeps refetchdeps clean distclean all

.INTERMEDIATE: server/dev/server