Add --werror_find_emulator, --werror_overriding_commands

For Android builds, we'd like to start removing some of the default
warnings and turn them into errors so that they can't come back.

For find emulator, we could attempt to check for errors, or silence
every find command in the tree, but that doesn't particularly scale,
especially when new code gets added with warnings. We've gone through
and fixed many of these, but they keep coming back, so add
--werror_find_emulator so that when we fix them all we can prevent them
from coming back.

Overriding commands is similar -- we really don't want multiple rules
defining a single output file. In ninja we've turned on -w dupbuild=err,
but if the paths happen to be identical the makefile overriding logic
kicks in first and presents a warning instead of an error. So add
--werror_overriding_commands in order to turn the make warning into an
error.
diff --git a/find.cc b/find.cc
index 6712923..2af242b 100644
--- a/find.cc
+++ b/find.cc
@@ -35,6 +35,14 @@
 #include "strutil.h"
 #include "timeutil.h"
 
+#define FIND_WARN_LOC(...) do {         \
+    if (g_flags.werror_find_emulator) { \
+      ERROR_LOC(__VA_ARGS__);           \
+    } else {                            \
+      WARN_LOC(__VA_ARGS__);            \
+    }                                   \
+  } while (0)
+
 class FindCond {
  public:
   virtual ~FindCond() = default;
@@ -261,9 +269,9 @@
                        vector<string>& out) const override {
     ScopedReadDirTracker srdt(this, *path, cur_read_dirs);
     if (!srdt.ok()) {
-      WARN_LOC(loc, "FindEmulator: find: File system loop detected; `%s' "
-               "is part of the same file system loop as `%s'.",
-               path->c_str(), srdt.conflicted().c_str());
+      FIND_WARN_LOC(loc, "FindEmulator: find: File system loop detected; `%s' "
+                    "is part of the same file system loop as `%s'.",
+                    path->c_str(), srdt.conflicted().c_str());
       return true;
     }
 
@@ -368,8 +376,8 @@
     if (fc.follows_symlinks && errno_ != ENOENT) {
       if (errno_) {
         if (fc.type != FindCommandType::FINDLEAVES) {
-          WARN_LOC(loc, "FindEmulator: find: `%s': %s",
-                   path->c_str(), strerror(errno_));
+          FIND_WARN_LOC(loc, "FindEmulator: find: `%s': %s",
+                        path->c_str(), strerror(errno_));
         }
         return true;
       }
@@ -687,7 +695,11 @@
         StringPiece dir= tok.substr(strlen("--dir="));
         fc_->finddirs.push_back(dir.as_string());
       } else if (HasPrefix(tok, "--")) {
-        WARN("Unknown flag in findleaves.py: %.*s", SPF(tok));
+        if (g_flags.werror_find_emulator) {
+          ERROR("Unknown flag in findleaves.py: %.*s", SPF(tok));
+        } else {
+          WARN("Unknown flag in findleaves.py: %.*s", SPF(tok));
+        }
         return false;
       } else {
         findfiles.push_back(tok.as_string());
@@ -826,8 +838,8 @@
         if (should_fallback)
           return false;
         if (!fc.redirect_to_devnull) {
-          WARN_LOC(loc, "FindEmulator: cd: %.*s: No such file or directory",
-                   SPF(fc.chdir));
+          FIND_WARN_LOC(loc, "FindEmulator: cd: %.*s: No such file or directory",
+                        SPF(fc.chdir));
         }
         return true;
       }
@@ -850,8 +862,8 @@
           return false;
         }
         if (!fc.redirect_to_devnull) {
-          WARN_LOC(loc, "FindEmulator: find: `%s': No such file or directory",
-                   ConcatDir(fc.chdir, finddir).c_str());
+          FIND_WARN_LOC(loc, "FindEmulator: find: `%s': No such file or directory",
+                        ConcatDir(fc.chdir, finddir).c_str());
         }
         continue;
       }