1 # Makefile used to build XDS daemon Web Server
3 # Retrieve git tag/commit to set sub-version string
4 ifeq ($(origin VERSION), undefined)
5 VERSION := $(shell git describe --tags --always | sed 's/^v//')
12 HOST_GOOS=$(shell go env GOOS)
13 HOST_GOARCH=$(shell go env GOARCH)
14 REPOPATH=github.com/iotbzh/xds-server
16 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
17 ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
18 ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
20 export GOPATH := $(shell go env GOPATH):$(ROOT_GOPRJ)
21 export PATH := $(PATH):$(ROOT_SRCDIR)/tools
30 #build: build/xds build/cmds
36 @echo "### Build XDS server (version $(VERSION))";
37 @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o bin/xds-server -ldflags "-X main.AppVersionGitTag=$(VERSION)" .
40 # @for target in $(WHAT); do \
41 # echo "### Build $$target"; \
42 # $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o bin/$$target -ldflags "-X main.AppVersionGitTag=$(VERSION)" ./cmd/$$target; \
46 go test --race $(shell ./tools/glide novendor)
49 go vet $(shell ./tools/glide novendor)
52 go fmt $(shell ./tools/glide novendor)
55 ./bin/xds-server --log info -c config.json.in
57 debug: build/xds webapp/debug
58 ./bin/xds-server --log debug -c config.json.in
61 rm -rf ./bin/* debug cmd/*/debug $(ROOT_GOPRJ)/pkg/*/$(REPOPATH)
64 rm -rf bin tools glide.lock vendor cmd/*/vendor webapp/node_modules webapp/dist
69 webapp: webapp/install
70 (cd webapp && gulp build)
73 (cd webapp && gulp watch &)
76 (cd webapp && npm install)
79 # FIXME - package webapp
81 goxc -d ./release -tasks-=go-vet,go-test -os="linux darwin" -pv=$(VERSION) -arch="386 amd64 arm arm64" -build-ldflags="-X main.AppVersionGitTag=$(VERSION)" -resources-include="README.md,Documentation,LICENSE,contrib" -main-dirs-exclude="vendor"
84 mkdir -p release/$(VERSION)
85 glide install --strip-vcs --strip-vendor --update-vendored --delete
86 glide-vc --only-code --no-tests --keep="**/*.json.in"
87 git ls-files > /tmp/xds-server-build
88 find vendor >> /tmp/xds-server-build
89 find webapp/ -path webapp/node_modules -prune -o -print >> /tmp/xds-server-build
90 tar -cvf release/$(VERSION)/xds-server_$(VERSION)_src.tar -T /tmp/xds-server-build --transform 's,^,xds-server_$(VERSION)/,'
91 rm /tmp/xds-server-build
92 gzip release/$(VERSION)/xds-server_$(VERSION)_src.tar
95 vendor: tools/glide glide.yaml
96 ./tools/glide install --strip-vendor
99 @echo "Downloading glide"
101 curl --silent -L https://glide.sh/get | GOBIN=./tools sh
107 @echo "Main supported rules:"
108 @echo " build (default)"
115 @echo "Influential make variables:"
116 @echo " V - Build verbosity {0,1,2}."
117 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."
118 # @echo " WHAT - Command to build. (e.g. WHAT=xds-make)"