-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
196 lines (165 loc) · 4.02 KB
/
Copy pathMakefile
File metadata and controls
196 lines (165 loc) · 4.02 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
ROOT_DIR := $(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))")
BUILD_DIR ?= build
BUILD_TYPE ?= Debug
CXXFLAGS ?= -march=native
export CXXFLAGS
CUDAARCHS ?= native
export CUDAARCHS
THRUST_DEVICE_SYSTEM ?= CUDA
FORK ?= $(shell nproc)
FUZZ_MAX_TOTAL_TIME ?= 0
FUZZ_MAX_PRIMITIVE_COUNT ?= 0
FUZZ_BOX_WORLD ?= 0
TEST_NAME_REGEX ?= .*
VENV := venv
PYTHON := $(VENV)/bin/python
PIP := $(VENV)/bin/pip
PYTEST := $(VENV)/bin/pytest
MYPY := $(VENV)/bin/mypy
RUFF := $(VENV)/bin/ruff
CLANG_FMT := $(VENV)/bin/clang-format
PRECOMMIT := $(VENV)/bin/pre-commit
GIT_FIRST_COMMIT := $(shell git rev-list --max-parents=0 HEAD)
SPIRV_HEADERS := $(PWD)/external/SPIRV-Headers/include
SCREEN_SIZE ?= $(shell xdpyinfo | awk '/dimensions:/ { print $$2 }' | tr 'x' ' ')
.DEFAULT_GOAL := build
.DELETE_ON_ERROR:
.ONESHELL:
SHELL := $(shell which bash)
.SHELLFLAGS = -eu -o pipefail -c
.SECONDARY: $(VENV)/bin/activate
$(VENV)/bin/activate: pyproject.toml
trap 'rm -rf $(VENV)' ERR
python3 -m venv venv/
$(PIP) install --quiet --upgrade pip setuptools
$(PIP) install --verbose --progress-bar=on --no-build-isolation --editable .[dev]
touch $@
.PHONY: venv
venv: $(VENV)/bin/activate
.PHONY: clean-venv
clean-venv:
rm -rf $(VENV)
.PHONY: re-venv
re-venv: clean-venv venv
.PHONY: install-hooks
install-hooks: venv
$(PRECOMMIT) install
$(PRECOMMIT) install --hook-type commit-msg
.PHONY: sh shell
sh shell: venv
. venv/bin/activate
$(SHELL)
.PHONY: configure
configure: venv
nice cmake \
-S $(PWD) \
-B $(BUILD_DIR) \
-DTHRUST_DEVICE_SYSTEM=$(THRUST_DEVICE_SYSTEM) \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
.PHONY: cmake-graphviz
cmake-graphviz: venv
cmake \
--graphviz=$(BUILD_DIR)/sah_kd_tree.dot \
-S $(PWD) \
-B $(BUILD_DIR) \
-DTHRUST_DEVICE_SYSTEM=$(THRUST_DEVICE_SYSTEM) \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
dot \
-Tpng \
-o $(BUILD_DIR)/sah_kd_tree.png \
$(BUILD_DIR)/sah_kd_tree.dot
.PHONY: build
build: venv configure
nice cmake \
--build $(BUILD_DIR) \
--parallel
.PHONY: rebuild
rebuild: venv configure
nice cmake \
--build $(BUILD_DIR) \
--parallel \
--clean-first
.PHONY: clean
clean: venv configure
nice cmake \
--build $(BUILD_DIR) \
--parallel \
--target clean
.PHONY: docker-run
docker-run: venv
tools/docker/archlinux/run.sh $(COMMAND)
.PHONY: fuzz
fuzz: venv configure
nice cmake \
--build $(BUILD_DIR) \
--parallel \
--target fuzzer
nice $(BUILD_DIR)/tools/fuzz/fuzzer \
-box_world=$(FUZZ_BOX_WORLD) \
-max_primitive_count=$(FUZZ_MAX_PRIMITIVE_COUNT) \
-max_total_time=$(FUZZ_MAX_TOTAL_TIME) \
-fork=$(FORK) \
-rss_limit_mb=512 \
-timeout=30 \
-report_slow_units=30 \
-print_final_stats=1 \
-print_corpus_stats=1 \
-print_pcs=1 \
-reduce_depth=1 \
-reduce_inputs=1 \
-shrink=1 \
-prefer_small=1 \
-artifact_prefix=data/fuzz/artifacts/ \
data/fuzz/CORPUS/ \
data/fuzz/artifacts/
.PHONY: fuzz-merge
fuzz-merge: venv configure
nice cmake \
--build $(BUILD_DIR) \
--parallel \
--target fuzzer
nice tools/fuzz/fuzzer \
-fork=$(FORK) \
-merge=1 \
data/fuzz/CORPUS*/ \
data/fuzz/artifacts/
.PHONY: plan 3d
plan 3d: venv $(CRASH_FILE)
gnuplot \
-persist \
-c tools/plot/plot.plt \
$@ \
$(CRASH_FILE) \
$(SCREEN_SIZE)
.PHONY: check
check: venv
$(RUFF) check
$(RUFF) format --check
MYPYPATH=$(SPIRV_HEADERS) \
$(MYPY) \
--exclude-gitignore \
src/
.PHONY: format
format: venv
$(RUFF) format
$(RUFF) check --fix
MYPYPATH=$(SPIRV_HEADERS) \
$(MYPY) \
--exclude-gitignore \
src/
git add --update
git clang-format \
--binary=$(CLANG_FMT) \
--extensions=cpp,hpp,cu,cuh,inl.cu,js \
$(GIT_FIRST_COMMIT) \
|| true
git status
.PHONY: test-cpp
test-cpp: build
ctest \
--parallel \
--output-on-failure \
--test-dir $(BUILD_DIR)/src/ \
-R '$(TEST_NAME_REGEX)'