add a Win/Clang build bot

BUG=skia:2679

CQ_INCLUDE_TRYBOTS=skia.primary:Build-Win-Clang-x86_64-Release

Change-Id: I861366ae1340abcc67e87041904d08337b465bbe
Reviewed-on: https://skia-review.googlesource.com/28864
Reviewed-by: Eric Boren <borenet@google.com>
diff --git a/bin/fetch-clang-win b/bin/fetch-clang-win
deleted file mode 100644
index 06ff07b..0000000
--- a/bin/fetch-clang-win
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 Google Inc.
-#
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-VERSION = '308728-3'
-MD5     = '8bec8c34da5d256e27638383667489e5'
-
-import hashlib
-import os
-import shutil
-import tarfile
-import urllib2
-
-os.chdir(os.path.dirname(__file__))
-
-if (not os.path.exists('clang_win/md5.txt')
-        or open('clang_win/md5.txt').read().strip() != MD5):
-
-  # Clear out everything and start fresh.
-  shutil.rmtree('clang_win', ignore_errors=True)
-  os.mkdir('clang_win')
-  os.chdir('clang_win')
-
-  # Grab the current Clang package.
-  with open(VERSION + '.tgz', 'wb') as tgz:
-    url = 'https://commondatastorage.googleapis.com/chromium-browser-clang'
-    tgz.write(urllib2.urlopen(url + '/Win/clang-' + VERSION + '.tgz').read())
-
-  # Extract it.
-  tarfile.open(VERSION + '.tgz').extractall()
-
-  # Write out its hash to md5.txt so that next time is quicker.
-  h = hashlib.md5()
-  with open(VERSION + '.tgz', 'rb') as tgz:
-    h.update(tgz.read())
-  with open('md5.txt', 'w') as md5:
-    md5.write(h.hexdigest())
diff --git a/infra/bots/gen_tasks.go b/infra/bots/gen_tasks.go
index f19bb56..e31497f 100644
--- a/infra/bots/gen_tasks.go
+++ b/infra/bots/gen_tasks.go
@@ -469,6 +469,9 @@
 		}
 	} else if strings.Contains(name, "Win") {
 		pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_toolchain"))
+		if strings.Contains(name, "Clang") {
+			pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_win"))
+		}
 		if strings.Contains(name, "Vulkan") {
 			pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_vulkan_sdk"))
 		}
diff --git a/infra/bots/jobs.json b/infra/bots/jobs.json
index 47f713d..8c15db4 100644
--- a/infra/bots/jobs.json
+++ b/infra/bots/jobs.json
@@ -59,6 +59,7 @@
   "Build-Mac-Clang-x86_64-Release",
   "Build-Mac-Clang-x86_64-Release-CommandBuffer",
   "Build-Win-Clang-arm64-Release-Android",
+  "Build-Win-Clang-x86_64-Release",
   "Build-Win-MSVC-x86-Debug",
   "Build-Win-MSVC-x86-Debug-ANGLE",
   "Build-Win-MSVC-x86-Debug-Exceptions",
diff --git a/infra/bots/recipe_modules/flavor/examples/full.expected/Build-Win-Clang-x86_64-Release.json b/infra/bots/recipe_modules/flavor/examples/full.expected/Build-Win-Clang-x86_64-Release.json
new file mode 100644
index 0000000..cb088a1
--- /dev/null
+++ b/infra/bots/recipe_modules/flavor/examples/full.expected/Build-Win-Clang-x86_64-Release.json
@@ -0,0 +1,54 @@
+[
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "[CUSTOM_C:\\_B_WORK]/skia/bin/fetch-gn"
+    ],
+    "cwd": "[CUSTOM_C:\\_B_WORK]/skia",
+    "env": {
+      "BUILDTYPE": "Release_x64",
+      "CHROME_HEADLESS": "1",
+      "PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]",
+      "SKIA_OUT": "[CUSTOM_C:\\_B_WORK]/skia/out/Build-Win-Clang-x86_64-Release"
+    },
+    "infra_step": true,
+    "name": "fetch-gn"
+  },
+  {
+    "cmd": [
+      "[CUSTOM_C:\\_B_WORK]/skia/bin/gn.exe",
+      "gen",
+      "[CUSTOM_C:\\_B_WORK]/skia/out/Build-Win-Clang-x86_64-Release/Release_x64",
+      "--args=cc=\"clang\" clang_win=\"[START_DIR]/clang_win\" cxx=\"clang++\" is_debug=false target_cpu=\"x86_64\" windk=\"[START_DIR]/t/depot_tools/win_toolchain/vs_files/d3cb0e37bdd120ad0ac4650b674b09e81be45616\""
+    ],
+    "cwd": "[CUSTOM_C:\\_B_WORK]/skia",
+    "env": {
+      "BUILDTYPE": "Release_x64",
+      "CHROME_HEADLESS": "1",
+      "PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]",
+      "SKIA_OUT": "[CUSTOM_C:\\_B_WORK]/skia/out/Build-Win-Clang-x86_64-Release"
+    },
+    "name": "gn gen"
+  },
+  {
+    "cmd": [
+      "ninja.exe",
+      "-C",
+      "[CUSTOM_C:\\_B_WORK]/skia/out/Build-Win-Clang-x86_64-Release/Release_x64"
+    ],
+    "cwd": "[CUSTOM_C:\\_B_WORK]/skia",
+    "env": {
+      "BUILDTYPE": "Release_x64",
+      "CHROME_HEADLESS": "1",
+      "PATH": "<PATH>:RECIPE_PACKAGE_REPO[depot_tools]",
+      "SKIA_OUT": "[CUSTOM_C:\\_B_WORK]/skia/out/Build-Win-Clang-x86_64-Release"
+    },
+    "name": "ninja"
+  },
+  {
+    "name": "$result",
+    "recipe_result": null,
+    "status_code": 0
+  }
+]
\ No newline at end of file
diff --git a/infra/bots/recipe_modules/flavor/examples/full.py b/infra/bots/recipe_modules/flavor/examples/full.py
index 59fba85..739fbb7 100644
--- a/infra/bots/recipe_modules/flavor/examples/full.py
+++ b/infra/bots/recipe_modules/flavor/examples/full.py
@@ -69,6 +69,7 @@
   'Build-Ubuntu-GCC-x86_64-Release-PDFium',
   'Build-Ubuntu-GCC-x86_64-Release-PDFium_SkiaPaths',
   'Build-Win-Clang-arm64-Release-Android',
+  'Build-Win-Clang-x86_64-Release',
   'Build-Win-MSVC-x86_64-Debug-GDI',
   'Build-Win-MSVC-x86_64-Debug-NoGPU',
   'Build-Win-MSVC-x86_64-Release-Exceptions',
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index 20d23ac..04afa7c 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -109,6 +109,8 @@
       args['skia_use_metal'] = 'true'
     if 'CheckGeneratedFiles' in extra_config:
       args['skia_compile_processors'] = 'true'
+    if compiler == 'Clang' and 'Win' in os:
+      args['clang_win'] = '"%s"' % self.m.vars.slave_dir.join('clang_win')
 
     for (k,v) in {
       'cc':  cc,
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json
index 11cdea5..8f586dc 100644
--- a/infra/bots/tasks.json
+++ b/infra/bots/tasks.json
@@ -365,6 +365,12 @@
         "Build-Win-Clang-arm64-Release-Android"
       ]
     },
+    "Build-Win-Clang-x86_64-Release": {
+      "priority": 0.8,
+      "tasks": [
+        "Build-Win-Clang-x86_64-Release"
+      ]
+    },
     "Build-Win-MSVC-x86-Debug": {
       "priority": 0.8,
       "tasks": [
@@ -3983,6 +3989,40 @@
       "isolate": "compile_skia.isolate",
       "priority": 0.8
     },
+    "Build-Win-Clang-x86_64-Release": {
+      "cipd_packages": [
+        {
+          "name": "skia/bots/win_toolchain",
+          "path": "t",
+          "version": "version:6"
+        },
+        {
+          "name": "skia/bots/clang_win",
+          "path": "clang_win",
+          "version": "version:0"
+        }
+      ],
+      "dimensions": [
+        "gpu:none",
+        "os:Windows-2008ServerR2-SP1",
+        "pool:Skia"
+      ],
+      "extra_args": [
+        "--workdir",
+        "../../..",
+        "compile",
+        "repository=<(REPO)",
+        "buildername=Build-Win-Clang-x86_64-Release",
+        "swarm_out_dir=${ISOLATED_OUTDIR}",
+        "revision=<(REVISION)",
+        "patch_repo=<(PATCH_REPO)",
+        "patch_storage=<(PATCH_STORAGE)",
+        "patch_issue=<(ISSUE)",
+        "patch_set=<(PATCHSET)"
+      ],
+      "isolate": "compile_skia.isolate",
+      "priority": 0.8
+    },
     "Build-Win-MSVC-x86-Debug": {
       "cipd_packages": [
         {