a love letter to tangled (android, iOS, and a search API)
1version := `git describe --tags --always --dirty 2>/dev/null || echo dev`
2commit := `git rev-parse --short HEAD 2>/dev/null || echo none`
3ldflags := "-s -w -X main.version=" + version + " -X main.commit=" + commit
4
5build:
6 CGO_ENABLED=0 go build -ldflags "{{ldflags}}" -o twister ./main.go
7
8# Run the API server. Usage: just run-api [mode], mode: local|remote|sqlite (default local)
9run-api mode="local":
10 if [ "{{mode}}" = "local" ]; then \
11 DATABASE_URL="postgresql://localhost/${USER:-postgres}_dev?sslmode=disable" \
12 go run -ldflags "{{ldflags}}" ./main.go api; \
13 elif [ "{{mode}}" = "remote" ]; then \
14 go run -ldflags "{{ldflags}}" ./main.go api; \
15 elif [ "{{mode}}" = "sqlite" ]; then \
16 go run -ldflags "{{ldflags}}" ./main.go api --local; \
17 else \
18 echo "invalid mode '{{mode}}' (expected local, remote, or sqlite)" >&2; \
19 exit 1; \
20 fi
21
22# Run the indexer. Usage: just run-indexer [mode], mode: local|remote|sqlite (default local)
23run-indexer mode="local":
24 if [ "{{mode}}" = "local" ]; then \
25 DATABASE_URL="postgresql://localhost/${USER:-postgres}_dev?sslmode=disable" \
26 TAP_URL="${TAP_URL:-ws://localhost:2480/channel}" \
27 TAP_AUTH_PASSWORD="${TAP_AUTH_PASSWORD:-twisted-dev}" \
28 go run -ldflags "{{ldflags}}" ./main.go indexer; \
29 elif [ "{{mode}}" = "remote" ]; then \
30 go run -ldflags "{{ldflags}}" ./main.go indexer; \
31 elif [ "{{mode}}" = "sqlite" ]; then \
32 go run -ldflags "{{ldflags}}" ./main.go indexer --local; \
33 else \
34 echo "invalid mode '{{mode}}' (expected local, remote, or sqlite)" >&2; \
35 exit 1; \
36 fi
37
38test:
39 go test ./...
40
41clean:
42 rm -f twister