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>
This commit is contained in:
Mike Klein 2016-10-17 11:51:11 -04:00
parent c7a46650bc
commit 1a8d675148
3 changed files with 109 additions and 22 deletions

View File

@ -399,6 +399,36 @@ toolchain("msvc") {
description = "link {{output}}"
}
tool("solink") {
dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
libname = "${dllname}.lib"
pdbname = "${dllname}.pdb"
rspfile = "${dllname}.rsp"
command = "$env_setup$bin/link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
outputs = [
dllname,
libname,
pdbname,
]
default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}"
link_output = libname
depend_output = libname
runtime_outputs = [
dllname,
pdbname,
]
# I don't quite understand this. Aping Chrome's toolchain/win/BUILD.gn.
restat = true
# inputs_newline works around a fixed per-line buffer size in the linker.
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
description = "link {{output}}"
}
tool("link") {
exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
pdbname = "$exename.pdb"
@ -422,6 +452,12 @@ toolchain("msvc") {
command = "cmd.exe /c echo > {{output}}"
description = "stamp {{output}}"
}
tool("copy") {
cp_py = rebase_path("cp.py")
command = "python.exe $cp_py {{source}} {{output}}"
description = "copy {{source}} {{output}}"
}
}
toolchain("gcc_like") {
@ -499,7 +535,8 @@ toolchain("gcc_like") {
}
tool("copy") {
command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
cp_py = rebase_path("cp.py")
command = "python $cp_py {{source}} {{output}}"
description = "copy {{source}} {{output}}"
}
}

23
gn/cp.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
#
# Copyright 2016 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 shutil
import sys
src, dst = sys.argv[1:]
if os.path.exists(dst):
if os.path.isdir(dst):
shutil.rmtree(dst)
else:
os.remove(dst)
if os.path.isdir(src):
shutil.copytree(src, dst)
else:
shutil.copy2(src, dst)

View File

@ -33,24 +33,32 @@ config("common") {
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 @@ copy("commit_id") {
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 @@ shared_library("libGLESv2") {
"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",