brewery
notashelf /
feb247f64a93c65c93a80df2d9c810bc72c71386

nixir

public

Import-resolving Nix IR plugin

Star0tarball
clone
ssh://git@git.notashelf.dev:33/notashelf/nixir.git
justfile98 lines2.5 KB
1
# Default recipe, show available commands
2
default:
3
    @just --list
4
5
# Build all targets
6
build:
7
    cmake --build build
8
9
# Clean build artifacts
10
clean:
11
    rm -rf build
12
    find tests -name '*.nixir' -delete
13
14
# Configure and build from scratch
15
rebuild: clean
16
    cmake -B build -G Ninja
17
    cmake --build build
18
19
# Run unit tests
20
test-unit:
21
    ./build/regression_test
22
23
# Run compilation tests (do all fixtures compile?)
24
test-compile:
25
    #!/usr/bin/env bash
26
    total=0
27
    success=0
28
    for f in tests/fixtures/*.nix; do
29
        total=$((total+1))
30
        if ./build/nix-irc "$f" "${f%.nix}.nixir" 2>&1 | grep -q "Done!"; then
31
            success=$((success+1))
32
        fi
33
    done
34
    echo "Compiled: $success/$total test files"
35
    [ $success -eq $total ]
36
37
# Run integration tests
38
test-integration:
39
    ./tests/integration/run.sh
40
41
# Run all tests
42
test: test-unit test-compile test-integration
43
    @echo "All tests passed"
44
45
# Run benchmarks
46
bench:
47
    ./tests/benchmark/run.sh
48
49
# Compile a single Nix file to IR
50
compile FILE OUTPUT="":
51
    #!/usr/bin/env bash
52
    if [ -z "{{OUTPUT}}" ]; then
53
        file="{{FILE}}"
54
        output="${file%.nix}.nixir"
55
    else
56
        output="{{OUTPUT}}"
57
    fi
58
    ./build/nix-irc "{{FILE}}" "$output"
59
60
# Load plugin and evaluate Nix expression
61
eval FILE:
62
    nix-instantiate --plugin-files ./build/nix-ir-plugin.so --eval --strict "{{FILE}}"
63
64
# Format C++ code with clang-format
65
format:
66
    find src tests -name '*.cpp' -o -name '*.h' | xargs clang-format -i
67
68
# Run clang-tidy on source files
69
lint:
70
    find src -name '*.cpp' | xargs clang-tidy --fix
71
72
# Show project statistics
73
stats:
74
    @echo "Lines of code:"
75
    @find src -name '*.cpp' -o -name '*.h' | xargs wc -l | tail -1
76
    @echo ""
77
    @echo "Test files:"
78
    @find tests/fixtures -name '*.nix' | wc -l
79
    @echo ""
80
    @echo "Build status:"
81
    @ls -lh build/nix-irc build/nix-ir-plugin.so build/regression_test 2>/dev/null || echo "Not built"
82
83
# Run a quick smoke test
84
smoke:
85
    ./build/nix-irc tests/fixtures/simple.nix /tmp/smoke.nixir
86
    nix-instantiate --plugin-files ./build/nix-ir-plugin.so --eval tests/integration/simple_eval.nix
87
88
# Generate IR from a Nix file and inspect it
89
inspect FILE:
90
    ./build/nix-irc "{{FILE}}" /tmp/inspect.nixir
91
    @echo "IR bundle size:"
92
    @ls -lh /tmp/inspect.nixir | awk '{print $5}'
93
    @echo "Magic number:"
94
    @xxd -l 4 /tmp/inspect.nixir
95
96
# Watch mode, rebuild on file changes
97
watch:
98
    find src tests -name '*.cpp' -o -name '*.h' | entr -c just build test-unit