blob: 88bad294347641ceeaec136119e495fa940aabaa [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 ]
mtkleind68f9b02016-09-23 13:18:41 -070063 }
64}
65
66copy("commit_id") {
67 sources = [
68 "$angle_root/src/commit.h",
69 ]
70 outputs = [
71 "$root_gen_dir/angle2/id/commit.h",
72 ]
73}
74
75shared_library("libGLESv2") {
76 configs += [ ":common" ]
Mike Klein1a8d6752016-10-17 11:51:11 -040077 configs -= [ "//gn:warnings" ]
Mike Kleina2c2fdd2016-10-17 12:34:38 -040078 defines = [
79 "LIBANGLE_IMPLEMENTATION",
80 "LIBGLESV2_IMPLEMENTATION",
81 ]
mtkleind68f9b02016-09-23 13:18:41 -070082 deps = [
83 ":commit_id",
84 ]
85 libs = []
Brian Osman21d742d2017-01-10 13:31:33 -050086 sources = rebase_path(
Mike Klein1a8d6752016-10-17 11:51:11 -040087 compiler_gypi.angle_preprocessor_sources +
Brian Osman21d742d2017-01-10 13:31:33 -050088 compiler_gypi.angle_translator_sources +
89 compiler_gypi.angle_translator_essl_sources +
90 compiler_gypi.angle_translator_glsl_sources +
91 compiler_gypi.angle_translator_hlsl_sources +
Mike Klein1a8d6752016-10-17 11:51:11 -040092 gles_gypi.libangle_sources + gles_gypi.libangle_common_sources +
93 gles_gypi.libangle_image_util_sources +
94 gles_gypi.libglesv2_sources + gles_gypi.libangle_gl_sources,
95 ".",
Brian Osman21d742d2017-01-10 13:31:33 -050096 "$angle_root/src")
mtkleind68f9b02016-09-23 13:18:41 -070097 if (!is_win) {
98 sources -= [ "$angle_root/src/libGLESv2/libGLESv2.def" ]
99 }
100
101 if (is_linux) {
102 libs += [
103 "X11",
104 "Xi",
105 "Xext",
106 ]
Mike Klein1a8d6752016-10-17 11:51:11 -0400107 sources +=
108 rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "$angle_root/src") +
109 [ "$angle_root/src/third_party/libXNVCtrl/NVCtrl.c" ]
110 } else if (is_win) {
111 defines += [
112 # TODO: ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
113 ]
114 sources += rebase_path(gles_gypi.libangle_gl_wgl_sources +
115 gles_gypi.libangle_d3d_shared_sources +
116 gles_gypi.libangle_d3d9_sources +
117 gles_gypi.libangle_d3d11_sources +
118 gles_gypi.libangle_d3d11_win32_sources,
mtkleind68f9b02016-09-23 13:18:41 -0700119 ".",
Mike Klein1a8d6752016-10-17 11:51:11 -0400120 "$angle_root/src")
121 libs += [
122 "d3d9.lib",
123 "dxguid.lib",
Mike Kleina2c2fdd2016-10-17 12:34:38 -0400124 "gdi32.lib",
125 "user32.lib",
Mike Klein1a8d6752016-10-17 11:51:11 -0400126 ]
127 deps += [
128 # TODO: copy_compiler_dll?
129 ]
mtkleind68f9b02016-09-23 13:18:41 -0700130 }
131}
132
133shared_library("libEGL") {
134 configs += [ ":common" ]
Mike Klein1a8d6752016-10-17 11:51:11 -0400135 configs -= [ "//gn:warnings" ]
mtkleind68f9b02016-09-23 13:18:41 -0700136 defines = [ "LIBEGL_IMPLEMENTATION" ]
137 deps = [
138 ":libGLESv2",
139 ]
140 sources = rebase_path(gles_gypi.libegl_sources, ".", "$angle_root/src")
141 if (!is_win) {
142 sources -= [ "$angle_root/src/libEGL/libEGL.def" ]
143 }
144}