summaryrefslogtreecommitdiffstats
path: root/src/graph.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #1534 from mathstuf/remove-depslog-restrictionJan Niklas Hasse2020-01-041-4/+32
|\ | | | | manifest_parser: remove multi-output depslog restriction
| * depfile_parser: remove restriction on multiple outputsBen Boeckel2019-11-201-4/+32
| |
* | graph.cc: constify DependencyScanKonstantin Kharlamov2019-11-201-2/+2
|/ | | | Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
* Fix invalid preprocessor #ifMichael Jones2019-11-141-1/+1
|
* Fix crash when using MSVC in debug modeJan Niklas Hasse2019-09-211-0/+4
| | | | | Accessing inputs_[0] when it's empty results in an assert when running in debug. Avoid it by using data() if available.
* 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-17/+11
|
* Fix UB "member call on null pointer of type 'DepsLog'", see #1248Jan Niklas Hasse2019-05-281-1/+1
|
* Teach RecomputeDirty to load dyndep files that are readyBrad King2019-04-181-0/+25
| | | | | | | | | | | The full readiness of a node that has a dyndep binding cannot be known until after the dyndep file is loaded. If a dyndep file is ready while constructing the build plan it can be loaded immediately so full information can be used to decide whether anything needs to be built. If a dyndep file is not ready while constructing the build plan then the edges naming it cannot be ready either because the dyndep file is one of their inputs. In this case we defer loading the dyndep file until the build plan is being executed.
* Teach DependencyScan to load a dyndep fileBrad King2019-04-181-0/+9
| | | | | 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-0/+5
| | | | | | 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-6/+10
| | | | | | 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-1/+3
| | | | | | | | | | | | | | | | 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.
* Make TimeStamp 64-bit.Elliott Sales de Andrade2017-09-161-4/+4
| | | | This prepares it for higher-resolution timestamps.
* Restore tolerance of self-referencing phony build statementsBrad King2017-09-081-0/+15
| | | | | | | | | | | | | | | | | | | | 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-14/+64
| | | | | | | | | | | | | | | | 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.
* Refactor RecomputeDirty to take a node instead of an edgeBrad King2017-06-191-10/+12
| | | | | | 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.
* Fix segfault on edge with no inputsColin Cross2017-06-161-1/+1
| | | | | | | | PR #1281 added a deference of most_recent_input without checking for NULL, which can occur if a build rule has no inputs. Check it for null before dereferencing, and add a test. Fixes #1290.
* Always rebuild on errorsColin Cross2017-05-221-7/+19
| | | | | | | | | | https://groups.google.com/forum/#!msg/ninja-build/YQuGNrECI-4/ti-lAs9SPv8J discusses a case where an rule updates its output file and then fails. The next run of ninja considers the ouptut file clean and doesn't rebuild it. Always stat output files after they are built, and write the mtime into .ninja_log. Consider output files dirty if the recorded mtime is older than the most recent input file.
* Move stat metric to DiskInterfaceColin Cross2017-05-221-1/+0
| | | | | | | Stat is not always used through Node::Stat, it is often used directly through DiskInterface. THe next patches will cause it to be called even more often through DiskInterface, so move the metrics to DiskInterface.
* Merge pull request #1181 from DanielWeber/issue-1161Nico Weber2017-01-241-4/+4
|\ | | | | Allow more path components
| * Use uint64_t for slash_bits consistentlyDaniel Weber2016-09-011-2/+2
| | | | | | | | The VS compiler complained about possible loss of data (and it was right!)
| * Allow more path componentsDaniel Weber2016-08-221-2/+2
| | | | | | | | | | | | | | - 60 instead of 30 path components - 64 instead of 32 backslashes in a path (windows only) Issue: 1161
* | Improve error message when a depfile contains a bad pathTomasz Śniatowski2016-10-121-1/+3
|/ | | | | Debugging "ninja: error: empty path" is not fun, so make the error message mention the depfile name.
* Remove StatIfNecessary call that is never necessaryBrad King2016-02-251-2/+1
| | | | | | | | | | | | | | The call to StatIfNecessary in DependencyScan::RecomputeOutputsDirty was added by commit v1.4.0^2~7^2~1 (Share more code between CleanNode() and RecomputeDirty(), 2013-09-02) while consolidating code paths. However, it was needed only when called from RecomputeDirty because prior to refactoring the CleanNode code path did not call it. Later commit v1.6.0^2~46^2 (Let DependencyScan::RecomputeDirty() work correclty with cyclic graphs, 2014-12-07) added back to RecomputeDirty a loop over outputs that calls StatIfNecessary. Therefore RecomputeOutputsDirty no longer needs to call StatIfNecessary for either of its own callers.
* Merge pull request #989 from bradking/implicit-outputsNico Weber2016-02-031-1/+2
|\ | | | | Add support for build statement implicit outputs
| * Add support for build statement implicit outputsBrad King2016-02-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Expose more details in FileReader::ReadFile signatureBrad King2016-02-031-2/+9
|/ | | | | | Return a status so callers can distinguish a missing file from an empty file. This allows our VirtualFileSystem test infrastructure to report as missing any file for which it has no entry.
* win: print right slashes in 'unknown target' messageNico Weber2015-07-101-3/+4
|
* Add a missing EXPLAIN() call.Nico Weber2015-05-151-1/+7
|
* Let Stat() have an err outparam instead of writing to stderr.Nico Weber2015-03-311-7/+1
| | | | | | | | | Also check for Stat() failure in a few more places. This way, ninja doesn't print two "ninja: error: " lines if stat() fails during a build. It also makes it easier to keep the stat tests quiet. Every caller of Stat() needs to explicitly log the error string if that's desired.
* Recover slowdown for cyclic rule bindings fix.Nico Weber2015-03-211-9/+17
|
* Don't crash on cyclic references between rule bindings.Nico Weber2015-03-211-0/+12
| | | | | | | | | | | | | Fixes #902. This dynamically detects cycles. I like this approach less than detecting them statically when parsing rules [1], but it has the advantage that it doesn't break existing ninja manifest files. It has the disadvantage that it slows down manifest_parser_perftest by 3.9%. 1: https://github.com/martine/ninja/commit/cc6f54d6d436047
* Make failing stat() calls abort the build.Nico Weber2015-03-191-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Env should only be about variables. No behavior change.Nico Weber2015-03-181-5/+0
|
* On unexpected output in a .d file, rebuild instead erroring.Nico Weber2015-03-121-3/+4
| | | | Fixes #417.
* Allow scoping rules through subninjaMohamed Bamakhrama2015-03-011-24/+5
| | | | | | | | 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.
* Typo fix in graph.cctzik2015-02-061-1/+1
|
* Let DependencyScan::RecomputeDirty() work correclty with cyclic graphs.Nico Weber2014-12-081-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RecomputDirty(edge) currently works roughly like this: RecomputeDirty(edge): LoadDeps(edge) for in in edge.inputs: if in.StatIfNecessary(): RecomputeDirty(in.in_edge) # recurse into inputs for out in edge.outputs: out.StatIfNecessary() # mark outputs as visited It uses the stat state of each node to mark nodes as visited and doesn't traverse across nodes that have been visited already. For cyclic graphs with an edge with multiple outputs on the cycle, nothing prevents an edge to be visited more than once if the cycle is entered through an output that isn't on the cycle. In other words, RecomputeDirty() for the same edge can be on the call stack more than once. This is bad for at least two reasons: 1. Deps are added multiple times, making the graph confusing to reason about. 2. LoadDeps() will insert into the inputs_ of an edge that's iterated over in a callframe higher up. This can invalidate the iterator, which causes a crash when the callframe with the loop over the now-invalidated iterator resumes. To fix this, let RecomputeDirty() mark all outputs of an edge as visited as the first thing it does. This way, even if the edge is on a cycle with several outputs, each output is already marked and no edge will have its deps loaded more than once. Fixes the crashes in #875. (In practice, it turns the crashes into "stuck [this is a bug]" messages for now, due to the example without duplicate rules in #867)
* Rename a few iterators. No behavior change.Nico Weber2014-12-071-9/+9
| | | | | | | | | It confused me that the iterator iterating over `outputs_` was called `i` -- this always made me think of "input", not "iterator". Call iterators over edge outputs "o", iterators over edge inputs "i", iterators over node input edges "oe", and general iterators over edges "e".
* remove two unneeded `explicit`sNico Weber2014-12-071-1/+1
|
* whitespace/comment/wrap fixes, no intended functionality changeScott Graham2014-11-121-1/+1
|
* no need to Decanonicalize on non-WindowsScott Graham2014-11-111-0/+2
|
* make all GetNode explicit, add DepsLog canonicalize testScott Graham2014-11-101-1/+1
|
* fix order of args to CanonicalizePathScott Graham2014-11-091-3/+3
|
* remove CanonicalizePath overloads, test for toplevel behaviourScott Graham2014-11-091-2/+9
|
* path decanonicalization when building commandScott Graham2014-11-081-1/+13
|
* Make "depfile=$out.d" work if $out contains escaped characters, rspfile too.Nico Weber2014-05-211-6/+25
| | | | | | | | | | | | | | 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/+4
| | | | | | | 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).
* More robust escaping of $in, $out pathsNicholas Hutchinson2014-01-061-9/+6
| | | | | | In summary: don’t escape if the path doesn’t contain problematic characters, otherwise: - Shell: enclose string in single quotes, escape embedded single quotes with the magic quote-backslash-quote sequence - Win32: Escape double quotes by doubling the number of consecutive backslashes that precede them (if any) and adding one more. Finally, double the number of trailing backslashes, and enclose the whole thing in double quotes.