Merge "Fix clean build of UI"
diff --git a/gn/standalone/check_buildtool_exists.py b/gn/standalone/check_buildtool_exists.py
index 9b8b42a..0b2ada5 100755
--- a/gn/standalone/check_buildtool_exists.py
+++ b/gn/standalone/check_buildtool_exists.py
@@ -20,12 +20,24 @@
 
 import os
 import sys
+import argparse
 
 def main():
-  if not os.path.exists(sys.argv[1]):
+  parser = argparse.ArgumentParser(description='Test path for existence')
+  parser.add_argument('path', help='Path to test for existence')
+  parser.add_argument('--touch', help='Touch this path on success')
+  args = parser.parse_args()
+
+  if not os.path.exists(args.path):
     err = '\x1b[31mCannot find %s/%s\nRun tools/install-build-deps --ui\x1b[0m'
     print >>sys.stderr,  err % (os.path.abspath('.'), sys.argv[1])
     return 127
 
+  if args.touch:
+    with open(args.touch, 'a'):
+      os.utime(args.touch, None)
+
+  return 0
+
 if __name__ == '__main__':
   sys.exit(main())
diff --git a/ui/BUILD.gn b/ui/BUILD.gn
index b5a3ffa..7018581 100644
--- a/ui/BUILD.gn
+++ b/ui/BUILD.gn
@@ -204,10 +204,14 @@
 
 action("check_node_exists") {
   script = "../gn/standalone/check_buildtool_exists.py"
-  args = [ nodejs_bin ]
+  args = [
+    nodejs_bin,
+    "--touch",
+    rebase_path("$target_out_dir/node_exists", ""),
+  ]
   inputs = []
   outputs = [
-    "$target_out_dir/ignored",
+    "$target_out_dir/node_exists",
   ]
 }