168 Commits

Author SHA1 Message Date
Jan Niklas Hasse
0f55557728 Add --status flag with Ninja-style variable expansion
Introduces a `--status FMT` command-line flag that configures the
progress status using Ninja's regular `$var`/`${var}` syntax with
descriptive variable names ($finished, $total, $progress, $elapsed,
etc.) instead of the `%`-escapes used by `NINJA_STATUS`. When passed,
it takes precedence over `NINJA_STATUS`; the env-var path is left
unchanged for backwards compatibility.
2026-05-13 21:06:00 +02:00
Jan Niklas Hasse
b7b5d3183a Merge pull request #2744 from braydenkrus/patch-1
Document `pool` option under "Rule Variables"
2026-05-09 00:00:58 +02:00
Brad King
1cda4274d9 Document more precisely how a dyndep file may affect the build graph
Only the part of the graph that depends on the edges with a dyndep
binding may be affected by content loaded from the dyndep file.
Otherwise the dyndep file could change the build graph in a way that
causes already up-to-date build statements to become out-of-date.
2026-03-24 16:59:22 -04:00
Brayden Krus
389d044d93 Document pool option under "Rule Variables"
In response to Issue #2732.
2026-03-18 10:55:52 -04:00
Jan Niklas Hasse
3fdd1796b9 restat tool: Add --builddir=DIR; might be needed because manifest won't be parsed 2026-02-17 21:33:45 +01:00
Jan Niklas Hasse
47c046750c Merge pull request #2660 from jyn514/doc
Document some additional `-t` tool flags
2026-01-20 09:12:59 +01:00
Ildus Kurbangaliev
85c1564114 Revert "Add \r\n on Windows"
This reverts commit 6c6587b64b.
2025-12-28 12:03:52 +01:00
Ildus Kurbangaliev
50db8fd1c3 Fix formatting and more precise doc 2025-09-26 15:15:26 +02:00
Ildus Kurbangaliev
da390ef9d5 Improve docs and use pointer in CheckNinjaVersion 2025-09-26 14:03:10 +02:00
Ildus Kurbangaliev
6c6587b64b Add '
' on Windows for '$^'
2025-09-25 22:12:16 +02:00
Ildus
d676f9eaa5 Support $^ escape sequence for newlines. 2025-09-25 21:56:31 +02:00
jyn
9746811d26 Document some additional -t tool flags 2025-08-19 12:43:15 -04:00
Christopher Warrington
e4dfed9e9e Correct GNU Make jobserver link
It has one too many instances of "https://" in it.
2025-08-18 14:18:38 -07:00
Jan Niklas Hasse
896f6bf05a Remove incorrect paragraph about jobserver on Posix 2025-05-15 20:59:37 +02:00
David 'Digit' Turner
d4a4f3694c Support jobserver client mode automatically.
Detect that the environment variable MAKEFLAGS specifies a
jobserver pool to use, and automatically use it to control
build parallelism when this is the case.

NOTE: On Posix, the pipe-based protocol is not supported and
will be detected. Ninja will print a warning on startup then
ignore the content of MAKEFLAGS (there is a regression test
for this).

This is disabled is `--dry-run` or an explicit `-j<COUNT>`
is passed on the command-line. Note that the `-l` option
used to limit dispatch based on the overall load factor
will still be in effect if used.

+ Use default member initialization for BuildConfig struct.

+ Add a new regression test suite that uses the
  misc/jobserver_pool.py script that was introduced in
  a previous commit, to verify that everything works
  properly.
2025-04-22 14:14:45 +02:00
Alexander Krabler
19c0e6a055 Remove superfluos character at order-only dependencies 2025-04-07 21:29:04 +02:00
Fredrik Andersson
beabef0987 Add multi-inputs tool
The 'multi-inputs' option will list all <target> + <inputs> for
the given targets.

Run:
ninja -t multi-inputs <target1> <target2> <target3>

Ninja will then output:
<target1> <input_x>
<target1> <input_y>
<target2> <input_x>
<target2> <input_z>
<target3> <input_y>
2024-11-22 13:28:14 +01:00
Jan Niklas Hasse
a3fda2b06c Merge pull request #2497 from JamesWidman/compdb-target
Introduce a new tool: `ninja -t compdb-targets`
2024-11-12 17:25:13 +01:00
James Widman
b785947b1f Fix display of labels in a [horizontal] list
The introduction of the entry for `compdb-targets` in the `[horizontal]`
labeled list in doc/manual.asciidoc revealed some display issues in the
left column:

First, the web browser would insert a line break in the middle of the
label `compdb-targets`, so that it looked like this:

       compdb-
       targets

We fix this by applying the `white-space: nowrap` attribute to the left
column.

After this is fixed, we see practically no space between the end of the
longest label and the beginning of the text in the second column; we fix
this with the `padding-right` attribute.

Finally, we align all labels to the right side of the column so that
there is a consistent amount of horizontal space between the end of each
label and the beginning of the text in the second column.
2024-10-13 01:57:02 -07:00
James Widman
4e4ec4c8ab Introduce new tool: -t compdb-targets
Fixes #1544

Co-authored-by: Linkun Chen <lkchen@google.com>
Co-authored-by: csmoe <csmoe@msn.com>
Co-authored-by: James Widman <james.widman@gmail.com>
2024-10-13 01:31:01 -07:00
spaette
a15549e63d typo 2024-10-03 15:00:42 -05:00
Martin Hundebøll
2d17936e9b codespell: fix taked => taken, and ignore false positives 2024-05-27 09:58:37 +02:00
Jan Niklas Hasse
b914a67b7c Remove trailing whitespace 2024-04-27 15:49:40 +02:00
Jan Niklas Hasse
1e6b5817db Update documentation for %p, fix #1145
24694d95f5
2024-04-11 19:52:44 +02:00
Jan Niklas Hasse
8d47b88d74 Merge pull request #1963 from LebedevRI/reliable-eta
Reliable ETA and progress percentage.
2024-03-16 13:08:42 +01:00
Cole Faust
e40ed8e8fc Add a dark mode to the docs 2023-12-31 14:40:32 -08:00
Roman Lebedev
44a402f9c4 Reliable ETA and progress percentage.
This has been bugging me for *years*. :)
Count of finished edges isn't a great statistic, it isn't
really obvious if LLVM will take 8 minues to build, or 10 minutes.

But, it's actually pretty straight-forward to get some
more useful information. We already know how much time each edge
has taken, so we could just do the dumb thing, and assume that
every edge in the plan takes the same amount of time.

Or, we can do better. `.ninja_log` already contains
the historical data on how long each edge took to produce it's outs,
so we simply need to ensure that we populate edges with that info,
and then we can greatly improve our predictions.
The math is pretty simple i think.

This is largely a port of a similar change i did to LLVM LIT:
https://reviews.llvm.org/D99073

With this, i get something quite lovely:
```
llvm-project/build-Clang12$ NINJA_STATUS="[%f/%t %p %P][%w + %W] " /repositories/ninja/build-Clang-debug/ninja opt
[288/2527  11%   4%][00:27 + 08:52] Building CXX object lib/DebugInfo/CodeView/CMakeFiles/LLVMDebugInfoCodeView.dir/AppendingTypeTableBuilder.cpp.o
```

I hope people will find this useful, and it could be merged.
2023-10-11 00:49:30 +03:00
Waleed Khan
96d408186b Fix formatting for msvc tool documentation 2023-03-31 14:02:41 -07:00
tocic
18d692c963 Fix typos in docs 2023-01-27 09:35:42 +03:00
Jan Niklas Hasse
99c1bc7442 doc: Add available since 1.11 to Validations 2022-05-15 17:52:42 +02:00
David 'Digit' Turner
988c847ee7 Make the output of ninja -t inputs deterministic
This sorts the output of `ninja -t inputs` to make it
deterministic and remove duplicates, and adds a regression
test in output_test.py

+ Ensure all inputs are listed, not only explicit ones.
+ Document the `inputs` tool in doc/manual.asciidoc.
2022-03-21 14:44:26 +01:00
David 'Digit' Turner
7923d736c1 Document the msvc tool 2022-03-11 16:22:13 +01:00
Jan Niklas Hasse
f404f0059d Merge pull request #1730 from naarcini/master
Add 'inputs' tool to print out all inputs for a set of targets
2022-02-02 19:49:17 +01:00
Jan Niklas Hasse
4a13d59820 Use correct version number for inputs tool 2021-12-21 19:35:22 +01:00
Jan Niklas Hasse
f0e734cd30 Merge pull request #1800 from colincross/validations
Add validation nodes to ninja
2021-12-21 19:32:16 +01:00
Jan Niklas Hasse
e620fed887 Merge pull request #2045 from Arthur-Milchior/rules_documentation
NF: clarify documentation's part about rules description
2021-11-11 09:53:15 +01:00
Dimitris Apostolou
112f85e153 Fix typo 2021-11-08 08:55:59 +01:00
Arthur Milchior
c7da3e64f9 NF: clarify documentation's part about rules description
The word "eventually" was quite strange here and should probably removed. I
suspect "potentially" was meant (which in French is "eventuellement", a standard
false friend). In any way, after a quick look at the source/ninja message, I
chose to even clarify this part of the doc, indicating that the `-d` option is
required here.
2021-11-07 18:00:27 +01:00
Colin Cross
04c410b15b Add validation nodes to ninja
A common problem in the Android build is inserting rules that perform
some sort of error checking that doesn't produce any artifacts needed
by the build, for example static analysis tools.  There are a few
patterns currently used, both of which have downsides.

The first is to have a rule that depends on all of the static analysis
results.  This ensures they run, but requires running static analysis
over everything, and not just the active parts of the build graph.

The second is to insert the static analysis rule into the build graph
between the artifact producing rule and anything that depends on it,
often copying the artifact as the output of the static analysis rule.
This increases the critical path of the build, often reducing
parallelism.  In the case of copying the artifact, it also wastes
disk space.

This patch adds "validation nodes" to edges in Ninja.  A build
statement can specify validation nodes using "|@" in the edge
inputs.  The validation nodes are not used as an input to the edge
(the edge can run before the validation node is ready), but are
added to the initial nodes of the build graph whenever the edge
is part of the build graph.  The edge that outputs the validation
node can depend on the output of the edge that is being validated
if desired.

Test: ninja_test
Change-Id: Ife27086c50c1b257a26509373199664680b2b247
2021-10-11 17:34:46 -07:00
Richard Geary
48ed0bb4b4 Set output mtime of phony edges to the latest inputs
This commit fixes issue #478.

Observed:
Real edges depending on a phony edge will not be marked as dirty or
rebuilt if the phony's (real) inputs are updated.

Expected:
An edge should always be rebuilt if its inputs or transitive inputs are
newer than the output's mtime.

Change:
Node::mtime_ was overloaded, 0 represented "does not exist". This change
disambiguates it by adding Node::exists_. Then to fix the observed
behaviour, Node::UpdatePhonyMtime was added to update the mtime if the
node does not exist.

Add tests BuildTest.PhonyUseCase# GraphTest.PhonyDepsMtimes.
Unit tests will also test for always-dirty behaviour if a phony rule has
no inputs.
2021-08-02 13:45:16 -07:00
Jan Niklas Hasse
ac0fe07d9e Merge pull request #1907 from aDotInTheVoid/patch-1
Clarify purpose for implicit dependencies
2021-03-05 22:51:32 +01:00
Brad King
a510f532f6 wincodepage: minimize to indicate UTF-8 or not
The ANSI code page identifier is more information than generator
programs actually need.  The encoding of `build.ninja` is always
either UTF-8 or the system-wide ANSI code page.  Reduce the output
to provide no more information than the generator programs need.

The Console code page can be obtained in other ways, so drop it.
2021-03-01 13:05:46 -05:00
Brad King
706e16bee5 Add tool to print code page information on Windows
Since commit 00459e2b (Use UTF-8 on Windows 10 Version 1903, fix #1195,
2021-02-17), `ninja` does not always expect `build.ninja` to be encoded
in the system's ANSI code page.  The expected encoding now depends on
how `ninja` is built and the version of Windows on which it is running.

Add a `-t wincodepage` tool that generators can use to ask `ninja`
what encoding it expects.

Issue: #1195
2021-02-26 10:31:27 -05:00
Brad King
212cd97679 doc: fix format of 'missingdeps' documentation
Group all the paragraphs together in the definition list entry.
2021-02-26 10:31:27 -05:00
Tomasz Śniatowski
bc69a640de Add manual entry about the missingdeps tool 2021-02-22 23:48:58 +01:00
Nixon Enraght-Moony
942a523a73 Clarify purpose for implicit dependencies 2021-01-29 18:34:58 +00:00
Dimitris Apostolou
6c5e886aac Fix typos 2020-07-07 13:00:22 +02:00
Nicolas Arciniega
b1afd603be Add 'inputs' tool to print out all inputs for a set of targets 2020-02-03 11:40:46 -08:00
Ben Boeckel
0644463f57 manual: remove "manifest" reference from the manual
Nothing else describes what a "manifest" is in user-facing docs.
2020-01-29 14:06:30 -05:00
Jan Niklas Hasse
0ccc7886fd Merge pull request #1624 from bungeman/patch-1
Recommend MD over MMD for header dependencies.
2020-01-19 13:16:06 +01:00