-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
124 lines (98 loc) · 3.34 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.DEFAULT_GOAL := build
# Local variables
THEMES = $(notdir $(basename $(wildcard etc/defaults/themes/*.yaml)))
SCREENSHOT_SAMPLE = prometheus.log
# Exported variables
export RUST_BACKTRACE=1
# The list of files that are intentionally ignored while being tracked
ignored-tracked-files = .vscode/settings.json
## Print help
help:
@echo "$$(tput setaf 2)Usage$$(tput sgr0)";sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## /---/;td" -e"s/:.*//;G;s/\\n## /===/;s/\\n//g;p;}" ${MAKEFILE_LIST}|awk -F === -v n=$$(tput cols) -v i=4 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf" '$$(tput setaf 2)make$$(tput sgr0)' %s%s%s\t",a,$$1,z;m=split($$2,w,"---");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;}printf"%*s%s\n",-i," ",w[j];}}' | column -ts $$'\t'
.PHONY: help
## Run continuous integration tests
ci: check-fmt check-schema test build
@cargo run -- --version
.PHONY: ci
## Run code formatting tests
check-fmt: contrib-build
@cargo +nightly fmt --all -- --check
.PHONY: check-fmt
## Run schema validation tests
check-schema: contrib-build
@taplo check
.PHONY: check-schema
## Automatically format code
fmt:
@cargo +nightly fmt --all
.PHONY: fmt
## Build debug target
build: contrib-build
@cargo build --benches
.PHONY: build
## Build release target
build-release: contrib-build
@cargo build --release --locked
.PHONY: build-release
## Install binary and man pages
install: contrib-build install-man-pages
@cargo install --path . --locked
.PHONY: install
## Install man pages
install-man-pages: ~/share/man/man1/hl.1
@echo $$(tput setaf 3)NOTE:$$(tput sgr0) ensure $$(tput setaf 2)~/share/man$$(tput sgr0) is added to $$(tput setaf 2)MANPATH$$(tput sgr0) environment variable
.PHONY: install-man-pages
~/share/man/man1/hl.1: contrib-build | ~/share/man/man1
@HL_CONFIG= cargo run --release --locked -- --man-page >$@
~/share/man/man1:
@mkdir -p $@
## Install versioned binary
install-versioned: contrib-build
@cargo install --path . --locked
@cp ${HOME}/.cargo/bin/hl ${HOME}/.cargo/bin/$$(${HOME}/.cargo/bin/hl --version | tr ' ' '-')
.PHONY: install-versioned
## Run tests
test: contrib-build
@cargo test --workspace
.PHONY: test
## Run benchmarks
bench: contrib-build
@cargo bench --workspace
.PHONY: bench
## Show usage of the binary
usage: build
@env -i HL_CONFIG= ./target/debug/hl --help
.PHONY: usage
## Clean build artifacts
clean: contrib-build
@cargo clean
.PHONY: clean
## Create screenshots
screenshots: build $(THEMES:%=screenshot-%)
.PHONY: screenshots
screenshot-%: build contrib-screenshots
@defaults write org.alacritty NSRequiresAquaSystemAppearance -bool yes
@contrib/bin/screenshot.sh light $(SCREENSHOT_SAMPLE) $*
@defaults write org.alacritty NSRequiresAquaSystemAppearance -bool no
@contrib/bin/screenshot.sh dark $(SCREENSHOT_SAMPLE) $*
@defaults delete org.alacritty NSRequiresAquaSystemAppearance
.PHONY: screenshot-%
## Collect coverage
coverage:
@contrib/bin/setup.sh coverage
@build/ci/coverage.sh
.PHONY: coverage
## Skip ignored tracked files
skip-ignored:
@git update-index --skip-worktree $(ignored-tracked-files)
.PHONY: skip-ignored
## Undo skip-ignored
no-skip-ignored:
@git update-index --no-skip-worktree $(ignored-tracked-files)
.PHONY: no-skip-ignored
contrib-build:
@contrib/bin/setup.sh build
.PHONY: contrib-build
contrib-screenshots:
@contrib/bin/setup.sh screenshots
.PHONY: contrib-screenshots