2018-06-28 08:40:18 +03:00
|
|
|
PWD := $(shell pwd)
|
|
|
|
PARENT_DIR := $(shell dirname $(PWD))
|
2018-07-03 20:10:13 +03:00
|
|
|
VERSION ?= $(shell ../scripts/get-version.sh)
|
2018-06-28 08:40:18 +03:00
|
|
|
OUTPUT_DIR := _output
|
|
|
|
|
|
|
|
# compile assets
|
2018-06-29 16:09:21 +03:00
|
|
|
.PHONY: assets
|
2018-06-28 08:40:18 +03:00
|
|
|
assets:
|
2018-07-03 20:10:13 +03:00
|
|
|
go-bindata --pkg assets -o assets/assets.go assets/**/*.html
|
2018-06-28 08:40:18 +03:00
|
|
|
|
2018-06-29 16:09:21 +03:00
|
|
|
HAS_GOX := $(shell command -v gox;)
|
|
|
|
HAS_DEP := $(shell command -v dep;)
|
|
|
|
HAS_BINDATA := $(shell command -v go-bindata;)
|
|
|
|
|
|
|
|
.PHONY: deps
|
2018-06-28 08:40:18 +03:00
|
|
|
# get dependencies
|
|
|
|
deps:
|
2018-06-29 16:09:21 +03:00
|
|
|
ifndef HAS_DEP
|
|
|
|
go get -u github.com/golang/dep/cmd/dep
|
|
|
|
endif
|
|
|
|
ifndef HAS_GOX
|
2018-06-28 08:40:18 +03:00
|
|
|
go get github.com/mitchellh/gox
|
2018-06-29 16:09:21 +03:00
|
|
|
endif
|
|
|
|
ifndef HAS_BINDATA
|
2018-06-28 08:40:18 +03:00
|
|
|
go get github.com/hasura/go-bindata/go-bindata
|
2018-06-29 16:09:21 +03:00
|
|
|
endif
|
|
|
|
if [ ! -d "vendor" ]; then dep ensure -v -vendor-only; fi
|
2018-06-28 08:40:18 +03:00
|
|
|
|
|
|
|
# build cli locally, for all given platform/arch
|
2018-06-29 16:09:21 +03:00
|
|
|
.PHONY: build
|
2018-06-28 08:40:18 +03:00
|
|
|
build:
|
2018-07-04 15:43:52 +03:00
|
|
|
gox -ldflags "-X github.com/hasura/graphql-engine/cli/version.BuildVersion=$(VERSION) -s -w" \
|
2018-06-28 08:40:18 +03:00
|
|
|
-os="linux darwin windows" \
|
|
|
|
-arch="amd64" \
|
2018-07-17 20:00:26 +03:00
|
|
|
-output="$(OUTPUT_DIR)/$(VERSION)/cli-hasura-{{.OS}}-{{.Arch}}" \
|
2018-06-28 08:40:18 +03:00
|
|
|
./cmd/hasura/
|
|
|
|
|
2018-06-29 16:09:21 +03:00
|
|
|
# compress
|
|
|
|
.PHONY: compress
|
|
|
|
compress:
|
2018-07-17 20:00:26 +03:00
|
|
|
ls $(OUTPUT_DIR)/$(VERSION)/cli-hasura-* | xargs upx
|
2018-06-29 16:09:21 +03:00
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
# to be executed in circle-ci only
|
|
|
|
ci-copy-binary:
|
2018-07-17 20:00:26 +03:00
|
|
|
mkdir -p /build/_cli_output/binaries
|
|
|
|
cp $(OUTPUT_DIR)/$(VERSION)/cli-hasura-* /build/_cli_output/binaries
|
2018-07-10 13:01:02 +03:00
|
|
|
echo "$(VERSION)" > /build/_cli_output/version.txt
|
|
|
|
|
2018-06-28 08:40:18 +03:00
|
|
|
# run tests
|
2018-06-29 16:09:21 +03:00
|
|
|
.PHONY: test
|
2018-06-28 08:40:18 +03:00
|
|
|
test:
|
2018-07-10 13:01:02 +03:00
|
|
|
go test -ldflags "-X github.com/hasura/graphql-engine/cli/version.BuildVersion=$(VERSION)" ./...
|
2018-06-28 08:40:18 +03:00
|
|
|
|
|
|
|
# generate docs
|
2018-06-29 16:09:21 +03:00
|
|
|
.PHONY: docs
|
2018-06-28 08:40:18 +03:00
|
|
|
docs:
|
|
|
|
rm -fr docs
|
|
|
|
go run cmd/hasura/hasura.go docs --type md --directory docs
|
|
|
|
|
|
|
|
# clean the output directory
|
2018-06-29 16:09:21 +03:00
|
|
|
.PHONY: clean
|
2018-06-28 08:40:18 +03:00
|
|
|
clean:
|
|
|
|
rm -rf "$(OUTPUT_DIR)"
|
|
|
|
|
2018-06-29 16:09:21 +03:00
|
|
|
.PHONY: all
|
2018-06-28 08:40:18 +03:00
|
|
|
all: deps assets test build
|
|
|
|
|
|
|
|
# build cli inside a docker container
|
|
|
|
all-in-docker:
|
|
|
|
docker build -t hasura-graphql-cli-builder -f build/builder.dockerfile build
|
|
|
|
docker run --rm -it \
|
|
|
|
-v $(PARENT_DIR):/go/src/github.com/hasura/graphql-engine \
|
|
|
|
hasura-graphql-cli-builder \
|
|
|
|
make all
|