Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (64 loc) · 2.91 KB
/
Copy pathMakefile
File metadata and controls
81 lines (64 loc) · 2.91 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
# Top-level wrapper for build, format, lint, and test workflows.
# All real work happens via cmake / clang-format / clang-tidy / scripts/.
# Run `make` (or `make help`) for a target list.
BUILD_DIR := build
CMAKE ?= cmake
# Prefer the Homebrew LLVM toolchain when available — clang-tidy needs to
# match the host triple (arm64 macOS), and a Windows-targeting llvm-mingw
# binary in PATH will choke on system headers. Override via env if needed:
# make tidy CLANG_TIDY=/some/other/clang-tidy
HOMEBREW_LLVM_BIN := /opt/homebrew/opt/llvm/bin
CLANG_FORMAT ?= $(shell test -x $(HOMEBREW_LLVM_BIN)/clang-format && \
echo $(HOMEBREW_LLVM_BIN)/clang-format || echo clang-format)
CLANG_TIDY ?= $(shell test -x $(HOMEBREW_LLVM_BIN)/clang-tidy && \
echo $(HOMEBREW_LLVM_BIN)/clang-tidy || echo clang-tidy)
# Every tracked C/C++ source or header (any depth). git ls-files's `*`
# matches `/`, so a single pattern covers all subdirectories.
FORMAT_FILES := $(shell git ls-files '*.c' '*.cpp' '*.h' '*.hpp')
# Host-code translation units only. The x86_64 .c samples in tests/ and
# benchmarks/ are excluded — clang-tidy mostly flags noise on them.
TIDY_FILES := $(shell git ls-files \
'rosetta_core/*.cpp' \
'rosetta_loader/*.cpp' \
'rosetta_config/*.cpp' \
'aotinvoke/*.cpp' \
'tools/*.cpp')
.PHONY: help build configure format format-check tidy tidy-fix \
test bench fusion-sweep clean
help:
@echo "Targets:"
@echo " build - configure and build (cmake -B build && cmake --build build)"
@echo " configure - cmake configure only (re-emits compile_commands.json)"
@echo " format - clang-format -i on all tracked C/C++ sources"
@echo " format-check - dry-run format check; non-zero exit if anything is dirty"
@echo " tidy - clang-tidy diagnostics on host C++ TUs"
@echo " tidy-fix - clang-tidy --fix on host C++ TUs"
@echo " test - scripts/run_tests.sh"
@echo " bench - scripts/run_benchmarks.sh"
@echo " fusion-sweep - scripts/run_fusion_sweep.sh"
@echo " clean - rm -rf $(BUILD_DIR)"
build: configure
$(CMAKE) --build $(BUILD_DIR)
configure:
$(CMAKE) -B $(BUILD_DIR)
format:
$(CLANG_FORMAT) -i $(FORMAT_FILES)
format-check:
$(CLANG_FORMAT) --dry-run -Werror $(FORMAT_FILES)
# Apple's /usr/bin/c++ adds the macOS SDK implicitly, so the entries in
# compile_commands.json don't carry -isysroot. Homebrew clang-tidy isn't
# Apple, so it can't find <cstdint> & friends without being told. Inject
# the active SDK path via --extra-arg.
TIDY_EXTRA := --extra-arg=-isysroot$(shell xcrun --show-sdk-path)
tidy: configure
$(CLANG_TIDY) -p $(BUILD_DIR) $(TIDY_EXTRA) $(TIDY_FILES)
tidy-fix: configure
$(CLANG_TIDY) -p $(BUILD_DIR) $(TIDY_EXTRA) --fix --fix-errors $(TIDY_FILES)
test:
scripts/run_tests.sh
bench:
scripts/run_benchmarks.sh
fusion-sweep:
scripts/run_fusion_sweep.sh
clean:
rm -rf $(BUILD_DIR)