forked from utilityai/llama-cpp-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (102 loc) · 4.06 KB
/
Copy pathMakefile
File metadata and controls
135 lines (102 loc) · 4.06 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
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
.DELETE_ON_ERROR:
TEST_DEVICE ?=
DEVICE_FEATURE = $(if $(TEST_DEVICE),--features $(TEST_DEVICE),)
CLANG_TIDY ?= clang-tidy
COMPILE_COMMANDS = target/compile_commands.json
CPPCHECK = target/cppcheck-src/cppcheck
CPPCHECK_COMMIT = f726f98ed2c3277780ee133ec5338f6352d7b43b
CPPCHECK_SOURCE = https://github.com/danmar/cppcheck.git
WRAPPER_SOURCES_RESPONSE_FILE = target/wrapper_sources.rsp
WRAPPER_SOURCES_CRATE = llama-cpp-wrapper-sources
WRAPPER_SOURCES_CRATE_FILES = \
$(WRAPPER_SOURCES_CRATE)/src/compile_commands_file.rs \
$(WRAPPER_SOURCES_CRATE)/src/cpp_standard.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_include_dirs.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_source_paths.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_sources.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_sources_response_file.rs
EMIT_WRAPPER_BUILD_INPUTS = cargo run --quiet --package $(WRAPPER_SOURCES_CRATE) -- \
$(CURDIR)/llama-cpp-bindings-sys $(COMPILE_COMMANDS) $(WRAPPER_SOURCES_RESPONSE_FILE)
VENDORED_SUPPRESSIONS = \
--suppress='*:*llama-cpp-bindings-sys/llama.cpp/*' \
--suppress='*:*llama-cpp-bindings-sys/GSL/*'
node_modules: package-lock.json
npm ci
touch node_modules
package-lock.json: package.json
npm install --package-lock-only
$(COMPILE_COMMANDS): $(WRAPPER_SOURCES_CRATE_FILES)
$(EMIT_WRAPPER_BUILD_INPUTS)
target/cppcheck-src/Makefile:
git init --quiet target/cppcheck-src
git -C target/cppcheck-src fetch --quiet --depth 1 $(CPPCHECK_SOURCE) $(CPPCHECK_COMMIT)
git -C target/cppcheck-src checkout --quiet FETCH_HEAD
$(CPPCHECK): target/cppcheck-src/Makefile
$(MAKE) --directory=target/cppcheck-src cppcheck \
FILESDIR=$(CURDIR)/target/cppcheck-src
target/lint-venv/bin/clang-tidy: requirements-lint.txt
python3 -m venv target/lint-venv
target/lint-venv/bin/pip install --quiet --requirement requirements-lint.txt
$(WRAPPER_SOURCES_RESPONSE_FILE): $(WRAPPER_SOURCES_CRATE_FILES)
$(EMIT_WRAPPER_BUILD_INPUTS)
.PHONY: clean.cmake
clean.cmake:
cargo clean --package llama-cpp-bindings-sys
.PHONY: clippy
clippy:
cargo clippy --workspace --all-targets $(DEVICE_FEATURE) -- -D warnings
.PHONY: coverage
coverage: node_modules
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report --no-fail-fast --workspace $(DEVICE_FEATURE)
cargo llvm-cov report --json --output-path target/llvm-cov.json
cargo llvm-cov report --lcov --output-path target/lcov.info
cargo llvm-cov report
./node_modules/.bin/rust-coverage-check target/llvm-cov.json \
--workspace-root $(CURDIR) \
--gated llama-cpp-bindings=98 \
--gated llama-cpp-bindings-types=100 \
--gated llama-cpp-error-recorder=100 \
--gated llama-cpp-ffi-status=100 \
--gated llama-cpp-gbnf=100 \
--gated llama-cpp-log-decoder=100 \
--gated llama-cpp-test-harness=99 \
--gated llama-cpp-test-harness-macros=100 \
--gated llama-cpp-wrapper-sources=100
.PHONY: coverage-clean
coverage-clean:
cargo llvm-cov clean --workspace
rm -rf target/llvm-cov-target
rm -f target/llvm-cov.json target/lcov.info
.PHONY: coverage-report
coverage-report:
cargo llvm-cov report --html
.PHONY: fmt
fmt:
cargo fmt --all
.PHONY: fmt.check
fmt.check:
cargo fmt --all --check
.PHONY: lint.cpp
lint.cpp: lint.cpp.clang-tidy lint.cpp.cppcheck
.PHONY: lint.cpp.clang-tidy
lint.cpp.clang-tidy: $(COMPILE_COMMANDS) $(WRAPPER_SOURCES_RESPONSE_FILE)
$(CLANG_TIDY) -p $(dir $(COMPILE_COMMANDS)) @$(WRAPPER_SOURCES_RESPONSE_FILE)
.PHONY: lint.cpp.cppcheck
lint.cpp.cppcheck: $(COMPILE_COMMANDS) $(CPPCHECK)
$(CPPCHECK) --project=$(COMPILE_COMMANDS) --enable=all --inconclusive \
--check-level=exhaustive --error-exitcode=1 \
$(VENDORED_SUPPRESSIONS) \
--suppress=missingIncludeSystem
.PHONY: test
test: test.llms
.PHONY: test.harness
test.harness: clippy
cargo test -p llama-cpp-test-harness-macros -p llama-cpp-test-harness $(DEVICE_FEATURE)
.PHONY: test.llms
test.llms: clippy test.harness test.unit
cargo test --no-fail-fast -p llama-cpp-bindings-tests $(DEVICE_FEATURE)
.PHONY: test.unit
test.unit: clippy
cargo test -p llama-cpp-bindings -p llama-cpp-bindings-build -p llama-cpp-gbnf \
-p llama-cpp-log-decoder -p llama-cpp-wrapper-sources $(DEVICE_FEATURE)