3407 Commits

Author SHA1 Message Date
Jan Niklas Hasse
06191e72d2 Merge pull request #2796 from orgads/tests-pipe
Tests: Use context manager for Popen
2026-06-16 09:33:23 +02:00
Orgad Shaneh
d128826522 Tests: Use context manager for Popen
ResourceWarning: unclosed file <_io.BufferedReader name=3>
2026-06-14 14:45:11 +03:00
Jan Niklas Hasse
f735970600 Merge pull request #2751 from philwo/clean-multi-outputs
Fix -t clean to remove all outputs of multi-output edges
2026-06-14 13:00:03 +02:00
Jan Niklas Hasse
cdb7c8be8e Merge pull request #2763 from braydenkrus/patch-2
Check `NO_COLOR` flag before `CLICOLOR_FORCE`
2026-06-14 12:58:34 +02:00
Jan Niklas Hasse
ec91f7db71 Merge pull request #2789 from bradking/dyndep-multi
dyndep: fix handling of multiple dyndep file outputs on one edge
2026-06-14 12:54:42 +02:00
Jan Niklas Hasse
f942e6efa0 Merge pull request #2792 from orgads/bootstrap-test
Fix bootstrap with unit tests
2026-06-14 12:47:53 +02:00
Orgad Shaneh
75c3aeecbf Fix bootstrap with unit tests
bootstrap complete.  rebuilding...
ninja: error: build.ninja:220: multiple rules generate build/string_piece_util.o

Traceback (most recent call last):
  File "/home/orgads/Projects/ninja/./configure.py", line 813, in <module>
    subprocess.check_call(rebuild_args)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/subprocess.py", line 419, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['./ninja']' returned non-zero exit status 1.

Amends commit 0d3b9f16b3.
2026-06-14 00:37:06 +03:00
Brad King
dd1faec2c9 dyndep: fix handling of multiple dyndep file outputs on one edge
Normally an edge with a dyndep binding cannot be scheduled until its
dyndep file is loaded because we require the dyndep file to be an input.
However, in the case that one edge produces multiple dyndep files as
outputs, none of their dependent edges is blocked on its dyndep input
because all the dyndep files are ready.  Load all of the dyndep files
before recomputing graph readiness to avoid mistakenly scheduling an
edge that appears to be ready only because its dyndep information has
not been loaded yet.

Fixes: #2782
2026-06-09 16:06:20 -04:00
scivision
5a7fe11473 deduplicate CMake target logic (#2775)
* deduplicate getopt.c CMake CXX language

* deduplicate clang-tidy CMake script

---------

Co-authored-by: scivision <scivision@users.noreply.github.com>
2026-05-21 17:09:24 +02:00
Jan Niklas Hasse
173f464386 Merge pull request #2777 from scivision/cmake-noop
remove noop CMake policy - always new already
2026-05-21 17:05:47 +02:00
Brayden Krus
2c729faff3 Remove unnecessary NO_COLOR checks, condense checks for CLICOLOR_FORCE and FORCE_COLOR 2026-05-20 12:44:39 -04:00
scivision
0d57a90b5d remove noop CMake policy - always new already
cmake_minimum_required(VERSION 3.9) and higher already set this
policy. Further, the canonical way for projects to set individual
policies is as done for CMP0135 in this project.
2026-05-15 19:34:14 -04:00
Jan Niklas Hasse
2a8ddccd35 Merge pull request #2772 from jhasse/status-cmd-line
Add --status flag with Ninja-style variable expansion
2026-05-13 22:12:35 +02:00
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
166d02307d Merge pull request #2771 from jhasse/test_issue_2621
Make test_issue_2621 resistence against different ordering
2026-05-11 15:56:37 +02:00
Jan Niklas Hasse
28d5408982 Make test_issue_2621 resistence against different ordering
See #2621.
2026-05-09 22:00:37 +02:00
Jan Niklas Hasse
aa4c15c20f Merge pull request #2722 from elliotgoodrich/small-string-utils
Add `StringPiece::substr` method
2026-05-09 00:04:15 +02:00
Jan Niklas Hasse
68398e170d Merge pull request #2738 from ninja-build/dependabot/github_actions/actions/upload-artifact-7
Bump actions/upload-artifact from 6 to 7
2026-05-09 00:02:23 +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
Jan Niklas Hasse
02e3fd228b Merge pull request #2765 from jhasse/builddir-target
Fall back to $builddir/target when target lookup fails
2026-05-08 11:27:48 +02:00
Brayden Krus
044656d45d Add a check for NO_COLOR for UNIX that was included for Windows 2026-05-04 15:26:59 -04:00
Brayden Krus
6aa47db2a3 Use anonymous namespace for helper functions, uncomment NO_COLOR code 2026-05-04 12:21:08 -04:00
Brayden Krus
d4f11df90f Remove ansi_color, move its implementation to line_printer 2026-04-30 10:04:57 -04:00
Brayden Krus
61b029a1f3 Switch to getenv and _putenv_s for Windows ansi_color 2026-04-28 10:20:59 -04:00
Jan Niklas Hasse
f19dc4a4e2 Address comments 2026-04-28 08:11:46 +02:00
Jan Niklas Hasse
a830ae5b15 Merge pull request #2726 from jamesl-10/ninja-parallelism
Make full use of parallelism in jobserver mode
2026-04-28 07:51:10 +02:00
Brayden Krus
14fa2b7df0 Fix AnsiColorTest on Windows, remove Windows line endings 2026-04-23 10:45:25 -04:00
Brayden Krus
1e6c96fd03 Implement ansi_color 2026-04-17 15:11:06 -04:00
Brayden Krus
201c9b944a Implement ansi_color 2026-04-17 15:05:56 -04:00
Brayden Krus
27e4b60d83 Simplify helper functions 2026-04-13 08:54:39 -04:00
Nico Weber
def9560a0b Merge pull request #2764 from skeeto/fix-recovery
Fix deps log recovery failing to remove corrupt records
2026-04-12 12:45:24 -04:00
Brayden Krus
e1707b46db Add support for FORCE_COLOR. (For now) comment out NO_COLOR logic 2026-04-12 10:26:56 -04:00
Jan Niklas Hasse
cedf78d68a Merge pull request #2739 from jhasse/exclude-validation-edges-from-compdb
compdb: Exclude validation-only edges from compile_commands.json
2026-04-12 15:33:53 +02:00
Jan Niklas Hasse
93e431abd3 Fall back to $builddir/target when target lookup fails
When $builddir is set in the manifest, passing "foo" on the command
line now checks for a target named "foo" first, then falls back to
"$builddir/foo" before reporting an error.
2026-04-12 15:25:27 +02:00
Jan Niklas Hasse
947aade849 Merge pull request #2753 from bradking/explain-dyndep
Restore "explain" output when a dyndep file is loaded
2026-04-12 12:57:25 +02:00
Christopher Wellons
93d37d0cb1 Add test for deps log duplicate path record recovery.
Appends a duplicate path record to a valid deps log and verifies that
recovery truncates it away on the first load, and the second load
succeeds cleanly.
2026-04-11 20:36:04 -04:00
Christopher Wellons
3f910ed8ce Fix deps log recovery failing to remove corrupt records
In DepsLog::Load(), the file offset used for truncation-based recovery
was advanced past each record immediately after reading its bytes from
disk, but before validating the record's semantic correctness (e.g. the
path checksum or node-id range checks). When a record was structurally
complete but semantically invalid, recovery truncated the file to an
offset that included the bad record, so it was never removed.

This created an infinite cycle: every build would load the deps log, hit
the corrupt record, "recover" by truncating everything after it (but not
the record itself), then append new dependency records that would be
destroyed by the next build's recovery. The result was spurious rebuilds
on every invocation.

Move the offset update to the end of the loop body, after all validation
has passed. Now when a record fails validation, the offset still points
before it, and truncation correctly removes it.

Fixes #2703
2026-04-10 23:55:06 -04:00
Brayden Krus
54ce433b09 Clean unneeded comment 2026-04-10 15:04:21 -04:00
Brayden Krus
467483fc5c Implement helper functions for NO_COLOR and CLICOLOR_FORCE 2026-04-10 14:46:52 -04:00
Brayden Krus
0d80e3c792 Fix getenv 2026-04-04 08:52:58 -04:00
Brayden Krus
ad4a073bb5 Check NO_COLOR flag before CLICOLOR_FORCE
In response to Issue #2295 (work in progress).
2026-04-04 08:47:05 -04:00
Brad King
bbde7f3d77 Restore "explain" output when a dyndep file is loaded
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
2026-04-03 09:17:16 -04:00
Brad King
b7bbeec9ae Add test for ninja -d explain with dyndep
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
2026-04-03 09:17:16 -04:00
Brad King
1ad778bff7 Migrate explanation printing from StatusPrinter to Explanations
It makes more sense to live in the latter.

Suggested-by: David 'Digit' Turner <digit+github@google.com>
2026-04-03 09:16:40 -04:00
Brad King
2dc18d33d7 Factor out implementation of Explanations into a dedicated source 2026-04-01 14:08:58 -04:00
Jan Niklas Hasse
b90f358771 Merge pull request #2756 from bradking/graph-visit-cleanup
Improve readability of dyndep, depfile, and validation node logic
2026-03-27 16:33:14 +01:00
Brad King
f42b614284 Simplify logic that updates an edge from dyndep and depfile bindings
RecomputeNodeDirty checks both dyndep and depfile bindings when an edge
is first encountered.  Consolidate them into a single conditional block.
This simplification was missed in commit 0f0fb3275d (Teach RecomputeDirty
to load dyndep files that are ready, 2015-11-05, v1.10.0~1^2~53^2~7).
2026-03-26 17:47:16 -04:00
Jan Niklas Hasse
85f4e5e2f9 Merge pull request #2750 from lklivingstone/fix/browse-url-encode
Fix/browse url encode
2026-03-26 22:34:50 +01:00
Brad King
882af5e362 Explicitly load a node's mtime before comparing it to the deps log
Previously we were relying on RecomputeNodeDirty to do
this before LoadDeps.  Avoid this non-local assumption.

Suggestd-by: David 'Digit' Turner <digit+github@google.com>
2026-03-26 14:11:42 -04:00
lklivingstone
ec78f22847 fix URL-encode targets in -t browse
The browse tool did not correctly encode targets containing '%', causing them to be interpreted incorrectly after URL decoding.
Fix this by URL-encoding targets using urllib.parse.quote when generating links.

The import changes are compatible with both Python 2.7 and Python 3.x.

Additionally included a test to ensure complex target names are preserved exactly during parsing.

Fixes #2652
2026-03-26 21:42:45 +05:30