2015-10-11 04:40:05 +08:00
|
|
|
COMMANDS := $(addprefix ./,$(wildcard cmd/*))
|
|
|
|
PACKAGES := .
|
|
|
|
VERSION := $(shell cat .goxc.json | jq -c .PackageVersion | sed 's/"//g')
|
|
|
|
SOURCES := $(shell find . -name "*.go")
|
2015-10-11 05:10:09 +08:00
|
|
|
GOTTY_URL := http://localhost:8081/
|
2015-10-11 04:32:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build: $(notdir $(COMMANDS))
|
|
|
|
|
|
|
|
|
2015-10-11 05:10:09 +08:00
|
|
|
.PHONY: test
|
|
|
|
test: build
|
|
|
|
./gotty-client $(GOTTY_URL)
|
|
|
|
|
|
|
|
|
2015-10-11 04:32:38 +08:00
|
|
|
.PHONY: build-docker
|
|
|
|
build-docker: contrib/docker/.docker-container-built
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -f $(notdir $(COMMANDS))
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: install
|
|
|
|
install:
|
|
|
|
go install $(COMMANDS)
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: release
|
|
|
|
release:
|
|
|
|
goxc
|
2015-10-11 04:40:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: build-docker
|
|
|
|
build-docker: contrib/docker/.docker-container-built
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: run-docker
|
|
|
|
run-docker: build-docker
|
|
|
|
docker run -it --rm moul/gotty-client $(GOTTY_URL)
|
|
|
|
|
|
|
|
|
|
|
|
$(notdir $(COMMANDS)): $(SOURCES)
|
|
|
|
gofmt -w $(PACKAGES) ./cmd/$@
|
|
|
|
go test -i $(PACKAGES) ./cmd/$@
|
2015-10-23 23:05:20 +08:00
|
|
|
go build -ldflags "-X main.VERSION=$(VERSION)" -o $@ ./cmd/$@
|
2015-10-11 05:10:09 +08:00
|
|
|
./$@ --version
|
2015-10-11 04:40:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
dist/latest/gotty-client_latest_linux_386: $(SOURCES)
|
|
|
|
mkdir -p dist
|
|
|
|
rm -f dist/latest
|
|
|
|
(cd dist; ln -s $(VERSION) latest)
|
|
|
|
goxc -bc="linux,386" xc
|
|
|
|
cp dist/latest/gotty-client_$(VERSION)_linux_386 dist/latest/gotty-client_latest_linux_386
|
|
|
|
|
|
|
|
|
|
|
|
contrib/docker/.docker-container-built: dist/latest/gotty-client_latest_linux_386
|
|
|
|
cp dist/latest/gotty-client_latest_linux_386 contrib/docker/gotty-client
|
|
|
|
docker build -t moul/gotty-client:latest contrib/docker
|
|
|
|
docker tag moul/gotty-client:latest moul/gotty-client:$(VERSION)
|
|
|
|
docker run -it --rm moul/gotty-client --version
|
|
|
|
docker inspect --type=image --format="{{ .Id }}" moul/gotty-client > $@.tmp
|
|
|
|
mv $@.tmp $@
|
2015-11-02 01:51:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: convey
|
|
|
|
convey:
|
|
|
|
go get github.com/smartystreets/goconvey
|
|
|
|
goconvey -cover -port=9042 -workDir="$(realpath .)" -depth=1
|