Makefile 3.14 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
# 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
18
	rm -rf dfssd/cmd
Loïck Bonniot's avatar
Loïck Bonniot committed
19
	rm -rf dfssd/gui
20
	rm dfssd/main.go
Loïck Bonniot's avatar
Loïck Bonniot committed
21 22 23
	go install ./...
	git reset --hard

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

25 26 27
# 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
28 29
	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"
30 31 32 33 34
	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
35 36 37
	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 \
38 39
		go build -ldflags "-r ." -o ../bin/gui

40 41 42 43 44 45
# 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
46

47 48 49 50 51
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 && \
Loïck Bonniot's avatar
Loïck Bonniot committed
52 53
	protoc --go_out=plugins=grpc:. dfss/dfsst/api/resolution.proto && \
	protoc --go_out=plugins=grpc:. dfss/net/fixtures/test.proto
54 55

# Release internals
56 57 58 59
# 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
60
	go get github.com/mitchellh/gox
61
	gox -ldflags "-s -w" -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
62 63 64 65 66 67

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
68 69
	cd gui && go build -ldflags "-s -w -r ." -o ../release/dfss_${VERSION}_linux_amd64/dfssc_gui
	cd dfssd && go build -ldflags "-s -w -r ." -o ../release/dfss_${VERSION}_linux_amd64/dfssd
70
	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
71 72 73 74 75 76 77 78 79

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)/
Caro Axel's avatar
Caro Axel committed
80

81 82
clean:
	rm -rf release
83 84

nocache: