Artifact fe656958b1b19d39cd0a458d5027f42dd391e51969597904595a523d20b2b2b2:
- File
src/main.c
— part of check-in
[6d70dcc76a]
at
2026-11-12 19:36:41
on branch trunk
— Phase 1: the config parser, the no-change run and the speed bench
suit check parses suit.conf strictly and prints a canonical dump. Any unknown kind or key, duplicate, cycle or dangling name rejects the whole file with its line number.
suit run compares a stamp against the files it names and exits without writing, allocating or printing when nothing changed.
suit bench times suit run against an empty program built the same way and against /usr/bin/true, interleaved, and fails the build when the no-change run costs more than 1 ms over the empty program or 1 MiB more memory. It measured 0.65 to 0.94 ms over, quiet and under load. A system binary starts 0.6 to 1.5 ms faster than any built binary on macOS, so it is shown for information and is not the baseline.
94 unit checks, 100 shell cases and a libFuzzer target for the parser. (user: dmestas, size: 1055) [annotate] [blame] [check-ins using]
#include "bench.h" #include "conf.h" #include "stamp.h" #include <stdio.h> #include <string.h> static Conf conf; static int usage(void) { fputs("usage: suit check FILE\n" " suit stamp PATH...\n" " suit run\n" " suit bench [-n N] [-e EMPTY_PROGRAM]\n", stderr); return 2; } static int cmd_check(const char *path) { ConfError err; if (!conf_load(&conf, path, &err)) { fprintf(stderr, "%s:%d: %s\n", path, err.line, err.msg); return 2; } conf_dump(&conf, stdout); return fflush(stdout) == 0 ? 0 : 1; } int main(int argc, char **argv) { if (argc < 2) return usage(); const char *cmd = argv[1]; if (strcmp(cmd, "run") == 0) return argc == 2 ? stamp_run() : usage(); if (strcmp(cmd, "check") == 0) return argc == 3 ? cmd_check(argv[2]) : usage(); if (strcmp(cmd, "stamp") == 0) return argc >= 3 ? stamp_write(argc - 2, argv + 2) : usage(); if (strcmp(cmd, "bench") == 0) return bench_main(argc - 2, argv + 2); return usage(); }