-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (61 loc) · 1.95 KB
/
Makefile
File metadata and controls
74 lines (61 loc) · 1.95 KB
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
BINARY_NAME=ro-tui
.PHONY: build run install tidy fmt test it
ROOT_DIR := $(shell pwd)
# Go caches:
# - Default is to use a shared per-user cache dir so isolated agent dirs (worktrees/copies)
# do not "redownload the world" on each build/test.
# - Override by setting GO_CACHE_DIR (or pre-setting GOMODCACHE/GOCACHE).
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
DEFAULT_GO_CACHE_DIR := $(HOME)/Library/Caches/ro-cli-go
else
DEFAULT_GO_CACHE_DIR := $(HOME)/.cache/ro-cli-go
endif
GO_CACHE_DIR ?= $(DEFAULT_GO_CACHE_DIR)
export GOMODCACHE ?= $(GO_CACHE_DIR)/gomodcache
export GOCACHE ?= $(GO_CACHE_DIR)/gocache
prep-cache:
@mkdir -p "$(GOMODCACHE)" "$(GOCACHE)"
build:
build: prep-cache
go build -o ./dist/$(BINARY_NAME) ./cmd/ro-tui
run:
run: prep-cache
go run ./cmd/ro-tui
tidy:
tidy: prep-cache
go mod tidy
fmt:
gofmt -w .
test:
test: prep-cache
@# If an in-repo module cache exists under tmp/, `go test ./...` will walk it and fail.
@# These caches are often read-only, so we rename them into an ignored dir (leading '_').
@# If a previous ignored cache already exists, move the new one aside (to avoid leaving tmp/gomodcache behind).
@if [ -d ./tmp/gomodcache ]; then \
if [ -d ./tmp/_gomodcache ]; then \
i=1; while [ -d "./tmp/_gomodcache$$i" ]; do i=$$((i+1)); done; \
mv ./tmp/gomodcache "./tmp/_gomodcache$$i"; \
else \
mv ./tmp/gomodcache ./tmp/_gomodcache; \
fi; \
fi
@if [ -d ./tmp/gocache ]; then \
if [ -d ./tmp/_gocache ]; then \
i=1; while [ -d "./tmp/_gocache$$i" ]; do i=$$((i+1)); done; \
mv ./tmp/gocache "./tmp/_gocache$$i"; \
else \
mv ./tmp/gocache ./tmp/_gocache; \
fi; \
fi
go test ./...
it:
it: prep-cache
bash ./scripts/cli_integration.sh
install:
install: prep-cache test it
@BIN_DIR="$$(go env GOBIN)"; \
if [ -z "$$BIN_DIR" ]; then BIN_DIR="$$(go env GOPATH)/bin"; fi; \
mkdir -p "$$BIN_DIR"; \
go build -o "$$BIN_DIR/$(BINARY_NAME)" ./cmd/ro-tui; \
echo "Installed: $$BIN_DIR/$(BINARY_NAME)"