summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
Commit message (Collapse)AuthorAgeFilesLines
* Don't disable stdout buffering on WindowsBruce Dawson2022-02-171-11/+0
| | | | | | | | | | | | | | | Long ago ninja disabled stdout buffering. Since then much has changed and this appears to no longer be needed, while also being actively harmful. Disabling of stdout buffering is not needed because printing is done (in LinePrinter::Print) either with WriteConsoleOutput (which is unaffected by stdout buffering) or by printf followed by fflush. Meanwhile, the unbuffered printing in the printf case causes dramatic slowdowns which are most visible in dry-run builds, as documented in issue #2084. This fixes issue #2084, finishing off the incomplete buffering fix done in pull request #2031.
* Merge pull request #1730 from naarcini/masterJan Niklas Hasse2022-02-021-1/+33
|\ | | | | Add 'inputs' tool to print out all inputs for a set of targets
| * Add 'inputs' tool to print out all inputs for a set of targetsNicolas Arciniega2020-02-031-1/+33
| |
* | Merge pull request #2055 from swills/still-dirty-timeJan Niklas Hasse2022-01-281-1/+1
|\ \ | | | | | | Suggest possible cause for hitting cycle limit
| * | Suggest possible cause for hitting cycle limitSteve Wills2021-11-231-1/+1
| | |
* | | Add validation nodes to ninjaColin Cross2021-10-121-0/+18
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Disable stdout buffering in real_mainBruce Dawson2021-10-011-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | Previously stdout buffering was disabled in the LinePrinter constructor. This worked for a long time but ultimately this side-effect caused a performance bug (issue #2018) in tools such as -t deps. Moving the disabling of buffering into real_main and only disabling buffering when a tool is not used makes the desired semantics clearer and restores the lost performance. This fixes issue #2018. It has been tested and a 10x speedup was seen relative to the tip-of-tree version.
* | Merge pull request #1347 from tzik/revdepJan Niklas Hasse2021-08-121-8/+13
|\ \ | | | | | | Look up header dependencies on the first-output build
| * | Look up header dependencies on the first-output buildtzik2017-10-251-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ninja has special syntax to specify the first output of the given node. E.g. it builds foo.o for foo.cc^. However, it doesn't work for headers, as headers usually doesn't appear in the regular dependency tree. After this change, Ninja looks up header dependencies from .ninja_deps to pick up a build target, so that it builds foo.o for foo.h^.
* | | compdb: escape control characters in JSON stringsLi-Yu Yu2021-07-221-13/+5
| | |
* | | util: Remove unnecessary CanonicalizePath error handlingBrad King2021-06-041-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 86f606fe (Remove path component limit from input of CanonicalizePath in windows, 2017-08-30, v1.8.0^2~2^2), the only failure case in the `CanonicalizePath` implementation is the "empty path" error. All call sites have been updated to ensure `CanonicalizePath` is never called with an empty path. Remove error handling from the signature to simplify call sites.
* | | Add explicit "empty path" errors before calling CanonicalizePathBrad King2021-06-041-0/+8
| | | | | | | | | | | | | | | | | | Update call sites that might have empty paths to explicitly check for them before calling CanonicalizePath. Note that the depfile parser ensures all parsed outs and deps are non-empty.
* | | Add jhasse's suggestion to suppress output on '--quiet'.Eli Ribble2021-05-061-1/+1
| | | | | | | | | | | | | | | This just ensures that we also don't get the "Entering directory..." message when the new '--quiet' flag is added.
* | | Update help description for --quietHenner Zeller2021-05-061-1/+1
| | | | | | | | | | | | Signed-off-by: Henner Zeller <h.zeller@acm.org>
* | | Add --quiet option that suppresses status updates.Henner Zeller2021-05-061-1/+6
| | | | | | | | | | | | | | | | | | Refined pull request after discussion in #1816 Signed-off-by: Henner Zeller <h.zeller@acm.org>
* | | Fix misleading usage of return type of Open*LogJan Niklas Hasse2021-04-091-4/+4
| | | | | | | | | | | | | | | In an earlier version of 791c887e22046e5e7a2d05ecb5ff27701d56895d those functions returned LoadStatus, too, but it was changed back to bool.
* | | Remove `-w dupbuild` from error message and help outputJan Niklas Hasse2021-03-201-1/+0
| | | | | | | | | | | | This is step 4 on #931.
* | | wincodepage: minimize to indicate UTF-8 or notBrad King2021-03-011-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Add tool to print code page information on WindowsBrad King2021-02-261-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge pull request #1331 from ilor/missingdeps3Jan Niklas Hasse2021-02-231-1/+26
|\ \ \ | | | | | | | | missingdeps tool, take 2
| * | | Add a -t missingdeps tool to detect some classes of build flakesTomasz Śniatowski2021-02-221-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Put builder output through status interfaceColin Cross2021-02-051-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | Send all output after manifest parsing is finished to the Status interface, so that when status frontends are added they can handle build messages.
* | | | Turn BuildStatus into an interfaceColin Cross2020-12-181-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | Make BuildStatus an abstract interface, and move the current implementation to StatusPrinter, to make way for a serialized Status output.
* | | | Move edge time from Status to BuilderColin Cross2020-12-181-3/+8
|/ / / | | | | | | | | | | | | | | | | | | | | | 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.
* | | Add unique IDs to edgesColin Cross2020-10-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Edges are nominally ordered by order in the build manifest, but in fact are ordered by memory address. In most cases the memory address will be monontonically increasing. Since serialized build output will need unique IDs, add a monotonically increasing ID to edges, and use that for sorting instead of memory address.
* | | Add 'using namespace std;' to all cc files to prepare for removing it from ↵Michael Jones2020-09-301-0/+2
| | | | | | | | | | | | header files
* | | Fix typosDimitris Apostolou2020-07-071-2/+2
| |/ |/|
* | restat: No need for loading build.ninjaJan Niklas Hasse2020-01-161-1/+1
| | | | | | | | | | This results in a huge speed up for large builds (e.g. Chromium). See #1718.
* | restat: Accept list of outputs to restat (none means all)Jan Niklas Hasse2020-01-161-1/+19
| | | | | | | | | | This will become handy when the generator only wants to restat the build.ninja entry in the log. See #1718.
* | Merge branch 'master' into clean_dead_outputsJan Niklas Hasse2020-01-041-42/+100
|\ \
| * \ Merge pull request #1534 from mathstuf/remove-depslog-restrictionJan Niklas Hasse2020-01-041-15/+3
| |\ \ | | | | | | | | manifest_parser: remove multi-output depslog restriction
| | * | depfile_parser: remove restriction on multiple outputsBen Boeckel2019-11-201-15/+3
| | | |
| * | | Merge pull request #1685 from jhasse/restatJan Niklas Hasse2020-01-041-8/+60
| |\ \ \ | | | | | | | | | | Add restat tool which recalculates all mtimes in the build log
| | * | | Ignore nonexistent .ninja_log/.ninja_deps for restat and recompactJan Niklas Hasse2019-12-231-10/+24
| | | | |
| | * | | Add restat tool which recalculates all mtimes in the build logJan Niklas Hasse2019-12-231-0/+38
| | |/ /
| * | | Fix logic-error in IsPathDead, see #1432Jan Niklas Hasse2019-12-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The conditional `(!n || !n->in_edge()) && ` was moved up. It now needs to be inversed because there's a `return false;`. See https://github.com/ninja-build/ninja/commit/3beebde51a2089ecb01820f1428efe0263deaeea#diff-78294872cbf9d32f4f972288561fa718R146 and https://github.com/ninja-build/ninja/pull/1432#discussion_r321827528
| * | | Fix error handling for getcwdAndreas Kempf2019-12-271-2/+4
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quoting from the Linux man page for errno, "The value in errno is significant only when the return value of the call indicated an error (i.e., -1 from most system calls; -1 or NULL from most library functions); a function that succeeds is allowed to change errno. The value of errno is never set to zero by any system call or library function." Successful calls to getcwd are allowed to set errno causing the compilation database not to be written. Spurious failures of this nature were observed on AIX. Adjust the error handling for getcwd so that errno is only checked if the call returned NULL.
| * | compdb: Dump every rule without any arguments, fix #1377Jan Niklas Hasse2019-08-021-16/+28
| | |
| * | Improve const-correctness in compdb related methodsJan Niklas Hasse2019-08-021-1/+2
| | |
* | | Adding a way to clean dead build artifacts that have an entry in the build log,ikifof2019-05-251-3/+8
|/ / | | | | | | | | | | | | | | | | | | | | | | but are no longer produced by the current manifest. For now adding a dedicated "-t cleandead" option, since it should be run after reading the log; ideally it should be part of the build config and done before to start looking for dirty targets so that an incremental build would produce the same end result as a clean build from scratch. But since I am not 100% sure to understand the comment in the NinjaMain::isPathDead(), I opted to make it a tool for now to avoid impacting users who want to keep those files. The option name "cleandead" was selected insteadof something like "reap" to keep the "clean" prefix.
* | Resurrect the 'rules' tool.Nicolas Despres2019-05-091-0/+52
| | | | | | | | | | | | | | | | | | This tool is useful for writing shell completion script for tools expecting a rule name as argument. The tool was dropped by 34b46f28c. Fix #1024.
* | query: load dyndep files for queried edgesBrad King2019-04-181-0/+7
| |
* | graph: load dyndep filesBrad King2019-04-181-1/+1
| | | | | | | | | | | | Teach the `-t graph` tool to load dyndep files because they are part of the build graph. Issue a warning when the dyndep file cannot be loaded cleanly. This will help users visualize the complete build graph.
* | clean: remove unnecessary Cleaner constructor variantBrad King2019-04-181-1/+1
| | | | | | | | | | | | | | | | `Cleaner` provides two constructors that are the same except that one constructs a "real" disk interface internally and the other takes a caller-provided disk interface. A real disk interface is already available at the only call site for the former constructor. Use it directly and drop the unnecessary constructor variant.
* | Restore depfile toleration of multiple output paths on distinct linesBrad King2018-11-191-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to introduction of depfile parser handling of multiple rules, ninja silently accepted a depfile of the form: out: in1 in2 in3 other: otherIn1 otherIn2 otherIn3 and incorrectly treated `other` and `otherIn*` as additional inputs to `out`. Now we prefer to reject this just as we already do for a depfile specifying multiple outputs on one line. However, this can break existing cases where such a depfile was silently tolerated. Add a `-w depfilemulti={err,warn}` option to control this behavior, and make it just a warning by default.
* | Fit --help output into 80 columns and move verbose up, fix #1500Jan Niklas Hasse2018-11-161-3/+3
| |
* | Explain why there's no browse tool, fix #1478Jan Niklas Hasse2018-11-141-3/+6
| |
* | Make -j 0 run unlimited parallel builds, fix #1309Martell Malone2018-11-141-3/+6
| |
* | Add --verbose as an alternative spelling for -v, fix #1310Jan Niklas Hasse2018-11-131-1/+2
| |
* | Misc typo fixes by https://github.com/codespell-project/codespell/Mo Zhou2018-09-061-1/+1
| |