GN: get Angle compiling on Windows.

Angle does not yet link, but it does compile.

I chickened out and wrote cp.py to be the copy tool on Windows.  I've got all platforms using it for consistency.


CQ_INCLUDE_TRYBOTS=master.client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-ANGLE-Trybot


GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3533

Change-Id: I15f4b63a47121528b2fd2672c26c62765966147c
Reviewed-on: https://skia-review.googlesource.com/3533
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/third_party/angle2/BUILD.gn b/third_party/angle2/BUILD.gn
index 3ae0f8e..b3958ca 100644
--- a/third_party/angle2/BUILD.gn
+++ b/third_party/angle2/BUILD.gn
@@ -33,24 +33,32 @@
   defines = [
     "ANGLE_ENABLE_ESSL",
     "ANGLE_ENABLE_GLSL",
-    "GL_GLEXT_PROTOTYPES",
+    "ANGLE_ENABLE_OPENGL",
     "EGL_EGLEXT_PROTOTYPES",
+    "GL_GLEXT_PROTOTYPES",
   ]
   include_dirs = [
     "$root_gen_dir/angle2",
     "$angle_root/include",
     "$angle_root/src",
     "$angle_root/src/common/third_party/numerics",
+    "$angle_root/src/third_party/khronos",
   ]
 
-  assert(is_linux)  # TODO: is_win, of course, maybe is_mac?
+  assert(is_linux || is_win)  # TODO: is_mac?
   if (is_linux) {
     defines += [
-      "ANGLE_ENABLE_OPENGL",
       "ANGLE_USE_X11",
       "GL_APICALL=__attribute__((visibility(\"default\")))",
       "EGLAPI=__attribute__((visibility(\"default\")))",
     ]
+  } else if (is_win) {
+    defines += [
+      "ANGLE_ENABLE_D3D11",
+      "ANGLE_ENABLE_D3D9",
+      "GL_APICALL=",
+      "EGLAPI=",
+    ]
   }
 }
 
@@ -65,25 +73,27 @@
 
 shared_library("libGLESv2") {
   configs += [ ":common" ]
+  configs -= [ "//gn:warnings" ]
   defines = [ "LIBGLESV2_IMPLEMENTATION" ]
   deps = [
     ":commit_id",
   ]
   libs = []
-  sources = rebase_path(compiler_gypi.angle_preprocessor_sources +
-                            compiler_gypi.angle_translator_lib_sources +
-                            compiler_gypi.angle_translator_lib_essl_sources +
-                            compiler_gypi.angle_translator_lib_glsl_sources +
-                            gles_gypi.libangle_sources +
-                            gles_gypi.libangle_common_sources +
-                            gles_gypi.libangle_image_util_sources +
-                            gles_gypi.libglesv2_sources,
-                        ".",
-                        "$angle_root/src") +
-            [
-              "$angle_root/src/compiler/translator/ShaderLang.cpp",
-              "$angle_root/src/compiler/translator/ShaderVars.cpp",
-            ]
+  sources =
+      rebase_path(
+          compiler_gypi.angle_preprocessor_sources +
+              compiler_gypi.angle_translator_lib_sources +
+              compiler_gypi.angle_translator_lib_essl_sources +
+              compiler_gypi.angle_translator_lib_glsl_sources +
+              gles_gypi.libangle_sources + gles_gypi.libangle_common_sources +
+              gles_gypi.libangle_image_util_sources +
+              gles_gypi.libglesv2_sources + gles_gypi.libangle_gl_sources,
+          ".",
+          "$angle_root/src") +
+      [
+        "$angle_root/src/compiler/translator/ShaderLang.cpp",
+        "$angle_root/src/compiler/translator/ShaderVars.cpp",
+      ]
   if (!is_win) {
     sources -= [ "$angle_root/src/libGLESv2/libGLESv2.def" ]
   }
@@ -94,16 +104,33 @@
       "Xi",
       "Xext",
     ]
-    sources += rebase_path(gles_gypi.libangle_gl_sources +
-                               gles_gypi.libangle_gl_glx_sources,
+    sources +=
+        rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "$angle_root/src") +
+        [ "$angle_root/src/third_party/libXNVCtrl/NVCtrl.c" ]
+  } else if (is_win) {
+    defines += [
+      # TODO: ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
+    ]
+    sources += rebase_path(gles_gypi.libangle_gl_wgl_sources +
+                               gles_gypi.libangle_d3d_shared_sources +
+                               gles_gypi.libangle_d3d9_sources +
+                               gles_gypi.libangle_d3d11_sources +
+                               gles_gypi.libangle_d3d11_win32_sources,
                            ".",
-                           "$angle_root/src") +
-               [ "$angle_root/src/third_party/libXNVCtrl/NVCtrl.c" ]
+                           "$angle_root/src")
+    libs += [
+      "d3d9.lib",
+      "dxguid.lib",
+    ]
+    deps += [
+      # TODO: copy_compiler_dll?
+    ]
   }
 }
 
 shared_library("libEGL") {
   configs += [ ":common" ]
+  configs -= [ "//gn:warnings" ]
   defines = [ "LIBEGL_IMPLEMENTATION" ]
   deps = [
     ":libGLESv2",