diff options
author | asmundak <23563312+asmundak@users.noreply.github.com> | 2021-10-20 09:49:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-20 09:49:16 -0700 |
commit | 9f48932c90ca93bc1777561cc22d1a2587bc0333 (patch) | |
tree | c2c9759015d401b688f071a82068fcc56595a620 | |
parent | 371194da71b3e191fea6f2ccceb7b061bd0de310 (diff) | |
parent | 06f2569b2d16628608c000a76e3d495a5a5528cb (diff) | |
download | kati-9f48932c90ca93bc1777561cc22d1a2587bc0333.tar.gz |
Merge pull request #239 from asmundak/master
Write top-level targets to the Ninja file in the alphabetical order
-rw-r--r-- | src/dep.cc | 7 | ||||
-rw-r--r-- | testcase/build_once.mk | 14 | ||||
-rw-r--r-- | testcase/curdir_implicit_rule.mk | 4 |
3 files changed, 18 insertions, 7 deletions
@@ -918,7 +918,12 @@ class DepBuilder { } Evaluator* ev_; - map<Symbol, RuleMerger> rules_; + struct TargetComp { + bool operator()(const Symbol& lhs, const Symbol& rhs) const { + return lhs.str() < rhs.str(); + } + }; + map<Symbol, RuleMerger, TargetComp> rules_; const unordered_map<Symbol, Vars*>& rule_vars_; unique_ptr<Vars> cur_rule_vars_; diff --git a/testcase/build_once.mk b/testcase/build_once.mk index ecb2a4e..792ae2b 100644 --- a/testcase/build_once.mk +++ b/testcase/build_once.mk @@ -1,7 +1,13 @@ # expect protoc compile/link only once. + +# Caveat: this test relies on Make and Ninja updating +# the targets in the same order. Make's target update +# order is depth first, Ninja's is the first lexically +# updatable target. Caution should be taken as Kati reorders +# targets. test: foo -foo: foo.o bar.o +foo: foo.o xbar.o echo link $@ from $< %.o: %.c FORCE_DO_CMD @@ -17,12 +23,12 @@ foo.c: foo.proto foo.proto: -bar.c: | protoc +xbar.c: | protoc -bar.c: bar.proto +xbar.c: xbar.proto echo protoc $@ from $< -bar.proto: +xbar.proto: protoc: proto.o echo link $@ from $< diff --git a/testcase/curdir_implicit_rule.mk b/testcase/curdir_implicit_rule.mk index 1f4ffaa..07df0ac 100644 --- a/testcase/curdir_implicit_rule.mk +++ b/testcase/curdir_implicit_rule.mk @@ -1,6 +1,6 @@ srcdir := . -test: foo.o bar.o +test: foo.o xbar.o echo linking $@ from $< %.o: $(srcdir)/%.c @@ -9,5 +9,5 @@ test: foo.o bar.o $(srcdir)/foo.c: echo source $@ -bar.c: +xbar.c: echo source $@ |