diff options
| author | Shinichiro Hamaji <hamaji@google.com> | 2015-10-05 14:47:14 +0900 |
|---|---|---|
| committer | Shinichiro Hamaji <hamaji@google.com> | 2015-10-05 14:47:36 +0900 |
| commit | f39f4f76b603a6e1e10e3b3e65698a1864825591 (patch) | |
| tree | 9c6420088317fd9b65b0fae98179877a1dbd568e | |
| parent | 7bd2e93a0036cf5eda8fc299cbdeda3ba9a14950 (diff) | |
| parent | 6ff74ce8ee4a618060a5bc7dac408be909151518 (diff) | |
| download | platform_build_kati-f39f4f76b603a6e1e10e3b3e65698a1864825591.tar.gz platform_build_kati-f39f4f76b603a6e1e10e3b3e65698a1864825591.tar.bz2 platform_build_kati-f39f4f76b603a6e1e10e3b3e65698a1864825591.zip | |
Merge remote-tracking branch 'aosp/upstream'
Bug: 24612917
Bug: 24384320
Change-Id: Ib7e5e040844097b7a82d3225c59a7d3beee8ebda
| -rw-r--r-- | .travis.yml | 1 | ||||
| -rw-r--r-- | dep.cc | 43 | ||||
| -rw-r--r-- | dep.h | 5 | ||||
| -rw-r--r-- | ninja.cc | 3 | ||||
| -rw-r--r-- | rule.cc | 2 | ||||
| -rwxr-xr-x | runtest.rb | 24 | ||||
| -rw-r--r-- | symtab.h | 4 | ||||
| -rw-r--r-- | testcase/first_rule.mk | 5 |
8 files changed, 73 insertions, 14 deletions
diff --git a/.travis.yml b/.travis.yml index 9ffcb7c..9d2dcc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,5 @@ script: - make -j4 ckati - ruby runtest.rb -c - ruby runtest.rb -c -n + - ruby runtest.rb -c -n -a
\ No newline at end of file @@ -18,6 +18,7 @@ #include <algorithm> #include <iterator> +#include <map> #include <memory> #include <unordered_map> #include <unordered_set> @@ -100,11 +101,12 @@ class RuleTrie { } // namespace -DepNode::DepNode(Symbol o, bool p) +DepNode::DepNode(Symbol o, bool p, bool r) : output(o), has_rule(false), - is_phony(p), is_default_target(false), + is_phony(p), + is_restat(r), rule_vars(NULL), output_pattern(Symbol::IsUninitialized()) { g_dep_node_pool->push_back(this); @@ -131,6 +133,12 @@ class DepBuilder { phony_.insert(input); } } + found = rules_.find(Intern(".KATI_RESTAT")); + if (found != rules_.end()) { + for (Symbol input : found->second->inputs) { + restat_.insert(input); + } + } } ~DepBuilder() { @@ -142,9 +150,7 @@ class DepBuilder { } CHECK(!first_rule_->outputs.empty()); - first_rule_->is_default_target = true; - - if (targets.empty()) { + if (!g_flags.gen_all_targets && targets.empty()) { targets.push_back(first_rule_->outputs[0]); } if (g_flags.gen_all_phony_targets) { @@ -152,8 +158,20 @@ class DepBuilder { targets.push_back(s); } if (g_flags.gen_all_targets) { - for (const auto& p : rules_) - targets.push_back(p.first); + unordered_set<Symbol> non_root_targets; + for (const auto& p : rules_) { + for (Symbol t : p.second->inputs) + non_root_targets.insert(t); + for (Symbol t : p.second->order_only_inputs) + non_root_targets.insert(t); + } + + for (const auto& p : rules_) { + Symbol t = p.first; + if (!non_root_targets.count(t)) { + targets.push_back(p.first); + } + } } // TODO: LogStats? @@ -285,6 +303,7 @@ class DepBuilder { ApplyOutputPattern(old_rule, output, old_rule.order_only_inputs, &r->order_only_inputs); } + r->is_default_target |= old_rule.is_default_target; return r; } @@ -299,6 +318,7 @@ class DepBuilder { auto p = rules_.insert(make_pair(output, rule)); if (p.second) { if (!first_rule_ && output.get(0) != '.') { + rule->is_default_target = true; first_rule_ = rule; } } else { @@ -386,6 +406,7 @@ class DepBuilder { copy(rule->inputs.begin(), rule->inputs.end(), back_inserter(r->inputs)); r->cmds = irule->cmds; + r->is_default_target |= irule->is_default_target; r->loc = irule->loc; r->cmd_lineno = irule->cmd_lineno; *out_rule = r; @@ -419,6 +440,7 @@ class DepBuilder { shared_ptr<Rule> r = make_shared<Rule>(*rule); r->inputs.insert(r->inputs.begin(), input); r->cmds = irule->cmds; + r->is_default_target |= irule->is_default_target; r->loc = irule->loc; r->cmd_lineno = irule->cmd_lineno; *out_rule = r; @@ -446,7 +468,9 @@ class DepBuilder { return found->second; } - DepNode* n = new DepNode(output, phony_.count(output)); + DepNode* n = new DepNode(output, + phony_.count(output), + restat_.count(output)); done_[output] = n; shared_ptr<Rule> rule; @@ -524,7 +548,7 @@ class DepBuilder { } Evaluator* ev_; - unordered_map<Symbol, shared_ptr<Rule>> rules_; + map<Symbol, shared_ptr<Rule>> rules_; const unordered_map<Symbol, Vars*>& rule_vars_; unique_ptr<Vars> cur_rule_vars_; @@ -535,6 +559,7 @@ class DepBuilder { shared_ptr<Rule> first_rule_; unordered_map<Symbol, DepNode*> done_; unordered_set<Symbol> phony_; + unordered_set<Symbol> restat_; }; void MakeDep(Evaluator* ev, @@ -30,7 +30,7 @@ class Value; class Vars; struct DepNode { - DepNode(Symbol output, bool is_phony); + DepNode(Symbol output, bool is_phony, bool is_restat); Symbol output; vector<Value*> cmds; @@ -38,8 +38,9 @@ struct DepNode { vector<DepNode*> order_onlys; vector<DepNode*> parents; bool has_rule; - bool is_phony; bool is_default_target; + bool is_phony; + bool is_restat; vector<Symbol> actual_inputs; Vars* rule_vars; Symbol output_pattern; @@ -437,6 +437,9 @@ class NinjaGenerator { fprintf(fp_, " command = %s -c \"%s\"\n", shell_.c_str(), cmd_buf.c_str()); } + if (node->is_restat) { + fprintf(fp_, " restat = 1\n"); + } } EmitBuild(node, rule_name, use_local_pool); @@ -166,6 +166,8 @@ string Rule::DebugString() const { v.push_back("is_double_colon"); if (is_suffix_rule) v.push_back("is_suffix_rule"); + if (is_default_target) + v.push_back("is_default_target"); if (!cmds.empty()) { v.push_back(StringPrintf("cmds=[%s]", JoinValues(cmds, ",").c_str())); } @@ -27,6 +27,10 @@ while true elsif ARGV[0] == '-n' via_ninja = true ARGV.shift + ENV['NINJA_STATUS'] = 'NINJACMD: ' + elsif ARGV[0] == '-a' + gen_all_targets = true + ARGV.shift elsif ARGV[0] == '-v' show_failing = true ARGV.shift @@ -93,7 +97,7 @@ def run_in_testdir(test_filename) end def normalize_ninja_log(log, mk) - log.gsub!(/^\[\d+\/\d+\] .*\n/, '') + log.gsub!(/^NINJACMD: .*\n/, '') log.gsub!(/^ninja: no work to do\.\n/, '') log.gsub!(/^ninja: error: (.*, needed by .*),.*/, '*** No rule to make target \\1.') @@ -219,13 +223,27 @@ run_make_test = proc do |mk| if via_ninja cmd += ' --ninja' end + if gen_all_targets + if !ckati || !via_ninja + raise "-a should be used with -c -n" + end + cmd += ' --gen_all_targets' + end if is_silent_test cmd += ' -s' end - cmd += " #{tc} 2>&1" + if !gen_all_targets || mk =~ /makecmdgoals/ + cmd += " #{tc}" + end + cmd += " 2>&1" res = IO.popen(cmd, 'r:binary', &:read) if via_ninja && File.exist?('build.ninja') && File.exists?('ninja.sh') - log = IO.popen('./ninja.sh -j1 -v 2>&1', 'r:binary', &:read) + cmd = './ninja.sh -j1 -v' + if gen_all_targets + cmd += " #{tc}" + end + cmd += ' 2>&1' + log = IO.popen(cmd, 'r:binary', &:read) res += normalize_ninja_log(log, mk) end res = normalize_kati_log(res) @@ -66,6 +66,10 @@ inline bool operator==(const Symbol& x, const Symbol& y) { return x.val() == y.val(); } +inline bool operator<(const Symbol& x, const Symbol& y) { + return x.val() < y.val(); +} + namespace std { template<> struct hash<Symbol> { size_t operator()(const Symbol& s) const { diff --git a/testcase/first_rule.mk b/testcase/first_rule.mk new file mode 100644 index 0000000..1d6291d --- /dev/null +++ b/testcase/first_rule.mk @@ -0,0 +1,5 @@ +%: + echo FAIL + +a b: + echo $@ |
