-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (58 loc) · 1.77 KB
/
Makefile
File metadata and controls
71 lines (58 loc) · 1.77 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
# Build zk in the current folder.
build:
$(call go,build)
# Build and install `zk` using go's default bin directory.
install:
$(call go,install)
# Run unit tests.
test:
$(call go,test,./...)
find . -name '*.go' | xargs gofmt -w
# Run end-to-end tests.
tesh: build
@PATH=".:$(shell pwd):$(PATH)" tesh tests tests/fixtures
# Run end-to-end tests and prints difference as raw bytes.
teshb: build
@PATH=".:$(shell pwd):$(PATH)" tesh -b tests tests/fixtures
# Update end-to-end tests.
tesh-update: build
PATH=".:$(shell pwd):$(PATH)" tesh -u tests tests/fixtures
testdata:
$(call go,build,-o gentestdata ./cmd/gentestdata)
./gentestdata -output testdata -notes 3000
rm -f gentestdata
echo "Use with: zk testdata && ../zk…"
alpine:
$(call alpine,build)
# Clean build and docs products.
clean:
rm -rf zk*
rm -rf docs-build
rm -rf testdata
VERSION ?= $(shell \
if grep -vq '^\$$Format' VERSION.txt 2>/dev/null; then \
cat VERSION.txt; \
else \
git describe --tags --always --dirty --match v[0-9]* 2>/dev/null; \
fi \
)
VERSION_DOCS := $(shell echo $(VERSION) | cut -c 2-)
# Docs
zkdocs:
mkdir -p docs-build
echo "$(VERSION_DOCS)" > docs/version.txt
sphinx-build -a docs docs-build
ENV_PREFIX := CGO_ENABLED=1
# Add necessary env variables for Apple Silicon.
ifeq ($(shell uname -sm),Darwin arm64)
ENV_PREFIX := $(ENV) GOARCH=arm64
endif
# Wrapper around the go binary, to set all the default parameters.
define go
$(ENV_PREFIX) go $(1) -buildvcs=false -tags "fts5" -ldflags "-X=main.Version=$(VERSION)" $(2)
endef
# Alpine (musl) requires statically linked libs. This should be compatible for
# Void linux and other musl based distros aswell.
define alpine
$(ENV_PREFIX) go $(1) -buildvcs=false -tags "fts5" -ldflags "-extldflags=-static -X=main.Version=$(VERSION)" $(2)
endef