GN: add skia_android_serial and push_$foo targets when it's set

E.g.
    $ ninja -C out push_dm

By default (ninja -C out) everything is built and pushed if skia_android_serial
is set.  Dependencies are tracked, so incremental builds push only executables
that have changed.

Change-Id: I586d81791f5f877b173cf61ed68fa9aab96234d2
Reviewed-on: https://skia-review.googlesource.com/6616
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 681a788..2c9335c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -25,6 +25,7 @@
   skia_use_piex = !is_win
   skia_use_zlib = true
 
+  skia_android_serial = ""
   skia_enable_android_framework_defines = false
   skia_enable_discrete_gpu = true
   skia_enable_gpu = true
@@ -771,11 +772,30 @@
         testonly = true
       }
     } else {
-      executable(target_name) {
+      _executable = target_name
+      executable(_executable) {
         forward_variables_from(invoker, "*", [ "is_shared_library" ])
         testonly = true
       }
     }
+    if (is_android && skia_android_serial != "" && defined(_executable)) {
+      action("push_" + target_name) {
+        script = "gn/push_to_android.py"
+        deps = [
+          ":" + _executable,
+        ]
+        _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
+        outputs = [
+          _stamp,
+        ]
+        args = [
+          rebase_path("$root_build_dir/$_executable"),
+          skia_android_serial,
+          rebase_path(_stamp),
+        ]
+        testonly = true
+      }
+    }
   }
 
   test_lib("gpu_tool_utils") {