Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ib4000ab597f94b2dd3dccf1e31fce3a76a6a6964
98 lines
2.5 KiB
Makefile
98 lines
2.5 KiB
Makefile
# Default recipe, show available commands
|
|
default:
|
|
@just --list
|
|
|
|
# Build all targets
|
|
build:
|
|
cmake --build build
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
rm -rf build
|
|
find tests -name '*.nixir' -delete
|
|
|
|
# Configure and build from scratch
|
|
rebuild: clean
|
|
cmake -B build -G Ninja
|
|
cmake --build build
|
|
|
|
# Run unit tests
|
|
test-unit:
|
|
./build/regression_test
|
|
|
|
# Run compilation tests (do all fixtures compile?)
|
|
test-compile:
|
|
#!/usr/bin/env bash
|
|
total=0
|
|
success=0
|
|
for f in tests/fixtures/*.nix; do
|
|
total=$((total+1))
|
|
if ./build/nix-irc "$f" "${f%.nix}.nixir" 2>&1 | grep -q "Done!"; then
|
|
success=$((success+1))
|
|
fi
|
|
done
|
|
echo "Compiled: $success/$total test files"
|
|
[ $success -eq $total ]
|
|
|
|
# Run integration tests
|
|
test-integration:
|
|
./tests/integration/run.sh
|
|
|
|
# Run all tests
|
|
test: test-unit test-compile test-integration
|
|
@echo "All tests passed"
|
|
|
|
# Run benchmarks
|
|
bench:
|
|
./tests/benchmark/run.sh
|
|
|
|
# Compile a single Nix file to IR
|
|
compile FILE OUTPUT="":
|
|
#!/usr/bin/env bash
|
|
if [ -z "{{OUTPUT}}" ]; then
|
|
file="{{FILE}}"
|
|
output="${file%.nix}.nixir"
|
|
else
|
|
output="{{OUTPUT}}"
|
|
fi
|
|
./build/nix-irc "{{FILE}}" "$output"
|
|
|
|
# Load plugin and evaluate Nix expression
|
|
eval FILE:
|
|
nix-instantiate --plugin-files ./build/nix-ir-plugin.so --eval --strict "{{FILE}}"
|
|
|
|
# Format C++ code with clang-format
|
|
format:
|
|
find src tests -name '*.cpp' -o -name '*.h' | xargs clang-format -i
|
|
|
|
# Run clang-tidy on source files
|
|
lint:
|
|
find src -name '*.cpp' | xargs clang-tidy --fix
|
|
|
|
# Show project statistics
|
|
stats:
|
|
@echo "Lines of code:"
|
|
@find src -name '*.cpp' -o -name '*.h' | xargs wc -l | tail -1
|
|
@echo ""
|
|
@echo "Test files:"
|
|
@find tests/fixtures -name '*.nix' | wc -l
|
|
@echo ""
|
|
@echo "Build status:"
|
|
@ls -lh build/nix-irc build/nix-ir-plugin.so build/regression_test 2>/dev/null || echo "Not built"
|
|
|
|
# Run a quick smoke test
|
|
smoke:
|
|
./build/nix-irc tests/fixtures/simple.nix /tmp/smoke.nixir
|
|
nix-instantiate --plugin-files ./build/nix-ir-plugin.so --eval tests/integration/simple_eval.nix
|
|
|
|
# Generate IR from a Nix file and inspect it
|
|
inspect FILE:
|
|
./build/nix-irc "{{FILE}}" /tmp/inspect.nixir
|
|
@echo "IR bundle size:"
|
|
@ls -lh /tmp/inspect.nixir | awk '{print $5}'
|
|
@echo "Magic number:"
|
|
@xxd -l 4 /tmp/inspect.nixir
|
|
|
|
# Watch mode, rebuild on file changes
|
|
watch:
|
|
find src tests -name '*.cpp' -o -name '*.h' | entr -c just build test-unit
|