michaelforney/samurai logo

michaelforney/samurai

Free

ninja-compatible build tool written in C

FreeFree tier
Type
Open Source

About michaelforney/samurai

samurai is a ninja-compatible build tool written in C99, focusing on simplicity, speed, and portability. It implements the ninja build language through version 1.9.0 (except for MSVC dependency handling) and uses the same format for .ninja_log and .ninja_deps as ninja (versions 5 and 4 respectively). It is feature-complete and supports most of the same options as ninja. samurai is built with make and requires POSIX.1-2008 interfaces. It differs from ninja in variable lookup order, job scheduling (stack-based), and does not post-process job output. It follows POSIX Utility Syntax Guidelines for command-line options.

Key Features

ninja-compatible build language support up to version 1.9.0
uses same .ninja_log and .ninja_deps formats as ninja
written in C99 for simplicity, speed, and portability
feature-complete with most ninja command-line options
built with make and requires POSIX.1-2008 interfaces
supports posix_spawn for subprocess execution, with fallback to fork/exec
optional load average-based job scheduling via getloadavg
stack-based job scheduling (last scheduled job executes first)

Pros & Cons

Pros
  • Compatible with ninja build language and log formats
  • Lightweight and fast due to C99 implementation
  • Portable across POSIX-compliant systems
  • Feature-complete with most ninja options available
  • Simpler codebase compared to ninja, making it easier to understand and modify
Cons
  • Does not support MSVC dependency handling (deps=msvc)
  • Stack-based job scheduling may expose insufficiently specified dependencies in projects
  • No output post-processing, so escape sequences are preserved in logs
  • Requires POSIX.1-2008 interfaces, limiting portability to non-POSIX systems

Best For

Building software projects that use ninja build filesReplacing ninja for faster or more portable buildsEmbedded in build systems like meson as an alternative backend

FAQ

Is samurai fully compatible with ninja?
samurai implements the ninja build language through version 1.9.0 except for MSVC dependency handling. It uses the same format for .ninja_log and .ninja_deps. There are some differences: samurai uses the documented variable lookup order while ninja has a quirk; job scheduling is stack-based; and samurai does not post-process output. These may cause build failures if dependencies are not fully specified.
What platforms does samurai support?
samurai requires POSIX.1-2008 interfaces. It uses posix_spawn for spawning subprocesses, but can fall back to fork/exec if NO_POSIX_SPAWN is defined. It can optionally use getloadavg for load-aware scheduling if available. Building may require linking with -lrt for clock_gettime on some systems.