-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (63 loc) · 3.33 KB
/
Copy pathMakefile
File metadata and controls
79 lines (63 loc) · 3.33 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
.PHONY: build build-debug test test-seq test-all tidy tidy-ci clean bootstrap rebuild docker docker-build docker-shell
BUILD_DIR := build
CMAKE_FLAGS := -G Ninja -DCMAKE_BUILD_TYPE=Release
JOBS := 2
build:
cmake -S . -B $(BUILD_DIR) $(CMAKE_FLAGS) && \
ninja -C $(BUILD_DIR) -j$(JOBS)
build-debug:
cmake -S . -B $(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Debug && \
ninja -C $(BUILD_DIR) -j$(JOBS)
test:
rm -rf ~/.cache/fluxscript && bash tests/integration/run_tests.sh -P $(JOBS)
test-seq:
rm -rf ~/.cache/fluxscript && bash tests/integration/run_tests.sh
test-all:
rm -rf ~/.cache/fluxscript && \
cd $(BUILD_DIR) && ctest --output-on-failure -j$(JOBS)
clean:
ninja -C $(BUILD_DIR) clean 2>/dev/null; true
rebuild: clean build
# ── bootstrap: build the self‑hosted compiler ──────────────────────────────
bootstrap: build
rm -rf ~/.cache/fluxscript
build/flux --cache=0 --emit=llvm src/fluxc/main.flux > /tmp/flux_stage2.ll
/usr/lib/llvm-21/bin/opt -passes=verify /tmp/flux_stage2.ll -o /tmp/flux_stage2_verify.bc
/usr/lib/llvm-21/bin/opt -passes=globaldce /tmp/flux_stage2_verify.bc -o /tmp/flux_stage2_gced.bc
/usr/lib/llvm-21/bin/llc -O2 -relocation-model=pic /tmp/flux_stage2_gced.bc -o /tmp/flux_stage2.s
g++ -O2 /tmp/flux_stage2.s -L$(BUILD_DIR) -lFluxScript -Wl,-rpath,$(BUILD_DIR) -o /tmp/fluxc2
FLUX_INPUT=src/fluxc/main.flux /tmp/fluxc2 > /tmp/flux_stage3.ll
/usr/lib/llvm-21/bin/opt -passes=verify /tmp/flux_stage3.ll -o /tmp/flux_stage3_verify.bc
/usr/lib/llvm-21/bin/opt -passes=globaldce /tmp/flux_stage3_verify.bc -o /tmp/flux_stage3_gced.bc
/usr/lib/llvm-21/bin/llc -O2 -relocation-model=pic /tmp/flux_stage3_gced.bc -o /tmp/flux_stage3.s
g++ -O2 /tmp/flux_stage3.s -L$(BUILD_DIR) -lFluxScript -Wl,-rpath,$(BUILD_DIR) -o $(BUILD_DIR)/fluxc_bootstrap
@echo "Bootstrap complete: $(BUILD_DIR)/fluxc_bootstrap"
# ── interactive: rebuild then open a REPL ──────────────────────────────────
run: build
ninja -C $(BUILD_DIR) flux-run && $(BUILD_DIR)/flux-run
# ── clang-tidy: static analysis ────────────────────────────────────────────
CLANG_TIDY := $(shell command -v clang-tidy-21 2>/dev/null || command -v clang-tidy 2>/dev/null)
TIDY_SOURCES := $(shell find src/compiler/ include/ -name '*.cpp' -o -name '*.h' -o -name '*.hpp' | sort)
tidy:
ifdef CLANG_TIDY
@echo "Running clang-tidy on all source files..."
$(CLANG_TIDY) -p $(BUILD_DIR) $(if $(FILE),$(FILE),$(TIDY_SOURCES)) 2>&1 | tee /tmp/clang-tidy.log
@echo "Results written to /tmp/clang-tidy.log"
else
@echo "clang-tidy not found. Install clang-tidy-21: sudo apt install clang-tidy-21"
endif
tidy-ci:
ifdef CLANG_TIDY
$(CLANG_TIDY) -p $(BUILD_DIR) $(TIDY_SOURCES) --warnings-as-errors='*' 2>&1
else
@echo "clang-tidy not found, skipping"
endif
# ── Docker dev environment ────────────────────────────────────────────────
DOCKER_IMAGE := fluxscript-dev
docker-build:
docker build -t $(DOCKER_IMAGE) -f Dockerfile.dev .
docker-shell: docker-build
docker run -it --rm \
-v $(PWD):/workspace \
-v $(HOME)/.cache/ccache:/root/.cache/ccache \
$(DOCKER_IMAGE)