26
26
#include " version.h"
27
27
28
28
ManifestParser::ManifestParser (State* state, FileReader* file_reader,
29
- DupeEdgeAction dupe_edge_action )
29
+ ManifestParserOptions options )
30
30
: state_(state), file_reader_(file_reader),
31
- dupe_edge_action_(dupe_edge_action ), quiet_(false ) {
31
+ options_(options ), quiet_(false ) {
32
32
env_ = &state->bindings_ ;
33
33
}
34
34
@@ -346,7 +346,7 @@ bool ManifestParser::ParseEdge(string* err) {
346
346
if (!CanonicalizePath (&path, &slash_bits, &path_err))
347
347
return lexer_.Error (path_err, err);
348
348
if (!state_->AddOut (edge, path, slash_bits)) {
349
- if (dupe_edge_action_ == kDupeEdgeActionError ) {
349
+ if (options_. dupe_edge_action_ == kDupeEdgeActionError ) {
350
350
lexer_.Error (" multiple rules generate " + path + " [-w dupbuild=err]" ,
351
351
err);
352
352
return false ;
@@ -383,6 +383,25 @@ bool ManifestParser::ParseEdge(string* err) {
383
383
edge->implicit_deps_ = implicit;
384
384
edge->order_only_deps_ = order_only;
385
385
386
+ if (options_.phony_cycle_action_ == kPhonyCycleActionWarn &&
387
+ edge->maybe_phonycycle_diagnostic ()) {
388
+ // CMake 2.8.12.x and 3.0.x incorrectly write phony build statements
389
+ // that reference themselves. Ninja used to tolerate these in the
390
+ // build graph but that has since been fixed. Filter them out to
391
+ // support users of those old CMake versions.
392
+ Node* out = edge->outputs_ [0 ];
393
+ vector<Node*>::iterator new_end =
394
+ remove (edge->inputs_ .begin (), edge->inputs_ .end (), out);
395
+ if (new_end != edge->inputs_ .end ()) {
396
+ edge->inputs_ .erase (new_end, edge->inputs_ .end ());
397
+ if (!quiet_) {
398
+ Warning (" phony target '%s' names itself as an input; "
399
+ " ignoring [-w phonycycle=warn]" ,
400
+ out->path ().c_str ());
401
+ }
402
+ }
403
+ }
404
+
386
405
// Multiple outputs aren't (yet?) supported with depslog.
387
406
string deps_type = edge->GetBinding (" deps" );
388
407
if (!deps_type.empty () && edge->outputs_ .size () > 1 ) {
@@ -400,7 +419,7 @@ bool ManifestParser::ParseFileInclude(bool new_scope, string* err) {
400
419
return false ;
401
420
string path = eval.Evaluate (env_);
402
421
403
- ManifestParser subparser (state_, file_reader_, dupe_edge_action_ );
422
+ ManifestParser subparser (state_, file_reader_, options_ );
404
423
if (new_scope) {
405
424
subparser.env_ = new BindingEnv (env_);
406
425
} else {
0 commit comments