https://github.com/michaelforney/samurai
ninja-compatible build tool written in C
https://github.com/michaelforney/samurai
build ninja
Last synced: about 1 year ago
JSON representation
ninja-compatible build tool written in C
- Host: GitHub
- URL: https://github.com/michaelforney/samurai
- Owner: michaelforney
- License: other
- Created: 2017-07-15T23:17:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-03T20:27:58.000Z (over 1 year ago)
- Last Synced: 2025-04-06T09:01:27.362Z (about 1 year ago)
- Topics: build, ninja
- Language: C
- Homepage:
- Size: 267 KB
- Stars: 877
- Watchers: 28
- Forks: 52
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# samurai
[](https://builds.sr.ht/~mcf/samurai)
[](https://github.com/michaelforney/samurai/actions)
samurai is a ninja-compatible build tool written in C99 with a focus on
simplicity, speed, and portability.
## Status
samurai implements the ninja build language through version 1.9.0 except
for MSVC dependency handling (`deps = msvc`). It uses the same format
for `.ninja_log` and `.ninja_deps` as ninja, currently version 5 and 4
respectively.
It is feature-complete and supports most of the same options as ninja.
## Requirements
samurai requires various POSIX.1-2008 interfaces.
Scheduling jobs based on load average requires the non-standard
`getloadavg` function. This feature can be enabled by defining
`HAVE_GETLOADAVG` in your `CFLAGS`, along with any other necessary
definitions for your platform.
## Differences from ninja
samurai tries to match ninja behavior as much as possible, but there
are several cases where it is slightly different:
- samurai uses the [variable lookup order] documented in the ninja manual,
while ninja has a quirk ([ninja-build/ninja#1516]) that if the build
edge has no variable bindings, the variable is looked up in file scope
*before* the rule-level variables.
- samurai schedules jobs using a stack, so the last scheduled job is
the first to execute, while ninja schedules jobs based on the pointer
value of the edge structure (they are stored in a `std::set`),
so the first to execute depends on the address returned by `malloc`.
This may result in build failures due to insufficiently specified
dependencies in the project's build system.
- samurai does not post-process the job output in any way, so if it
includes escape sequences they will be preserved, while ninja strips
escape sequences if standard output is not a terminal. Some build
systems, like meson, force color output from gcc by default using
`-fdiagnostics-color=always`, so if you plan to save the output to a
log, you should pass `-Db_colorout=auto` to meson.
- samurai follows the [POSIX Utility Syntax Guidelines], in particular
guideline 9, so it requires that any command-line options precede
the operands. It does not do GNU-style argument permutation.
[ninja-build/ninja#1516]: https://github.com/ninja-build/ninja/issues/1516
[variable lookup order]: https://ninja-build.org/manual.html#ref_scope
[POSIX Utility Syntax Guidelines]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02