-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
88 lines (71 loc) · 2.49 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
SHELL := /bin/bash
# export GOPATH="$(HOME)/go:$(PWD)"
TARGET=/usr/local/bin
## help: this help file
help:
@( echo "" && echo "Makefile targets..." && echo "" )
@( cat Makefile | grep '^##' | sed -e 's/##/ -/' | sort && echo "" )
## build: build the cli and tcp services
build:
@[ -d bin ] || mkdir bin
( /bin/rm -f bin/* )
( go build -o bin/unique src/main.go )
( go build -o bin/unique-tcp tcp/unique-tcp.go )
## install: install all the cli versions locally, ulid, uuid, txid, xuid, etc
install:
cp -f bin/unique $(TARGET)/unique
ln -f $(TARGET)/unique $(TARGET)/ulid
ln -f $(TARGET)/unique $(TARGET)/uuid
ln -f $(TARGET)/unique $(TARGET)/guid
ln -f $(TARGET)/unique $(TARGET)/tsid
ln -f $(TARGET)/unique $(TARGET)/txid
ln -f $(TARGET)/unique $(TARGET)/cuid
ln -f $(TARGET)/unique $(TARGET)/xuid
ln -f $(TARGET)/unique $(TARGET)/bytes
## build-install: install all the cli versions locally, ulid, uuid, txid, xuid, etc
build-install:
@make build
@make install
## build-linux: build the targets for linux
build-linux:
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o linux/unique src/main.go
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o linux/unique-tcp tcp/unique-tcp.go
## docker: build and copy the tcp service
docker:
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o linux/unique-tcp tcp/unique-tcp.go
( cd linux && ./build.sh )
## install-deps: install all required dependencies
install-deps:
go get -u golang.org/x/lint/golint
go get github.com/oklog/ulid
go get github.com/franela/goblin
## format: format all souce code
format:
( gofmt -s -w src/*.go src/unique/*.go test/*.go tcp/*.go )
## lint: run lint on the source code
lint:
@( golint src/... && golint test/... )
## test: run all unit tests + vet + lint
test:
@( go vet src/unique/*.go && go vet src/unique/*.go && go vet src/*.go && cd test/ && go test -cover )
@( make lint )
## qtest: run all unit tests + vet
qtest:
@( go vet src/unique/*.go && go vet src/unique/*.go && go vet src/*.go && cd test/ && go test -cover )
## run: run the service
run:
go run src/main.go
## run-tcp: run the tcp service
run-tcp:
go run tcp/unique-tcp.go
## examples: run the example client
examples:
javac examples/UniqueClient.java
## watch: start the source code watcher
watch:
clear
while true; do inotifywait -r -e modify --exclude=".swp" src; clear; make test; done
## edit: edit the source code
edit:
vi -O2 src/*/*.go test/*.go src/*.go
.PHONY: format test watch examples edit run lint format install-deps