Add support for Windows to the gradle builds

Bug: skia:
Change-Id: Ie463354281f5091866c6ccda3d041f6c7d8f0558
Reviewed-on: https://skia-review.googlesource.com/c/182101
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Stan Iliev <stani@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/platform_tools/android/apps/build.gradle b/platform_tools/android/apps/build.gradle
index e894ae5..1805fc5 100644
--- a/platform_tools/android/apps/build.gradle
+++ b/platform_tools/android/apps/build.gradle
@@ -1,5 +1,8 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 
+import java.io.File
+import java.nio.file.Paths
+import org.apache.tools.ant.taskdefs.condition.Os
 
 buildscript {
     repositories {
@@ -25,7 +28,12 @@
     appVariants.all{ variant ->
         def buildNativeLib = project.task("${variant.name}_BuildSkiaLib", type:Exec) {
             workingDir '../../../..' // top-level skia directory
-            commandLine constructBuildCommand(project, variant, appName).split()
+            final String cmd = constructBuildCommand(project, variant, appName)
+            if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+                commandLine "cmd", "/c", cmd
+            } else {
+                commandLine cmd.split()
+            }
         }
         buildNativeLib.onlyIf { !project.hasProperty("suppressNativeBuild") }
 
@@ -91,8 +99,8 @@
 
 def constructBuildCommand(project, variant, appName) {
     String depotToolsDir = null
-    for (String entry : System.getenv("PATH").split(":")) {
-        if (entry.contains("depot_tools")) {
+    for (String entry : System.getenv("PATH").split(File.pathSeparator)) {
+        if (Paths.get(entry).endsWith("depot_tools")) {
             depotToolsDir = entry;
             break;
         }
@@ -106,7 +114,7 @@
                 " depot_tools or define depot_tools.dir in local.properties")
     }
 
+    String ninja = Paths.get(depotToolsDir, "ninja")
     String out_dir = getVariantOutDir(project, variant).skiaOut
-
-    return "${depotToolsDir}/ninja -C $out_dir $appName"
+    return "$ninja -C $out_dir $appName"
 }