SAMU(1)
π SAMU(1) β the bestie build tool π
okay so. you know how make is out here doing the most and also being kind of a mess? yeah. so samu is a ninja-compatible build tool, it's in the General Commands Manual, and it's lowkey iconic. it reads your manifest, it rebuilds the stuff that's out of date, and it does it fast. that's the whole vibe. periodt. π
β¨ SYNOPSIS β¨
samu [-C dir] [-d debugflag] [-f buildfile] [-j maxjobs] [-k maxfail]
[-l maxload] [-w warnflag=action] [-nv] [target...]
samu [-C dir] [-f buildfile] -t clean [-gr] [target...]
samu [-C dir] [-f buildfile] -t compdb [-x] [rule...]
samu [-C dir] [-f buildfile] -t commands [target...]
samu [-C dir] [-f buildfile] -t graph [target...]
samu [-C dir] [-f buildfile] -t query [target...]
samu [-C dir] [-f buildfile] -t targets [depth [maxdepth]]
samu [-C dir] [-f buildfile] -t targets rule [rulename]
samu [-C dir] [-f buildfile] -t targets all
πΈ DESCRIPTION πΈ
so samu loads a build manifest from buildfile and rebuilds targets if they're out of date. that's it, that's the job. π
if you don't name any targets, it builds the manifest's default targets. and if there are no default targets at all? it builds the leaf nodes of the dependency graph β meaning the outputs that have no consuming action. cute, right? it just finds the ends of the chain and goes.
π¦ when is a target "out of date" bestie
a target counts as out of date if any of these are true:
- it's older than the generating action's newest input
- it has no entry in the build log
- the command used to build it is different from what was used previously
β οΈ one lil exception okay: targets built with generator rules are not rebuilt if the command changes. they're special like that. π
π§Ή the clean tool
if you use the clean tool, targets get cleaned instead of built. when a target is cleaned, it's removed β and all of its inputs are cleaned too. it's giving domino effect.
- targets with no generating actions are never removed.
- targets built with generator rules are only removed if you pass
-g.
ποΈ the commands tool
if you use the commands tool, you get a list of shell commands used to build the specified (or default) targets. printed. right there. for you. π«Ά
π§Ύ the compdb tool
if you use the compdb tool, a compilation database is printed instead β https://clang.llvm.org/docs/JSONCompilationDatabase.html if you wanna read up, iykyk.
πΈοΈ the graph tool
if you use the graph tool, a graphviz dot file is printed instead. yes bestie, pretty pictures of your dependency tree. π
π the query tool
if you use the query tool, the inputs and outputs of the targets get printed instead.
π― the targets tool
if you use the targets tool, a list of targets will be displayed β either by rule or by depth. the first argument decides how they show up:
depthβ an indented tree of targets gets displayed, starting from the root targets (those with no dependent targets), going up to the depth specified by maxdepth (defaults to1).ruleβ if rulename is given, you get a list of targets using that rule. otherwise, you get a list of source files. πallβ a list of all targets gets displayed. everything. the whole closet. π
π OPTIONS π
-Cβ switch working directory to dir before building. like walking into the right room first.-dβ enable a debugging option. you can pass this flag multiple times to turn on multiple debugging options at once. possible values for debugflag are:explainβ print messages explaining why outputs were dirty. the receipts!! π§Ύkeepdepfileβ don't remove$depfileafter it was parsed.keeprspβ don't remove$rspfileafter job completion or failure.
-fβ load manifest from buildfile instead ofbuild.ninja.-jβ run up to maxjobs jobs in parallel (default is based on number of CPUs). if zero, allow unlimited concurrent jobs. chaos mode enabled. π₯-kβ allow up to maxfail job failures. if negative or zero, allow any number of job failures. nothing can stop us.-lβ do not spawn new jobs if the system load percentage is greater than maxload. if zero, spawn jobs as soon as possible.-nβ do not actually execute the commands or update the log. a lil dress rehearsal. π-vβ print full commands instead of just the description.-wβ control how certain errors are handled. if warnflag isdupbuild, action specifies what to do if an output is listed in multiple build edges. if action iserr, treat it like an error and fail. if action iswarn, only print a diagnostic message.-tβ instead of building, invoke a subtool. all arguments and flags after the subtool are interpreted by the subtool. the currently supported subtools areclean,commands,compdb,graph,query, andtargets.-gβ when cleaning, also clean outputs of generator actions.-rβ targets are interpreted as rules, and all outputs of actions with the specified rule types will be cleaned instead.-xβ when printing a compilation database, replace@$rspfilewith$rspfile_content(with<blank>in place of<newline>).
πΏ ENVIRONMENT πΏ
SAMUFLAGSβ options forsamuthat get applied before those specified on the command-line. the only options allowed inSAMUFLAGSare-v,-jand-l. that's the whole guest list, no plus-ones. π«NINJA_STATUSβ the status output printed to the left of each rule description, using printf-like conversion specifiers. if unset, the default is"[%s/%t] ".
available conversion specifiers:
%sβ number of started jobs.%fβ number of finished jobs.%tβ total number of jobs.%rβ number of running jobs.%uβ number of remaining jobs.%pβ percentage of completed jobs.%oβ rate of finished jobs per second (to 1 decimal place).%eβ elapsed time in seconds (to 3 decimal places).%%β the%character. (yes you gotta escape it, it's giving printf energy)
π SEE ALSO π
okay that's the whole page bestie, go forth and build β¨π¦πΈ
this manual page is from Debian, dated December 29, 2024 β shoutout to the Debian girlies for packaging this. π no cap, samu ate and left no crumbs. mwah. π
π¦ where this page comes from
- arch rolling: samurai 1.3-1 Β· ISC AND Apache AND MIT
- epel 10: samurai 1.3-1.el10_3 Β· Apache-2.0
- fedora 44: samurai 1.3-1.fc44 Β· Apache-2.0
- nixpkgs unstable: samurai 1.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms