documentation/build, BUILDCONFIG: Visual Studio Build Tools 2019

deprecate 2015

Docs-Preview: https://skia.org/?cl=226502
Change-Id: I32cd75937ebdc774138499c4cd79c1eda29bd0f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226502
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 446bb30..aa5cd36 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -63,12 +63,8 @@
       "NOMINMAX",
     ]
 
-    if (msvc == 2015) {
-      _include_dirs = [ "$win_vc/include" ]
-    } else {  # 2017
-      _include_dirs = [ "$win_vc/Tools/MSVC/$win_toolchain_version/include" ]
-    }
-    _include_dirs += [
+    _include_dirs = [
+      "$win_vc/Tools/MSVC/$win_toolchain_version/include",
       "$win_sdk/Include/$win_sdk_version/shared",
       "$win_sdk/Include/$win_sdk_version/ucrt",
       "$win_sdk/Include/$win_sdk_version/um",
@@ -89,17 +85,8 @@
     lib_dirs = [
       "$win_sdk/Lib/$win_sdk_version/ucrt/$target_cpu",
       "$win_sdk/Lib/$win_sdk_version/um/$target_cpu",
+      "$win_vc/Tools/MSVC/$win_toolchain_version/lib/$target_cpu",
     ]
-    if (msvc == 2015) {
-      if (target_cpu == "x86") {
-        lib_dirs += [ "$win_vc/lib" ]
-      } else {
-        lib_dirs += [ "$win_vc/lib/amd64" ]
-      }
-    } else {  # 2017
-      lib_dirs +=
-          [ "$win_vc/Tools/MSVC/$win_toolchain_version/lib/$target_cpu" ]
-    }
   } else {
     cflags += [
       "-fstrict-aliasing",
diff --git a/gn/BUILDCONFIG.gn b/gn/BUILDCONFIG.gn
index a082d90..5e17b17 100644
--- a/gn/BUILDCONFIG.gn
+++ b/gn/BUILDCONFIG.gn
@@ -113,62 +113,18 @@
   }
 }
 
-msvc = ""
 if (target_os == "win") {
   # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a
   # non-default location, you can set win_vc to inform us where it is.
-  vc_2017_ent_default =
-      "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC"
-  vc_2017_pro_default =
-      "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC"
-  vc_2017_com_default =
-      "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC"
-  vc_2017_bt_default =
-      "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC"
-  vc_2015_default = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC"
 
   if (win_vc == "") {
-    if ("True" == exec_script("//gn/checkdir.py",
-                              [ "$vc_2017_ent_default" ],
-                              "trim string")) {
-      win_vc = vc_2017_ent_default
-      msvc = 2017
-    } else if ("True" == exec_script("//gn/checkdir.py",
-                                     [ "$vc_2017_pro_default" ],
-                                     "trim string")) {
-      win_vc = vc_2017_pro_default
-      msvc = 2017
-    } else if ("True" == exec_script("//gn/checkdir.py",
-                                     [ "$vc_2017_com_default" ],
-                                     "trim string")) {
-      win_vc = vc_2017_com_default
-      msvc = 2017
-    } else if ("True" == exec_script("//gn/checkdir.py",
-                                     [ "$vc_2017_bt_default" ],
-                                     "trim string")) {
-      win_vc = vc_2017_bt_default
-      msvc = 2017
-    } else if ("True" == exec_script("//gn/checkdir.py",
-                                     [ "$vc_2015_default" ],
-                                     "trim string")) {
-      win_vc = vc_2015_default
-      msvc = 2015
-    }
+    win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
   }
   assert(win_vc != "")  # Could not find VC installation. Set win_vc to your VC directory.
-
-  if (msvc == "") {
-    if ("True" ==
-        exec_script("//gn/checkdir.py", [ "$win_vc/Tools" ], "trim string")) {
-      msvc = 2017
-    } else {
-      msvc = 2015
-    }
-  }
 }
 
 if (target_os == "win") {
-  if (msvc == 2017 && win_toolchain_version == "") {
+  if (win_toolchain_version == "") {
     win_toolchain_version = exec_script("//gn/highest_version_dir.py",
                                         [
                                           "$win_vc/Tools/MSVC",
diff --git a/gn/find_msvc.py b/gn/find_msvc.py
new file mode 100644
index 0000000..864db09
--- /dev/null
+++ b/gn/find_msvc.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# Copyright 2019 Google Inc.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+
+'''
+Look for the first match in the format
+    C:\\Program Files (x86)\\Microsoft Visual Studio\\${RELEASE}\\${VERSION}\\VC
+'''
+def find_msvc():
+  if sys.platform.startswith('win'):
+    default_dir = r'C:\Program Files (x86)\Microsoft Visual Studio'
+    for release in ['2019', '2017']:
+      for version in ['Enterprise', 'Professional', 'Community', 'BuildTools']:
+        path = os.path.join(default_dir, release, version, 'VC')
+        if os.path.isdir(path):
+          return path
+  return None
+
+if __name__ == '__main__':
+  result = find_msvc()
+  if result:
+    sys.stdout.write(result + '\n')
diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py
index 4b60dc5..a548749 100644
--- a/gn/gn_to_bp.py
+++ b/gn/gn_to_bp.py
@@ -338,6 +338,7 @@
     # some dummy values.
     d['win_vc'] = '"dummy_version"'
     d['win_sdk_version'] = '"dummy_version"'
+    d['win_toolchain_version'] = '"dummy_version"'
   return d
 
 gn_args       = generate_args('"android"', True)
diff --git a/gn/toolchain/BUILD.gn b/gn/toolchain/BUILD.gn
index f95fcc2..d931b32 100644
--- a/gn/toolchain/BUILD.gn
+++ b/gn/toolchain/BUILD.gn
@@ -33,15 +33,7 @@
 toolchain("msvc") {
   lib_dir_switch = "/LIBPATH:"
 
-  if (msvc == 2015) {
-    if (target_cpu == "x86") {
-      bin = "$win_vc/bin"
-    } else {
-      bin = "$win_vc/bin/amd64"
-    }
-  } else {
-    bin = "$win_vc/Tools/MSVC/$win_toolchain_version/bin/HostX64/$target_cpu"
-  }
+  bin = "$win_vc/Tools/MSVC/$win_toolchain_version/bin/HostX64/$target_cpu"
 
   env_setup = ""
   if (target_cpu == "x86") {
diff --git a/site/user/build.md b/site/user/build.md
index bfef757..30b44c8d 100644
--- a/site/user/build.md
+++ b/site/user/build.md
@@ -7,8 +7,19 @@
 Skia uses [GN](https://chromium.googlesource.com/chromium/src/tools/gn/) to
 configure its builds.
 
-`is_official_build` and Third-party Dependencies
-------------------------------------------------
+  - [`is_official_build` and Third-party Dependencies](#third-party)
+  - [A note on software backend performance](#performance)
+  - [Quickstart](#quick)
+  - [Android](#android)
+  - [ChromeOS](#cros)
+  - [Mac](#macos)
+  - [iOS](#ios)
+  - [Windows](#windows)
+  - [Windows ARM64](#win-arm64)
+  - [CMake](#cmake)
+
+<span id="third-party">`is_official_build` and Third-party Dependencies</span>
+------------------------------------------------------------------------------
 
 Most users of Skia should set `is_official_build=true`, and most developers
 should leave it to its `false` default.
@@ -33,8 +44,8 @@
 use `extra_cflags` and `extra_ldflags` to add include or library paths if
 needed.
 
-A note on software backend performance
---------------------------------------
+<span id="performance">A note on software backend performance</span>
+--------------------------------------------------------------------
 
 A number of routines in Skia's software backend have been written to run
 fastest when compiled by Clang.  If you depend on software rasterization, image
@@ -45,8 +56,8 @@
 wrong with non-Clang compilers.  So if this is a serious issue for you, please
 let us know on the mailing list.
 
-Quickstart
-----------
+<span id="quick">Quickstart</span>
+----------------------------------
 
 Run GN to generate your build files.
 
@@ -83,8 +94,8 @@
 
     tools/install_dependencies.sh
 
-Android
--------
+<span id="android">Android</span>
+---------------------------------
 
 To build Skia for Android you need an [Android
 NDK](https://developer.android.com/ndk/index.html).
@@ -116,8 +127,9 @@
     adb shell "cd /data/local/tmp; ./dm --src gm --config gl"
 
 
-ChromeOS
---------------
+<span id="cros">ChromeOS</span>
+-------------------------------
+
 To cross-compile Skia for arm ChromeOS devices the following is needed:
 
   - Clang 4 or newer
@@ -206,13 +218,13 @@
 
     sudo mount -i -o remount,exec /home/chronos
 
-Mac
----
+<span id="macos">Mac</span>
+---------------------------
 
 Mac users may want to pass `--ide=xcode` to `bin/gn gen` to generate an Xcode project.
 
-iOS
----
+<span id="ios">iOS</span>
+-------------------------
 
 Run GN to generate your build files.  Set `target_os="ios"` to build for iOS.
 This defaults to `target_cpu="arm64"`.  Choosing `x64` targets the iOS simulator.
@@ -241,15 +253,15 @@
 but can be done on the command line by setting the environment variable IPHONEOS_DEPLOYMENT_TARGET
 to the desired OS version.
 
-Windows
--------
+<span id="windows">Windows</span>
+---------------------------------
 
-Skia can build on Windows with Visual Studio 2017 or Visual Studio 2015 Update 3.
+Skia can build on Windows with Visual Studio 2017 or 2019.
 If GN is unable to locate either of those, it will print an error message. In that
 case, you can pass your `VC` path to GN via `win_vc`.
 
-Skia can be compiled with the free [Build Tools for Visual Studio
-2017](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017).
+Skia can be compiled with the free [Build Tools for Visual Studio 2017 or
+2019](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2019).
 
 The bots use a packaged 2017 toolchain, which Googlers can download like this:
 
@@ -261,7 +273,6 @@
     win_sdk = "C:\toolchain\win_sdk"
 
 This toolchain is the only way we support 32-bit builds, by also setting `target_cpu="x86"`.
-There is also a corresponding 2015 toolchain, downloaded via `infra/bots/assets/win_toolchain_2015`.
 
 The Skia build assumes that the PATHEXT environment variable contains ".EXE".
 
@@ -272,11 +283,13 @@
 
 Setting the `cc` and `cxx` gn args is _not_ sufficient to build with clang-cl. These variables
 are ignored on Windows. Instead set the variable `clang_win` to your LLVM installation directory.
-If you installed the prebuilt LLVM downloaded from [here](https://releases.llvm.org/download.html "LLVM Download") in the default location that would be:
+If you installed the prebuilt LLVM downloaded from [here](https://releases.llvm.org/download.html
+"LLVM Download") in the default location that would be:
 
     clang_win = "C:\Program Files\LLVM"
 
-Follow the standard Windows path specification and not MinGW convention (e.g. `C:\Program Files\LLVM` not ~~`/c/Program Files/LLVM`~~).
+Follow the standard Windows path specification and not MinGW convention (e.g.
+`C:\Program Files\LLVM` not ~~`/c/Program Files/LLVM`~~).
 
 ### Visual Studio Solutions
 
@@ -297,8 +310,8 @@
 of inactive code blocks based on preprocessor definitions from the selected
 solution configuration.
 
-Windows ARM64
--------------
+<span id="win-arm64">Windows ARM64</span>
+-----------------------------------------
 
 There is early, experimental support for [Windows 10 on ARM](https://docs.microsoft.com/en-us/windows/arm/).
 This currently requires (a recent version of) MSVC, and the `Visual C++ compilers and libraries for ARM64`
@@ -314,8 +327,8 @@
 when launched with `--backend angle`, because the software backend tries to use OpenGL to display the
 window contents.
 
-CMake
------
+<span id="cmake">CMake</span>
+-----------------------------
 
 We have added a GN-to-CMake translator mainly for use with IDEs that like CMake
 project descriptions.  This is not meant for any purpose beyond development.