diff options
| author | Colin Cross <ccross@android.com> | 2019-09-23 14:02:07 -0700 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2019-09-23 14:02:07 -0700 |
| commit | b68db2b843e950e2d194f2a4eb55fea1e85553fe (patch) | |
| tree | 188af86c12cac0f5a40589a85f9cd0db3ae5d3b3 | |
| parent | 4106f47975671d33dc9c2a18a084e9c67bf48945 (diff) | |
| download | platform_build_kati-b68db2b843e950e2d194f2a4eb55fea1e85553fe.tar.gz platform_build_kati-b68db2b843e950e2d194f2a4eb55fea1e85553fe.tar.bz2 platform_build_kati-b68db2b843e950e2d194f2a4eb55fea1e85553fe.zip | |
Refine check for special targets and suffix rules
The checks for special targets and suffix rules looking for outputs
that start with ".", but this matches outputs that start with "../".
Add an IsSpecialTarget function that checks for "." followed by
something that is not another ".".
Bug: 139495363
Test: m DIST_DIR=../dist dist
Change-Id: Id8708cb46b81b65997e8497aa3e6c918e3c5ca4e
| -rw-r--r-- | dep.cc | 12 | ||||
| -rw-r--r-- | dep.h | 2 | ||||
| -rw-r--r-- | ninja.cc | 2 |
3 files changed, 11 insertions, 5 deletions
@@ -126,7 +126,7 @@ class RuleTrie { }; bool IsSuffixRule(Symbol output) { - if (output.empty() || output.str()[0] != '.') + if (output.empty() || !IsSpecialTarget(output)) return false; const StringPiece rest = StringPiece(output.str()).substr(1); size_t dot_index = rest.find('.'); @@ -344,7 +344,7 @@ class DepBuilder { if (g_flags.gen_all_targets) { SymbolSet non_root_targets; for (const auto& p : rules_) { - if (p.first.get(0) == '.') + if (IsSpecialTarget(p.first)) continue; for (const Rule* r : p.second.rules) { for (Symbol t : r->inputs) @@ -356,7 +356,7 @@ class DepBuilder { for (const auto& p : rules_) { Symbol t = p.first; - if (!non_root_targets.exists(t) && t.get(0) != '.') { + if (!non_root_targets.exists(t) && !IsSpecialTarget(t)) { targets.push_back(p.first); } } @@ -453,7 +453,7 @@ class DepBuilder { void PopulateExplicitRule(const Rule* rule) { for (Symbol output : rule->outputs) { - if (!first_rule_.IsValid() && output.get(0) != '.') { + if (!first_rule_.IsValid() && !IsSpecialTarget(output)) { first_rule_ = output; } rules_[output].AddRule(output, rule); @@ -841,3 +841,7 @@ void QuitDepNodePool() { delete n; delete g_dep_node_pool; } + +bool IsSpecialTarget(Symbol output) { + return output.get(0) == '.' && output.get(1) != '.'; +} @@ -63,4 +63,6 @@ void MakeDep(Evaluator* ev, const vector<Symbol>& targets, vector<NamedDepNode>* nodes); +bool IsSpecialTarget(Symbol output); + #endif // DEP_H_ @@ -483,7 +483,7 @@ class NinjaGenerator { string rule_name = "phony"; bool use_local_pool = false; - if (node->output.get(0) == '.') { + if (IsSpecialTarget(node->output)) { return; } if (g_flags.enable_debug) { |
