-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
135 lines (106 loc) · 3.29 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
125
126
127
128
129
130
131
132
133
134
135
# Common makefile helpers
include build/make/common.mk
.DEFAULT_GOAL := build
SHELL = /bin/bash
# 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
## Build debug target
.PHONY: build
build: contrib-build
@cargo build --benches
## Run continuous integration tests
.PHONY: ci
ci: check-fmt check-schema test build
@cargo run -- --version
## Run code formatting tests
.PHONY: check-fmt
check-fmt: contrib-build-nightly
@cargo +nightly fmt --all -- --check
## Run schema validation tests
.PHONY: check-schema
check-schema: contrib-schema
@taplo check
## Automatically format code
.PHONY: fmt
fmt: contrib-build-nightly
@cargo +nightly fmt --all
## Build release target
.PHONY: build-release
build-release: contrib-build
@cargo build --release --locked
## Install binary and man pages
.PHONY: install
install: contrib-build install-man-pages
@cargo install --path . --locked
## Install man pages
.PHONY: 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
~/share/man/man1/hl.1: contrib-build | ~/share/man/man1
cargo run --release --locked -- --config - --man-page >"$@"
~/share/man/man1:
@mkdir -p "$@"
## Install versioned binary
.PHONY: install-versioned
install-versioned: contrib-build
@cargo install --path . --locked
@cp ${HOME}/.cargo/bin/hl ${HOME}/.cargo/bin/$$(${HOME}/.cargo/bin/hl --version | tr ' ' '-')
## Run tests
.PHONY: test
test: contrib-build
@cargo test --workspace
## Run benchmarks
.PHONY: bench
bench: contrib-build
@cargo bench --workspace
## Show usage of the binary
.PHONY: usage
usage: build
@./target/debug/hl --config - --help
## Clean build artifacts
.PHONY: clean
clean: contrib-build
@cargo clean
## Create screenshots
.PHONY: screenshots
screenshots: build $(THEMES:%=screenshot-%)
screenshot-%: build contrib-screenshots
@defaults write org.alacritty NSRequiresAquaSystemAppearance -bool yes
@$(SHELL) contrib/bin/screenshot.sh light $(SCREENSHOT_SAMPLE) $*
@defaults write org.alacritty NSRequiresAquaSystemAppearance -bool no
@$(SHELL) contrib/bin/screenshot.sh dark $(SCREENSHOT_SAMPLE) $*
@defaults delete org.alacritty NSRequiresAquaSystemAppearance
.PHONY: screenshot-%
## Collect coverage
.PHONY: coverage
coverage: contrib-coverage
@$(SHELL) contrib/bin/setup.sh coverage
@$(SHELL) build/ci/coverage.sh
## Skip ignored tracked files
.PHONY: skip-ignored
skip-ignored:
@git update-index --skip-worktree $(ignored-tracked-files)
## Undo skip-ignored
.PHONY: no-skip-ignored
no-skip-ignored:
@git update-index --no-skip-worktree $(ignored-tracked-files)
.PHONY: contrib-build
contrib-build:
@$(SHELL) contrib/bin/setup.sh build
.PHONY: contrib-build-nightly
contrib-build-nightly:
@$(SHELL) contrib/bin/setup.sh build-nightly
.PHONY: contrib-coverage
contrib-coverage:
@$(SHELL) contrib/bin/setup.sh coverage
.PHONY: contrib-schema
contrib-schema:
@$(SHELL) contrib/bin/setup.sh schema
.PHONY: contrib-screenshots
contrib-screenshots:
@$(SHELL) contrib/bin/setup.sh screenshots