Makefile 3.03 KB
Newer Older
Loïck Bonniot's avatar
Loïck Bonniot committed
1
2
3
4
5
6
7
8
REVISION := $(shell git rev-parse HEAD || echo )
VERSION := $(shell git tag --points-at HEAD | grep -m1 v[0-9] | sed -e 's/^v//g' )
ifeq ($(VERSION),)
	VERSION := master
endif

.PHONY:

9
10
11
12
13
install: nocache
	go install ./dfssc
	go install ./dfssp
	go install ./dfsst

Loïck Bonniot's avatar
Loïck Bonniot committed
14
15
16
17
18
19
20
21
22
# install_all installs everything, including libraries. It's mandatory for linter, but should be improved in the future.
install_all: install
	git stash
	rm -rf gui
	rm -rf dfssd/gui
	rm -f dfssd/main.go
	go install ./...
	git reset --hard

Loïck Bonniot's avatar
Loïck Bonniot committed
23

24
25
26
# prepare_gui builds a new container from the goqt image, adding DFSS dependencies for faster builds.
# call it once or after dependency addition.
prepare_gui: nocache
Loïck Bonniot's avatar
Loïck Bonniot committed
27
28
	docker run --name dfss-builder -v ${PWD}:/go/src/dfss -w /go/src/dfss lesterpig/goqt /bin/bash -c \
		"cp -r ../github.com/visualfc/goqt/bin . ; ./build/deps.sh"
29
30
31
32
33
	docker commit dfss-builder dfss:builder
	docker rm dfss-builder

# gui builds the gui component of the dfss project into a docker container, outputing the result in bin/ directory.
gui: nocache
Loïck Bonniot's avatar
Loïck Bonniot committed
34
35
36
	docker run --rm -v ${PWD}:/go/src/dfss -w /go/src/dfss/gui dfss:builder \
		../bin/goqt_rcc -go main -o application.qrc.go application.qrc
	docker run --rm -v ${PWD}:/go/src/dfss -w /go/src/dfss/gui dfss:builder \
37
38
		go build -ldflags "-r ." -o ../bin/gui

39
40
41
42
43
44
# dfssd builds the demonstrator into a docker container, outputing the result in bin/ directory
dfssd: nocache
	docker run --rm -v ${PWD}:/go/src/dfss -w /go/src/dfss/dfssd/gui dfss:builder \
		../../bin/goqt_rcc -go gui -o application.qrc.go application.qrc
	docker run --rm -v ${PWD}:/go/src/dfss -w /go/src/dfss/dfssd dfss:builder \
		go build -ldflags "-r ." -o ../bin/dfssd
45

46
47
48
49
50
51
52
53
protobuf:
	cd .. && \
	protoc --go_out=plugins=grpc:. dfss/dfssc/api/client.proto && \
	protoc --go_out=plugins=grpc:. dfss/dfssd/api/demonstrator.proto && \
	protoc --go_out=plugins=grpc:. dfss/dfssp/api/platform.proto && \
	protoc --go_out=plugins=grpc:. dfss/dfsst/api/resolution.proto

# Release internals
54
55
56
57
# Do not run these commands on your personal computer
release: clean build_x build_g package

build_x:
Loïck Bonniot's avatar
Loïck Bonniot committed
58
	go get github.com/mitchellh/gox
59
60
61
62
63
64
65
66
	gox -osarch "linux/amd64 linux/386 linux/arm windows/386 darwin/amd64" -parallel 1 -output "release/dfss_${VERSION}_{{.OS}}_{{.Arch}}/{{.Dir}}" dfss/dfssc dfss/dfssp dfss/dfsst

build_g:
	cp $(GOPATH)/src/github.com/visualfc/goqt/bin/goqt_rcc /bin/
	cp $(GOPATH)/src/github.com/visualfc/goqt/bin/lib* /lib/
	cd gui && goqt_rcc -go main -o a.qrc.go application.qrc
	cd dfssd/gui && goqt_rcc -go gui -o a.qrc.go application.qrc
	cd gui && go build -ldflags "-r ." -o ../release/dfss_${VERSION}_linux_amd64/dfssc_gui
67
	cd dfssd && go build -ldflags "-r ." -o ../release/dfss_${VERSION}_linux_amd64/dfssd
68
	cp /lib/libqtdrv.ui.so.1.0.0 release/dfss_${VERSION}_linux_amd64/libqtdrv.ui.so.1
Loïck Bonniot's avatar
Loïck Bonniot committed
69
70
71
72
73
74
75
76
77

package:
	echo "$(VERSION) $(REVISION)" > build/embed/VERSION
	cd release && ls -1 . | xargs -n1 -I {} cp ../build/embed/* {}/
	cd release && ls -1 . | xargs -n1 -I {} tar zcvf {}.tar.gz {}

deploy:
	mkdir -p /deploy/$(VERSION)
	cp release/*.tar.gz /deploy/$(VERSION)/
Axel's avatar
Axel committed
78

79
80
clean:
	rm -rf release
81
82

nocache: