2758 Commits

Author SHA1 Message Date
John Drouhard
ef2ae300a8 Add some regression tests for additional test cases
These expose some behavior related to implicit deps unknown to ninja and
timestamps with generating them as part of a rule.

See discussions in #1932 and #1933.
2021-03-24 08:50:00 -05:00
John Drouhard
b51a3e83ff Revert "Change build log to always log the most recent input mtime"
This reverts commit 67fbbeeec91ec171da7d4e297b8f9b319f3424c8.

There were a few missing test cases exposed by CMake's test suite that
need slight adjustments. Better to revert the original attempt, add the
test cases, and then re-land the change with the fixes.

Fixes #1932
2021-03-24 08:49:58 -05:00
Jan Niklas Hasse
db6c4ac476 Remove -w dupbuild from error message and help output
This is step 4 on #931.
2021-03-20 15:18:53 +01:00
Jan Niklas Hasse
2b97efa4a9
Merge pull request #1753 from jdrouhard/log_input_mtime
Change build log to always log the most recent input mtime
2021-03-20 15:07:25 +01:00
John Drouhard
67fbbeeec9 Change build log to always log the most recent input mtime
If an edge's output files' mtimes are compared to the most recent
input's mtime, edges might be calculated as clean even if they are
actually dirty. While an edge's command is running its rule to produce
its outputs and an input to the edge is updated before the outputs are
written to disk, then subsequent runs will think that the outputs are
newer than the inputs, even though the inputs have actually been updated
and may be different than what were used to produce those outputs.

Ninja will now restat all inputs just prior to running an edge's command
and remember the most recent input mtime. When the command completes,
it will stat any discovered dependencies from dep files (if necessary),
recalculate the most recent input mtime, and log it to the build log
file. On subsequent runs, ninja will use this value to compare to the
edge's most recent input's mtime to determine whether the outputs are
dirty.

This extends the methodology used by restat rules to work in all cases.
Restat rules are still unique in that they will clean the edge's output
nodes recursively if the edge's command did not change the output, but
in all cases, the mtime recorded in the log file is now the most recent
input mtime. See the new tests for more clarification.
2021-03-16 18:39:31 -05: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
Jan Niklas Hasse
0c11d6e4dc
Merge pull request #1921 from bradking/windows-code-page-utf8
wincodepage: minimize to indicate UTF-8 or not
2021-03-04 18:19:13 +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
Jan Niklas Hasse
1a8015038d
Merge pull request #1918 from bradking/windows-code-page
Add tool to print code page information on Windows
2021-02-26 17:08:19 +01: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
Jan Niklas Hasse
100efbaf55
Merge pull request #1916 from scivision/check_msg
cmake: add browse check status
2021-02-23 23:01:06 +01:00
Michael Hirsch
aa9317e42f
cmake: add browse check status 2021-02-23 14:36:15 -05:00
Jan Niklas Hasse
5c93343406
Merge pull request #1331 from ilor/missingdeps3
missingdeps tool, take 2
2021-02-23 10:08:48 +01:00
Jan Niklas Hasse
ec8de9c247
Merge pull request #1915 from jhasse/windows-utf8
Use UTF-8 on Windows 10 Version 1903, fix #1195
2021-02-23 10:00:23 +01:00
Tomasz Śniatowski
6c89e596ee missingdeps: use nested maps for edge adjacency cache
In my tests, nested maps outperform a large map of pairs by 10-20% on a
sample Chromium missingdeps run, and are arguably simpler due to fewer
ifdefs needed.
2021-02-22 23:48:58 +01:00
Tomasz Śniatowski
b94a891ac9 missingdeps: add exception for targets that dep on build.ninja
A "missing dep path" to build.ninja is a false positive, skip reporting it.
2021-02-22 23:48:58 +01:00
Tomasz Śniatowski
bc69a640de Add manual entry about the missingdeps tool 2021-02-22 23:48:58 +01:00
Tomasz Śniatowski
3030254733 Add a -t missingdeps tool to detect some classes of build flakes
The tool looks for targets that depend on a generated file, but do not
properly specify a dependency on the generator. It needs to be run after
a successful build, and will list all potential flakes that may have
broken the build, but didn't due to accidental build step ordering.

The search relies on the correctness of depfile and generator output
information, but these are usually easier to get right than dependencies.

The errors found can usually be verified as actual build flakes by trying
to build the listed problematic files alone in a clean build directory.
Such builds usually fail with a compile job lacking a generated file.

There is some overlap between this tool and 'gn check', but not everyone
uses gn, not everyone using gn uses gn check, and most importantly, gn
check is more about modularity, and less about actual build-time deps
without flakes.

The tool needs to be run after a build completes and depfile data is
collected. It may take several seconds to process, up to a dozen or
two on a large, chromium-sized build.
2021-02-22 23:48:58 +01:00
Tomasz Śniatowski
d0489c3863 Refactor depfile loading in preparation for the missingdeps tool
Extract an usable helper to load depfile dependencies without adding them
to the graph.
2021-02-22 23:48:58 +01:00
Jan Niklas Hasse
c83f00c8a6
Merge pull request #1911 from eszlari/cmake-cleanup
cmake: add_compile_options / PROJECT_SOURCE_DIR
2021-02-22 23:31:17 +01:00
Jan Niklas Hasse
e77c5615b9
Merge pull request #1899 from colincross/status_for_serialize
Status changes to support frontends
2021-02-22 23:06:28 +01:00
Jan Niklas Hasse
00459e2b44 Use UTF-8 on Windows 10 Version 1903, fix #1195
Allows Ninja to use descriptions, filenames and environment variables
with characters outside of the ANSI codepage on Windows. Build manifests
are now UTF-8 by default (this change needs to be emphasized in the
release notes).

WriteConsoleOutput doesn't support UTF-8, but it's deprecated on newer
Windows 10 versions anyway (or as Microsoft likes to put it: "no longer
a part of our ecosystem roadmap"). We'll use the VT100 sequence just as
we do on Linux and macOS.

https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page
https://docs.microsoft.com/en-us/windows/console/writeconsoleoutput
https://docs.microsoft.com/de-de/windows/console/console-virtual-terminal-sequences
2021-02-17 21:59:20 +01:00
Jan Niklas Hasse
9c66e69846
Merge pull request #1913 from bradking/windows-remove
Restore toleration of missing to-be-deleted files on Windows
2021-02-12 20:28:56 +01:00
Brad King
5392e0e7bf disk_interface: Restore toleration of missing files in RemoveFile on Windows
Revise the logic from commit 2d7f7e55 (Delete read-only files on
Windows, too, 2020-12-07) to check if `GetFileAttributes` or
`DeleteFile` failed due either variant of the file/path-not-found error.

Issue: #1886
2021-02-12 11:47:12 -05:00
Brad King
c7e3e5ef45 disk_interface: Do not query bits of INVALID_FILE_ATTRIBUTES 2021-02-12 11:44:45 -05:00
Brad King
a33b813058 disk_interface: Improve wrapping of comment in RemoveFile 2021-02-12 11:44:38 -05:00
Jan Niklas Hasse
b0662970ba GitHub Actions: Test both Debug and Release with MSVC 2021-02-12 11:08:55 +01:00
Jan Niklas Hasse
a999fdb0d8
Merge pull request #1892 from jhasse/windows-readonly
Delete read-only files on Windows, too
2021-02-10 08:51:56 +01:00
Peter Eszlari
6118f74838 cmake: add_compile_options / PROJECT_SOURCE_DIR 2021-02-09 13:57:23 +01:00
Colin Cross
ad3d29fb53 Put builder output through status interface
Send all output after manifest parsing is finished to the Status
interface, so that when status frontends are added they can handle
build messages.
2021-02-05 12:08:17 -08:00
Nixon Enraght-Moony
942a523a73
Clarify purpose for implicit dependencies 2021-01-29 18:34:58 +00:00
Jan Niklas Hasse
9216c31f29
Merge pull request #1905 from korli/haiku
Add Haiku support.
2021-01-28 23:42:13 +01:00
Augustin Cavalier
fba4f7b1e5 Add Haiku support. 2021-01-28 12:32:47 +01:00
Jan Niklas Hasse
68f09b03c0
Merge pull request #1904 from remexre/master
Adds dyndep support to ninja_syntax.py.
2021-01-13 17:07:49 +01:00
Nathan Ringo
c161199646 Adds dyndep support to ninja_syntax.py. 2021-01-12 10:36:45 -08:00
Jan Niklas Hasse
fb824d27b3
Merge pull request #1674 from cameron314/bugfix/core-count
Fixed processor count detection on Windows
2021-01-01 23:01:23 +01:00
Cameron
4b07ca35eb Added preprocessor if to clarify processor count workaround code is only needed on 32-bit builds (following code review) 2020-12-31 14:45:59 -05:00
Colin Cross
589f5b2497 Turn BuildStatus into an interface
Make BuildStatus an abstract interface, and move the current
implementation to StatusPrinter, to make way for a serialized
Status output.
2020-12-18 12:38:29 -08:00
Colin Cross
045890cee3 Simplify running edges status
Store the number of running edges instead of trying to compute it
from the started and finshed edge counts, which may be different
for starting and ending status messages.  Allows removing the status
parameter to PrintStatus and the EdgeStatus enum.
2020-12-18 12:38:29 -08:00
Colin Cross
dede9ac780 Move edge time from Status to Builder
The times that end up in the build log currently originate in the
status printer, and are propagated back out to the Builder.  Move
the edge times into the Builder instead, and move the overall start
time into NinjaMain so it doesn't get reset during manifest
rebuilds.
2020-12-18 12:38:25 -08:00
Jan Niklas Hasse
68f971460b
Merge pull request #1893 from AdamKorcz/fuzz1
Added fuzzer with build script and seed
2020-12-11 12:08:22 +01:00
Jan Niklas Hasse
91f4a498b2
Merge pull request #1894 from gjasny/modern-add-test-signature
cmake: Use modern add_test signature
2020-12-11 12:06:59 +01:00
Gregor Jasny
721db105e6 cmake: Use modern add_test signature
Using this modern signature makes CMake/CTest use the effective
binary path and works also with multi-config generators which put
binaries in extra `Release` folders.
2020-12-11 08:36:26 +01:00
AdamKorcz
365a149069 Created oss-fuzz folder and moved build.sh and sample ninja file into it 2020-12-10 18:00:26 +00:00
AdamKorcz
9c801316ba Added fuzzer with build script and seed 2020-12-08 20:18:29 +00:00
Jan Niklas Hasse
2d7f7e55c0 Delete read-only files on Windows, too
Fixes main complaint of #1886.
2020-12-07 19:46:10 +01:00
Jan Niklas Hasse
58f77f972b Ignore new clangd cache directory, too 2020-12-06 15:49:29 +01:00
Jan Niklas Hasse
507db2c022
Merge pull request #1791 from neheb/exp
[clang-tidy] add explicit to single argument constructors
2020-12-06 12:15:55 +01:00
Jan Niklas Hasse
e664814b6a
Merge pull request #1790 from neheb/bool
[clang-tidy] simplify boolean expression
2020-12-06 12:15:06 +01:00