aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2019-01-22 14:59:01 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-01-22 14:59:01 -0800
commit4f157d89375d6b6ca5859637bc55d88f3519b629 (patch)
tree693c3a9b063ea42a57fb27995f58ff91faff9369
parent366709b3eaf631db3458780fca599b37776d5c78 (diff)
parentc8b9a208eb9d35f4f0ef60315ca0d39d99b345a4 (diff)
downloadkati-4f157d89375d6b6ca5859637bc55d88f3519b629.tar.gz
Merge remote-tracking branch 'aosp/upstream' am: 6cccb8fde7 am: bd05e6980b
am: c8b9a208eb Change-Id: I14eed78b1df7a1370f4cc36c4a45272cfabef0d6
-rw-r--r--dep.cc6
-rw-r--r--flags.cc2
-rw-r--r--flags.h1
-rw-r--r--testcase/top_level_phony.sh43
4 files changed, 51 insertions, 1 deletions
diff --git a/dep.cc b/dep.cc
index 8905105..d72a62f 100644
--- a/dep.cc
+++ b/dep.cc
@@ -768,7 +768,11 @@ class DepBuilder {
DepNode* c = BuildPlan(input, output);
n->deps.push_back({input, c});
- if (!n->is_phony && c->is_phony) {
+ bool is_phony = c->is_phony;
+ if (!is_phony && !c->has_rule && g_flags.top_level_phony) {
+ is_phony = input.str().find("/") == string::npos;
+ }
+ if (!n->is_phony && is_phony) {
if (g_flags.werror_real_to_phony) {
ERROR_LOC(n->loc,
"*** real file \"%s\" depends on PHONY target \"%s\"",
diff --git a/flags.cc b/flags.cc
index 54828e5..4f46311 100644
--- a/flags.cc
+++ b/flags.cc
@@ -118,6 +118,8 @@ void Flags::Parse(int argc, char** argv) {
warn_suffix_rules = true;
} else if (!strcmp(arg, "--werror_suffix_rules")) {
werror_suffix_rules = true;
+ } else if (!strcmp(arg, "--top_level_phony")) {
+ top_level_phony = true;
} else if (!strcmp(arg, "--warn_real_to_phony")) {
warn_real_to_phony = true;
} else if (!strcmp(arg, "--werror_real_to_phony")) {
diff --git a/flags.h b/flags.h
index 62865a3..df26f5c 100644
--- a/flags.h
+++ b/flags.h
@@ -49,6 +49,7 @@ struct Flags {
bool werror_implicit_rules;
bool warn_suffix_rules;
bool werror_suffix_rules;
+ bool top_level_phony;
bool warn_real_to_phony;
bool werror_real_to_phony;
bool warn_phony_looks_real;
diff --git a/testcase/top_level_phony.sh b/testcase/top_level_phony.sh
new file mode 100644
index 0000000..e8d78cb
--- /dev/null
+++ b/testcase/top_level_phony.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Copyright 2018 Google Inc. All rights reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -u
+
+mk="$@"
+
+cat <<EOF > Makefile
+.PHONY: test
+test: out/foo
+out/foo: bar
+ @echo "END"
+EOF
+
+touch bar
+
+if echo "${mk}" | grep -qv "kati"; then
+ # Make doesn't support these warnings, so write the expected output.
+ echo 'Makefile:4: warning: real file "out/foo" depends on PHONY target "bar"'
+ echo 'END'
+else
+ ${mk} --warn_real_to_phony --top_level_phony 2>&1
+fi
+
+if echo "${mk}" | grep -qv "kati"; then
+ # Make doesn't support these warnings, so write the expected output.
+ echo 'Makefile:4: *** real file "out/foo" depends on PHONY target "bar"'
+else
+ ${mk} --werror_real_to_phony --top_level_phony 2>&1
+fi