aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2019-09-23 14:02:07 -0700
committerColin Cross <ccross@android.com>2019-09-23 14:02:07 -0700
commitb68db2b843e950e2d194f2a4eb55fea1e85553fe (patch)
tree188af86c12cac0f5a40589a85f9cd0db3ae5d3b3
parent4106f47975671d33dc9c2a18a084e9c67bf48945 (diff)
downloadplatform_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.cc12
-rw-r--r--dep.h2
-rw-r--r--ninja.cc2
3 files changed, 11 insertions, 5 deletions
diff --git a/dep.cc b/dep.cc
index d72a62f..65687cf 100644
--- a/dep.cc
+++ b/dep.cc
@@ -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) != '.';
+}
diff --git a/dep.h b/dep.h
index 5d3eacb..259c017 100644
--- a/dep.h
+++ b/dep.h
@@ -63,4 +63,6 @@ void MakeDep(Evaluator* ev,
const vector<Symbol>& targets,
vector<NamedDepNode>* nodes);
+bool IsSpecialTarget(Symbol output);
+
#endif // DEP_H_
diff --git a/ninja.cc b/ninja.cc
index 90e56c8..4e38a8a 100644
--- a/ninja.cc
+++ b/ninja.cc
@@ -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) {