blob: c540bfa6692a5ba0767eac8400cdedbf778e4fe5 [file] [log] [blame]
mtkleind68f9b02016-09-23 13:18:41 -07001# Copyright 2016 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6declare_args() {
7}
8
9angle_root = "../externals/angle2"
10
11import("../third_party.gni")
12
13third_party("angle2") {
14 public_include_dirs = [ "$angle_root/include" ]
15 deps = [
16 ":libEGL",
17 ":libGLESv2",
18 ]
19}
20
21compiler_gypi = exec_script("//gn/gypi_to_gn.py",
22 [ rebase_path("$angle_root/src/compiler.gypi") ],
23 "scope",
24 [])
25
26gles_gypi = exec_script("//gn/gypi_to_gn.py",
27 [ rebase_path("$angle_root/src/libGLESv2.gypi") ],
28 "scope",
29 [])
30
31config("common") {
mtkleind68f9b02016-09-23 13:18:41 -070032 defines = [
33 "ANGLE_ENABLE_ESSL",
34 "ANGLE_ENABLE_GLSL",
Mike Kleina2c2fdd2016-10-17 12:34:38 -040035 "ANGLE_ENABLE_HLSL",
Mike Klein1a8d6752016-10-17 11:51:11 -040036 "ANGLE_ENABLE_OPENGL",
mtkleind68f9b02016-09-23 13:18:41 -070037 "EGL_EGLEXT_PROTOTYPES",
Mike Klein1a8d6752016-10-17 11:51:11 -040038 "GL_GLEXT_PROTOTYPES",
mtkleind68f9b02016-09-23 13:18:41 -070039 ]
40 include_dirs = [
41 "$root_gen_dir/angle2",
42 "$angle_root/include",
43 "$angle_root/src",
Robert Phillipsffaa47e2017-06-12 08:40:56 -040044 "$angle_root/src/common/third_party/base",
Mike Klein1a8d6752016-10-17 11:51:11 -040045 "$angle_root/src/third_party/khronos",
mtkleind68f9b02016-09-23 13:18:41 -070046 ]
Brian Salomon80094882017-08-18 11:44:28 -040047 cflags_cc = []
Mike Klein1a8d6752016-10-17 11:51:11 -040048 assert(is_linux || is_win) # TODO: is_mac?
mtkleind68f9b02016-09-23 13:18:41 -070049 if (is_linux) {
50 defines += [
mtkleind68f9b02016-09-23 13:18:41 -070051 "ANGLE_USE_X11",
52 "GL_APICALL=__attribute__((visibility(\"default\")))",
53 "EGLAPI=__attribute__((visibility(\"default\")))",
54 ]
Brian Salomon80094882017-08-18 11:44:28 -040055 cflags_cc += [ "-std=c++14" ]
Mike Klein1a8d6752016-10-17 11:51:11 -040056 } else if (is_win) {
57 defines += [
58 "ANGLE_ENABLE_D3D11",
59 "ANGLE_ENABLE_D3D9",
60 "GL_APICALL=",
61 "EGLAPI=",
62 ]
Brian Osman514094c2017-11-12 13:53:26 -050063
64 # Allow noexcept, even though we build without exceptions
65 cflags_cc += [ "/wd4577" ]
mtkleind68f9b02016-09-23 13:18:41 -070066 }
67}
68
69copy("commit_id") {
70 sources = [
71 "$angle_root/src/commit.h",
72 ]
73 outputs = [
74 "$root_gen_dir/angle2/id/commit.h",
75 ]
76}
77
78shared_library("libGLESv2") {
79 configs += [ ":common" ]
Mike Klein1a8d6752016-10-17 11:51:11 -040080 configs -= [ "//gn:warnings" ]
Mike Kleina2c2fdd2016-10-17 12:34:38 -040081 defines = [
82 "LIBANGLE_IMPLEMENTATION",
83 "LIBGLESV2_IMPLEMENTATION",
84 ]
mtkleind68f9b02016-09-23 13:18:41 -070085 deps = [
86 ":commit_id",
87 ]
88 libs = []
Brian Osman21d742d2017-01-10 13:31:33 -050089 sources = rebase_path(
Mike Klein1a8d6752016-10-17 11:51:11 -040090 compiler_gypi.angle_preprocessor_sources +
Brian Osman21d742d2017-01-10 13:31:33 -050091 compiler_gypi.angle_translator_sources +
92 compiler_gypi.angle_translator_essl_sources +
93 compiler_gypi.angle_translator_glsl_sources +
94 compiler_gypi.angle_translator_hlsl_sources +
Mike Klein1a8d6752016-10-17 11:51:11 -040095 gles_gypi.libangle_sources + gles_gypi.libangle_common_sources +
96 gles_gypi.libangle_image_util_sources +
97 gles_gypi.libglesv2_sources + gles_gypi.libangle_gl_sources,
98 ".",
Brian Osman21d742d2017-01-10 13:31:33 -050099 "$angle_root/src")
mtkleind68f9b02016-09-23 13:18:41 -0700100 if (!is_win) {
101 sources -= [ "$angle_root/src/libGLESv2/libGLESv2.def" ]
102 }
103
104 if (is_linux) {
105 libs += [
106 "X11",
107 "Xi",
108 "Xext",
109 ]
Mike Klein1a8d6752016-10-17 11:51:11 -0400110 sources +=
111 rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "$angle_root/src") +
112 [ "$angle_root/src/third_party/libXNVCtrl/NVCtrl.c" ]
113 } else if (is_win) {
114 defines += [
115 # TODO: ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
116 ]
117 sources += rebase_path(gles_gypi.libangle_gl_wgl_sources +
118 gles_gypi.libangle_d3d_shared_sources +
119 gles_gypi.libangle_d3d9_sources +
120 gles_gypi.libangle_d3d11_sources +
121 gles_gypi.libangle_d3d11_win32_sources,
mtkleind68f9b02016-09-23 13:18:41 -0700122 ".",
Mike Klein1a8d6752016-10-17 11:51:11 -0400123 "$angle_root/src")
124 libs += [
125 "d3d9.lib",
126 "dxguid.lib",
Mike Kleina2c2fdd2016-10-17 12:34:38 -0400127 "gdi32.lib",
128 "user32.lib",
Mike Klein1a8d6752016-10-17 11:51:11 -0400129 ]
130 deps += [
131 # TODO: copy_compiler_dll?
132 ]
mtkleind68f9b02016-09-23 13:18:41 -0700133 }
134}
135
136shared_library("libEGL") {
137 configs += [ ":common" ]
Mike Klein1a8d6752016-10-17 11:51:11 -0400138 configs -= [ "//gn:warnings" ]
mtkleind68f9b02016-09-23 13:18:41 -0700139 defines = [ "LIBEGL_IMPLEMENTATION" ]
140 deps = [
141 ":libGLESv2",
142 ]
143 sources = rebase_path(gles_gypi.libegl_sources, ".", "$angle_root/src")
144 if (!is_win) {
145 sources -= [ "$angle_root/src/libEGL/libEGL.def" ]
146 }
147}