From 7584eb76e125913b824bc6807c52f04e4d716bf5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 23 Feb 2026 02:25:06 +0300 Subject: [PATCH] meta: switch to justfile for task organization Signed-off-by: NotAShelf Change-Id: Ib4000ab597f94b2dd3dccf1e31fce3a76a6a6964 --- CMakeLists.txt | 1 + flake.nix | 2 ++ justfile | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 justfile diff --git a/CMakeLists.txt b/CMakeLists.txt index edb503c..10ed5a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ install(TARGETS nix-ir-plugin LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/n add_executable(regression_test tests/regression_test.cpp src/irc/serializer.cpp + src/irc/parser.cpp ) target_include_directories(regression_test PRIVATE diff --git a/flake.nix b/flake.nix index a127312..4f98a7f 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,8 @@ ninja bear clang-tools + just + entr ]; env.NIX_PLUGINABI = "0.2"; diff --git a/justfile b/justfile new file mode 100644 index 0000000..9ca92f8 --- /dev/null +++ b/justfile @@ -0,0 +1,98 @@ +# 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