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.
Since commit 8e6c741a4b ("explain" debug prints just before each command
is run, 2022-01-06, v1.13.0~1^2~56^2~2) the "loading dyndep file '...'"
explanation has not been printed. Instead the explanation has been
recorded for the dyndep file's node *after* it has been brought
up-to-date, and therefore never printed.
This explanation is generated just before its operation runs, so we can
print it immediately instead of buffering it.
Fixes: #2758
This was regressed by commit 8e6c741a4b ("explain" debug prints just
before each command is run, 2022-01-06, v1.13.0~1^2~56^2~2). Add a
test demonstrating the problems, called out by FIXME comments.
Issue: #2758, #2759
This fixes ##2681, a regression that was introduced during PR #2540
where Ninja would return a status code of 0 when interrupted.
The problem comes from RealCommandRunner::WaitForCommand() not
updating the result->status field in case of interrupt being
detected in Subprocess::DoWork().
This fixes the issue and adds a regression test for it.
+ Fix the CommandRunner::Result constructor to ensure that
the `status` field is always initialized, even though it
should now always be replaced at the end of a command.
Targets which use multiple input files only have their first input
file show up in the compilation database. This can cause issues with
tools that build a list of files to inspect from the compilation
database. For example, when using the Swift programming language
together with the SourceKit-LSP language server, only one source file
from each Swift module gets processed correctly by the language server
using the current compilation database output from Ninja, because Swift
modules are compiled with one compiler invocation and therefore one
Ninja target for the whole module.
This changes the compilation database formatter to emit one entry
for each input file of a target instead of just the first input
file, which makes tools able to pick up all the input files used in
the build.
Fixes#1590.
See also https://github.com/mesonbuild/meson/pull/14264.
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>
PR #2487 introduced a regression, where a completed command without
an output would force a newline, preventing the next status update
to appear on the same line in smart terminals.
This fixes the issue by adding the missing `!outputs.empty()`
condition + adding a proper regression test to catch future
breaks.
Fixed: #2499
For most actions, the depfile will be in the same directory as one
of its outputs, and their parent directory will be created by Ninja
before running the command. However, this is not always the case.
In particular, the GN build tool is changing its Ninja build plan
generation logic, switching from using stamp files to phony targets,
after issue #478 was fixed in Ninja. For additionnal context
see https://gn-review.googlesource.com/c/gn/+/11380.
The newly generated build plans trigger this condition more frequently,
which results in flaky build failures for large GN-based projects such
as Fuchsia.
This patch ensures the depfile's parent directory is always created
before the command is launched to get rid of the issue entirely.
Add new options to the `inputs` tool in order to change
the format of its output:
- `--no-shell-escape` to avoid shell-escaping the results.
- `--dependency-order` to return results in dependency order,
instead of sorting them alphabetically.
- `--print0` to use \0 as the list separator in the list,
useful to process the target paths with `xargs -0` and
similar tools.
This uses the InputsCollector class introduced in the
previous patch to implement the tool properly. Results
are still shell-escaped and sorted alphabetically.
Fixed#2482
Before #2067, ninja would have printed this instead for the second
`ninja` invocation:
ninja explain: output .FORCE of phony edge with no inputs doesn't exist
ninja explain: .FORCE is dirty
ninja explain: input is dirty
ninja explain: mid is dirty
[1/3] [ -e input ] || touch input
Do not use os.chdir() to change the current directory inside
the run() function, as doing this prevents the temporary directory
from being removed.
Moreover, this breaks pytest invocations when adding new regression
test scripts in this directory (as done in other forks).
+ Use dict.pop() to undefine environment variables in `default_env`
dictionary.
This fixes#1966 by removing the variable name from the
lookups stack once the recursive lookup call has been performed.
Without this, any previously expanded variable could no longer
be referenced in the command, as Ninja would (incorrectly)
complain about a cyclical dependency.
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.
See comment in #1899. Also adds two tests to output_test.py which check
this behaviour by relying on Python's suprocess.check_output not piping
stderr.