summaryrefslogtreecommitdiffstats
path: root/src/graph.h
Commit message (Collapse)AuthorAgeFilesLines
* Small constifications (#1647)Konstantin Kharlamov2019-09-191-3/+3
| | | | | | | * build: constify EdgeWanted() * build: constify a bit of CommandRunner * graph: constify functions of struct Edge Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
* Improve const-correctness in compdb related methodsJan Niklas Hasse2019-08-021-3/+3
|
* Teach DependencyScan to load a dyndep fileBrad King2019-04-181-1/+11
| | | | | Add a LoadDyndeps method to load a dyndep file and update the edges that name it in their dyndep binding.
* Add a "dyndep" reserved binding to the manifest formatBrad King2019-04-181-3/+15
| | | | | | Allow rules or build statements to specify one of the build statement inputs in a "dyndep" binding. This will later be used to load dependency information from the specified file.
* Explicitly avoid repeat deps loadingBrad King2019-04-181-1/+2
| | | | | | Track for each Edge whether depfile information has been loaded using an explicit flag. This will allow RecomputeDirty to be repeated for an edge without loading deps again.
* Restore depfile toleration of multiple output paths on distinct linesBrad King2018-11-191-4/+9
| | | | | | | | | | | | | | | | 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.
* Restore tolerance of self-referencing phony build statementsBrad King2017-09-081-0/+1
| | | | | | | | | | | | | | | | | | | | Since commit v1.8.0^2~3^2~1 (Teach RecomputeDirty to detect cycles in the build graph, 2015-11-13) we correctly reject self-referencing phony build statements like build a: phony a as cycles. Unfortunately this breaks support for CMake 2.8.12.x and 3.0.x because those versions incorrectly produce edges of this form (that we used to tolerate). In order to preserve compatibility with those CMake versions we need to restore tolerance of these edges. Add a special case to the manifest parser to filter out self-referencing inputs of phony edges of the form produced by those CMake versions. Warn by default, but add a `-w phonycycle={err,warn}` option to make it an error. Fixes: #1322
* Teach RecomputeDirty to detect cycles in the build graphBrad King2017-06-191-0/+3
| | | | | | | | | | | | | | | | RecomputeDirty is the earliest traversal of the build graph complete with depfile-loaded dependencies. Teach it to detect cycles and fail immediately. This avoids the need to tolerate cycles in RecomputeDirty only to diagnose them later. It also enables future simplification of Plan and Builder logic because they will be able to assume DAG input. When RecomputeDirty detects a cycle, reject it with an error message like that previously produced by Plan::CheckDependencyCycle. Previously we used the stat state of each node to determine whether we reached it earlier in the walk. Retain this approach for leaf nodes, but add an explicit walk state mark for each Edge so that we can have a temporary mark to aid cycle detection.
* Add infrastructure for efficient walks through the `Edge` graphBrad King2017-06-191-1/+8
| | | | Store a mark in each `Edge` to be updated as it is encountered by a walk.
* Refactor RecomputeDirty to take a node instead of an edgeBrad King2017-06-191-1/+2
| | | | | | All call sites have a node on which they call `in_edge()` to call RecomputeDirty. Simplify call sites by taking the node directly and calling `in_edge()` internally.
* Use uint64_t for slash_bits consistentlyDaniel Weber2016-09-011-4/+5
| | | | The VS compiler complained about possible loss of data (and it was right!)
* Add support for build statement implicit outputsBrad King2016-02-031-1/+11
| | | | | | | | | | | | | | | | | | Some build rules produce outputs that are not mentioned on the command line but that should be part of the build graph. Such outputs should not be named in the `$out` variable. Extend the build statement syntax to support specification of implicit outputs using the syntax `| out1 out2` after the explicit outputs and before the `:`. For example, compilation of a Fortran source file `foo.f90` that defines `MODULE FOO` may now be specified as: rule fc command = f95 -c $in -o $out build foo.o | foo.mod: fc foo.f90 The `foo.mod` file is an implicit output generated by the compiler based on the content of the source file and not mentioned on the command line.
* win: print right slashes in 'unknown target' messageNico Weber2015-07-101-1/+6
|
* Add missing member initializer in Edge constructorBrad King2015-06-161-1/+2
| | | | | | In commit v1.1.0^2~15^2~20 (stub out an api and de-constify Pool, 2012-10-03) the Edge "pool_" member was added as a raw pointer but the initializer was accidentally left out of the constructor. Add it now.
* Make failing stat() calls abort the build.Nico Weber2015-03-191-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | Fixes #830, fixes #904. In practice, this either happens with 64-bit inodes and a 32-bit userspace when building without -D_FILE_OFFSET_BITS=64 in CFLAGS, or when a filename is longer than the system file length limit. Since DiskInterface::Stat() returns -1 on error, and Node used -1 on "stat state unknown", not aborting the build lead to ninja stat()ing the same file over and over again, until it finally ran out of stack. That's now fixed. * Change RecomputeOutputsDirty() to return success instead of dirty state (like RecomputeDirty()) and return the dirty state in a bool outparam * Node::Stat()s old return value wasn't used anywhere, change the function to return success instead and add an |err| outparam * Node::StatIfNecessary()'s old return value was used only in one place. Change that place to explicitly check status_known() and make StatIfNecessary() return success and add an |err| outparam * Plan::CleanNode() can now fail, make it return bool and add an |err| outparam
* Allow scoping rules through subninjaMohamed Bamakhrama2015-03-011-21/+0
| | | | | | | | Ninja didn't support scoping rules through subninja and assumed a unique rule name in the whole namespace. With this change, this behavior is changed to allow scoping rules. Two rules can have the same name if they belong to two different scopes. However, two rules can NOT have the same name in the same scope.
* path decanonicalization when building commandScott Graham2014-11-081-1/+4
|
* wip on adding tests at higher level, some not rightScott Graham2014-11-081-1/+7
|
* Make "depfile=$out.d" work if $out contains escaped characters, rspfile too.Nico Weber2014-05-211-0/+6
| | | | | | | | | | | | | | Fixes #730. This has always been broken, but due to #690 more paths are now escaped (e.g. paths containing + characters, like file.c++). Also see discussion in #689. The approach is to give EdgeEnv an enum deciding on whether or not to escape file names, and provide functions that evaluate depfile and rspfile with that set that to kNoEscape. (depfile=$out.d doesn't make sense on edges with multiple outputs.) This should be relatively safe, as $in and $out can't be used on edges, only on rules (#687).
* Introduce the "console" poolPeter Collingbourne2014-02-031-0/+1
| | | | | | | This is a pre-defined pool with a depth of 1. It has the special property that any task in the pool has direct access to the console. This can be useful for interactive tasks or long-running tasks which produce status updates on the console (such as test suites).
* Fix restat rebuild if deps are missing.Maxim Kalaev2013-09-021-2/+3
| | | | | | | | | | | | Fixes issue #603. Apparently, the problem was caused by my fix r "consider target dirty if depfile is missing" (bcc8ad1), which was not working correctly with restat rules cleaning nodes. Switching to deps only triggered an easily observable issue. Fix by setting a flag in edges with invalid deps, and not cleaning edges with that flag set.
* Share more code between CleanNode() and RecomputeDirty().Maxim Kalaev2013-09-021-3/+7
| | | | | | | | | Move a common loop into the new function RecomputeOutputsDirty(). Simplifies things a bit, and makes it harder for the restat path to have different behavior from the regular path. No dramatic behavior change (the restat path now also calls RestatIfNecessary()).
* Check depslog timestamp in LoadDepsFromLog(), not in RecomputeOutputDirty().Maxim Kalaev2013-09-021-6/+5
| | | | | | | | | | | | RecomputeOutputDirty() is called from two places: 1. RecomputeDirty(), which calls LoadDeps(). 2. CleanNode(), which always passes 0 for the deps mtime. So this is no behavior change in either case. deps_mtime was nonzero only in deps mode, and it got passed all over the place. This makes things simpler.
* use logged deps mtime in dirty calculationEvan Martin2013-04-081-3/+5
| | | | | | | | The idea here is that it's possible for a build to complete (writing its output) but then for Ninja to get interrupted before writing out the updated dependency information. In that case the mtime stored in the deps log (if any) will match the previous output, and we'll know we need to rebuild the output just to get the deps updated.
* hook up depslog writing into build processEvan Martin2013-04-081-0/+8
|
* add "special=gcc" attribute, use to load depslogEvan Martin2013-04-081-1/+10
|
* plumb DepsLog load through BuilderEvan Martin2013-04-081-4/+5
|
* use DepsLog in loading dependenciesEvan Martin2013-04-081-5/+18
| | | | WIP
* factor out implicit dep loadingEvan Martin2013-04-081-5/+16
|
* add DepsLog, a new data structure for dependency informationEvan Martin2013-04-081-1/+8
| | | | | DepsLog is a compact serialization of dependency information. It can be used to replace depfiles for faster loading.
* rearrange handling of builtin bindings to make rules simplerEvan Martin2012-12-291-33/+10
| | | | | Now, a 'build' block can override any special binding like 'command' or 'description' if it needs to.
* wrap some overlong linesEvan Martin2012-12-291-1/+1
|
* update a commentEvan Martin2012-12-211-6/+3
|
* Make Edge->pool() a pointer like it should have beenRobert Iannucci2012-11-301-1/+1
|
* block parse method doneRobert Iannucci2012-11-101-0/+1
|
* and some basic implementationRobert Iannucci2012-11-091-0/+2
|
* stub out an api and de-constify PoolRobert Iannucci2012-11-091-0/+2
|
* remove unfortunate header dependencyEvan Martin2012-09-041-1/+0
| | | | This was temporarily added, and now it can be removed.
* clarify setterEvan Martin2012-09-041-1/+3
|
* move BuildLog to DependencyScanEvan Martin2012-09-041-5/+13
| | | | | | | The build log is needed in computing whether an edge is dirty, so I think it belongs here. (It's a bit weird that Builder needs to reach into it to record completed commands, maybe it will become cleaner with more thought.)
* remove a redundant arg to RecomputeOutputDirtyEvan Martin2012-09-021-2/+1
|
* split out dirty recomputation logic from Edge classEvan Martin2012-09-021-17/+32
| | | | | | | | | | Rather than passing States and DiskInterfaces through all the calls, put the necessary ambient information in a new DependencyScan object and move the code accordingly. Note: I didn't move the source location of the functions to preserve history, though this does result in a sort of weird order for the functions in graph.cc.
* windows: fix size_t<->int conversions in ninja.exeEvan Martin2012-08-101-4/+4
|
* Improving Edge::Dump, introducing Node::DumpMaxim Kalaev2012-06-281-1/+3
| | | | | | | - Edge::Dump could crash if called while inputs_ is being extended - Node::Dump prints Node attributes, in-edge and lists of out-edges - Dump functions now accept "prefix" parameter, printed along with the object for easier orientation. For example, edge->Dump("Re-reading deps files").
* views: Mark single-argument constructors as explicit.Thiago Farina2012-05-061-3/+7
| | | | | | | | This was reported by cpplint as: python ~/depot_tools/cpplint.py 2>&1 | grep -v "Done processing" | grep explicit Signed-off-by: Thiago Farina <tfarina@chromium.org>
* add support for -d explain to help debug why rules are runningScott Graham2012-04-131-1/+2
|
* fix some public/private errors in rspfile patchEvan Martin2012-02-231-0/+2
|
* Merge pull request #217 from PetrWolf/masterEvan Martin2012-02-231-1/+16
|\ | | | | Response files
| * Add comments, remove unwanted whitespace changePetr Wolf2012-02-101-0/+10
| |
| * Response filesunknown2012-02-091-1/+6
| |