diff options
| author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-10-03 11:58:35 +0900 |
|---|---|---|
| committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-10-03 11:58:35 +0900 |
| commit | 6ff74ce8ee4a618060a5bc7dac408be909151518 (patch) | |
| tree | 9c6420088317fd9b65b0fae98179877a1dbd568e /dep.cc | |
| parent | 867fb12908f2eedbb3ebbc28a971680b534a0b8b (diff) | |
[C++] Fix target specific variables with --gen_all_targets
--gen_all_targets started traversing the dependency graph from
random node. This may prevent target specific variables in
parents from being applied. With this patch, we always traverse
the graph from nodes without parents.
Diffstat (limited to 'dep.cc')
| -rw-r--r-- | dep.cc | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -150,7 +150,7 @@ class DepBuilder { } CHECK(!first_rule_->outputs.empty()); - 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) { @@ -158,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? |
