blob: 7cface7753fee75fb587cce42e2731a69bc3b31c [file] [log] [blame]
Corentin Wallezd4bcfa22015-09-01 10:32:30 -04001# Copyright 2014-2015 The Chromium Authors. All rights reserved.
Jamie Madill72f5b5e2014-06-23 15:13:02 -04002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Corentin Wallez51e2ad12015-05-26 11:32:58 -04005# import the use_x11 variable
6import("//build/config/ui.gni")
Corentin Wallezd4bcfa22015-09-01 10:32:30 -04007import("//third_party/angle/build/angle_common.gni")
Corentin Wallez51e2ad12015-05-26 11:32:58 -04008
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +02009angle_git_is_present = exec_script("src/commit_id.py",
10 [
11 "check",
12 rebase_path(".", root_build_dir),
13 ],
14 "value")
15
16angle_use_commit_id = angle_git_is_present == 1
17
Jamie Madill562e81b2015-01-14 14:31:02 -050018gles_gypi = exec_script(
19 "//build/gypi_to_gn.py",
20 [ rebase_path("src/libGLESv2.gypi") ],
21 "scope",
22 [ "src/libGLESv2.gypi" ])
Brett Wilson04bac602014-07-16 14:19:18 -070023
24compiler_gypi = exec_script(
Jamie Madill562e81b2015-01-14 14:31:02 -050025 "//build/gypi_to_gn.py",
26 [ rebase_path("src/compiler.gypi") ],
27 "scope",
28 [ "src/compiler.gypi" ])
Brett Wilson04bac602014-07-16 14:19:18 -070029
Brett Wilson2f5469c2014-07-22 17:00:17 -070030# This config is exported to dependent targets (and also applied to internal
31# ones).
32config("external_config") {
33 include_dirs = [
34 "include",
35 ]
36}
37
Jamie Madill72f5b5e2014-06-23 15:13:02 -040038# This config is applied to internal Angle targets (not pushed to dependents).
39config("internal_config") {
40 include_dirs = [
41 "include",
42 "src",
43 ]
44}
45
Daniel Bratell73941de2015-02-25 14:34:49 +010046if (is_win) {
Daniel Bratell73941de2015-02-25 14:34:49 +010047 copy("copy_compiler_dll") {
Dirk Prankea17e77f2015-03-18 14:58:49 -070048 sources = [ "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll" ]
Daniel Bratell73941de2015-02-25 14:34:49 +010049 outputs = [ "$root_build_dir/d3dcompiler_47.dll" ]
50 }
Daniel Bratell73941de2015-02-25 14:34:49 +010051}
52
Jamie Madill72f5b5e2014-06-23 15:13:02 -040053component("translator") {
54 sources = [
55 "src/compiler/translator/ShaderLang.cpp",
Jamie Madille5c97ab2014-08-07 12:31:38 -040056 "src/compiler/translator/ShaderVars.cpp",
Jamie Madill72f5b5e2014-06-23 15:13:02 -040057 ]
58
59 defines = [ "ANGLE_TRANSLATOR_IMPLEMENTATION" ]
60
Daniel Bratell73941de2015-02-25 14:34:49 +010061 if (angle_enable_hlsl) {
62 sources += rebase_path(compiler_gypi.angle_translator_lib_hlsl_sources, ".", "src")
63 defines += [ "ANGLE_ENABLE_HLSL" ]
64 }
65
Jamie Madill72f5b5e2014-06-23 15:13:02 -040066 configs -= [ "//build/config/compiler:chromium_code" ]
67 configs += [
68 ":internal_config",
69 "//build/config/compiler:no_chromium_code",
70 ]
71
Brett Wilson10ac4042014-09-24 10:20:56 -070072 public_deps = [
Jamie Madill72f5b5e2014-06-23 15:13:02 -040073 ":translator_lib",
74 ]
75}
76
77# Holds the shared includes so we only need to list them once.
78source_set("includes") {
79 sources = [
80 "include/EGL/egl.h",
81 "include/EGL/eglext.h",
82 "include/EGL/eglplatform.h",
83 "include/GLES2/gl2.h",
84 "include/GLES2/gl2ext.h",
85 "include/GLES2/gl2platform.h",
86 "include/GLES3/gl3.h",
Jamie Madill72f5b5e2014-06-23 15:13:02 -040087 "include/GLES3/gl3platform.h",
Geoff Langee483762015-09-15 13:12:07 -040088 "include/GLES3/gl31.h",
89 "include/GLES3/gl32.h",
Jamie Madill72f5b5e2014-06-23 15:13:02 -040090 "include/GLSLANG/ShaderLang.h",
91 "include/KHR/khrplatform.h",
92 ]
93}
94
95static_library("preprocessor") {
Brett Wilson04bac602014-07-16 14:19:18 -070096 sources = rebase_path(compiler_gypi.angle_preprocessor_sources, ".", "src")
Jamie Madill72f5b5e2014-06-23 15:13:02 -040097
98 configs -= [ "//build/config/compiler:chromium_code" ]
99 configs += [
100 ":internal_config",
101 "//build/config/compiler:no_chromium_code",
102 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400103}
104
Jamie Madille5c97ab2014-08-07 12:31:38 -0400105config("translator_static_config") {
106 defines = [ "ANGLE_TRANSLATOR_STATIC" ]
107}
108
Corentin Wallezbeb81582015-09-02 10:30:55 -0400109
Cooper Partin75da1972015-06-16 15:03:14 -0700110config("debug_annotations_config") {
111 if (is_debug) {
112 defines = [
113 "ANGLE_ENABLE_DEBUG_ANNOTATIONS",
114 ]
115 }
116}
117
Jamie Madill562e81b2015-01-14 14:31:02 -0500118static_library("angle_common") {
119 sources = rebase_path(gles_gypi.libangle_common_sources, ".", "src")
Cooper Partin75da1972015-06-16 15:03:14 -0700120
Jamie Madill562e81b2015-01-14 14:31:02 -0500121 configs -= [ "//build/config/compiler:chromium_code" ]
122 configs += [
123 ":internal_config",
Cooper Partin75da1972015-06-16 15:03:14 -0700124 ":debug_annotations_config",
Nico Weber47b53c02015-06-04 12:58:22 -0700125 "//build/config/compiler:no_chromium_code",
Jamie Madill562e81b2015-01-14 14:31:02 -0500126 ]
127}
128
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400129static_library("translator_lib") {
Brett Wilson04bac602014-07-16 14:19:18 -0700130 sources = rebase_path(compiler_gypi.angle_translator_lib_sources, ".", "src")
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400131
Daniel Bratell73941de2015-02-25 14:34:49 +0100132 if (angle_enable_hlsl) {
133 sources += rebase_path(compiler_gypi.angle_translator_lib_hlsl_sources, ".", "src")
134 defines = [ "ANGLE_ENABLE_HLSL" ]
135 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400136 configs -= [ "//build/config/compiler:chromium_code" ]
137 configs += [
138 ":internal_config",
Jamie Madille5c97ab2014-08-07 12:31:38 -0400139 ":translator_static_config",
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400140 "//build/config/compiler:no_chromium_code",
141 ]
Brett Wilson10ac4042014-09-24 10:20:56 -0700142 public_configs = [ ":external_config" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400143
144 deps = [
145 ":includes",
146 ":preprocessor",
147 ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500148
149 public_deps = [
150 ":angle_common",
151 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400152}
153
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400154static_library("translator_static") {
155 sources = [
156 "src/compiler/translator/ShaderLang.cpp",
Jamie Madilla2ad4e82014-07-17 14:16:32 -0400157 "src/compiler/translator/ShaderVars.cpp",
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400158 ]
159
Daniel Bratell73941de2015-02-25 14:34:49 +0100160 if (angle_enable_hlsl) {
161 defines = [ "ANGLE_ENABLE_HLSL" ]
162 }
163
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400164 configs -= [ "//build/config/compiler:chromium_code" ]
165 configs += [
166 ":internal_config",
167 "//build/config/compiler:no_chromium_code",
168 ]
Brett Wilson10ac4042014-09-24 10:20:56 -0700169 public_configs = [ ":translator_static_config" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400170
Brett Wilson10ac4042014-09-24 10:20:56 -0700171 public_deps = [
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400172 ":translator_lib",
173 ]
174}
175
176config("commit_id_config") {
177 include_dirs = [ "$root_gen_dir/angle" ]
178}
179
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +0200180commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
181if (angle_use_commit_id) {
182 action("commit_id") {
183 script = "src/commit_id.py"
184 outputs = [
185 commit_id_output_file,
186 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400187
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +0200188 args = [
189 "gen",
190 rebase_path(".", root_build_dir),
191 rebase_path(commit_id_output_file, root_build_dir),
192 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400193
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +0200194 public_configs = [ ":commit_id_config" ]
195 }
196} else {
197 copy("commit_id") {
198 sources = [
199 "src/commit.h",
200 ]
201 outputs = [
202 commit_id_output_file,
203 ]
204 public_configs = [ ":commit_id_config" ]
205 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400206}
207
Jamie Madill562e81b2015-01-14 14:31:02 -0500208config("libANGLE_config") {
Austin Kinross40853472015-02-12 10:39:56 -0800209 cflags = []
Jamie Madill562e81b2015-01-14 14:31:02 -0500210 defines = []
211 if (angle_enable_d3d9) {
212 defines += [ "ANGLE_ENABLE_D3D9" ]
Geoff Lang2b5420c2014-11-19 14:20:15 -0500213 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500214 if (angle_enable_d3d11) {
215 defines += [ "ANGLE_ENABLE_D3D11" ]
216 }
Geoff Langc588ac72015-02-13 15:41:41 -0500217 if (angle_enable_gl) {
218 defines += [ "ANGLE_ENABLE_OPENGL" ]
219 }
Corentin Wallez51e2ad12015-05-26 11:32:58 -0400220 if (use_x11) {
221 defines += [ "ANGLE_USE_X11" ]
222 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500223 defines += [
Geoff Langee483762015-09-15 13:12:07 -0400224 "GL_GLEXT_PROTOTYPES",
Austin Kinross502f3df2015-12-02 12:33:18 -0800225 "EGL_EGLEXT_PROTOTYPES",
Jamie Madill562e81b2015-01-14 14:31:02 -0500226 ]
Corentin Wallezbeb81582015-09-02 10:30:55 -0400227
228 if (is_win) {
229 defines += [
230 "GL_APICALL=",
231 "EGLAPI=",
232 ]
233 } else {
234 defines += [
235 "GL_APICALL=__attribute__((visibility(\"default\")))",
236 "EGLAPI=__attribute__((visibility(\"default\")))",
237 ]
238 }
Austin Kinross40853472015-02-12 10:39:56 -0800239 if (is_win) {
240 cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics are not enabled.
241 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500242}
Geoff Lang2b5420c2014-11-19 14:20:15 -0500243
Jamie Madill562e81b2015-01-14 14:31:02 -0500244static_library("libANGLE") {
245 sources = rebase_path(gles_gypi.libangle_sources, ".", "src")
Geoff Lang2b5420c2014-11-19 14:20:15 -0500246
Geoff Langc588ac72015-02-13 15:41:41 -0500247 include_dirs = []
Jamie Madill562e81b2015-01-14 14:31:02 -0500248 libs = []
249 defines = [
250 "LIBANGLE_IMPLEMENTATION",
251 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400252
Jamie Madill562e81b2015-01-14 14:31:02 -0500253 # Shared D3D sources.
254 if (angle_enable_d3d9 || angle_enable_d3d11) {
255 sources += rebase_path(gles_gypi.libangle_d3d_shared_sources, ".", "src")
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400256
Geoff Lang2b5420c2014-11-19 14:20:15 -0500257 defines += [
258 "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " +
259 "\"d3dcompiler_47.dll\", \"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }",
260 ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500261 }
Geoff Lang2b5420c2014-11-19 14:20:15 -0500262
Jamie Madill562e81b2015-01-14 14:31:02 -0500263 if (angle_enable_d3d9) {
264 sources += rebase_path(gles_gypi.libangle_d3d9_sources, ".", "src")
265 libs += [ "d3d9.lib" ]
266 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400267
Jamie Madill562e81b2015-01-14 14:31:02 -0500268 if (angle_enable_d3d11) {
269 sources += rebase_path(gles_gypi.libangle_d3d11_sources, ".", "src")
270 sources += rebase_path(gles_gypi.libangle_d3d11_win32_sources, ".", "src")
271 libs += [ "dxguid.lib" ]
272 }
273
Geoff Langc588ac72015-02-13 15:41:41 -0500274 if (angle_enable_gl) {
275 sources += rebase_path(gles_gypi.libangle_gl_sources, ".", "src")
276 include_dirs += [ "src/third_party/khronos" ]
277
278 if (is_win) {
279 sources += rebase_path(gles_gypi.libangle_gl_wgl_sources, ".", "src")
280 }
Corentin Wallez51e2ad12015-05-26 11:32:58 -0400281 if (use_x11) {
Corentin Wallez47fc1fe2015-05-14 10:54:18 -0400282 sources += rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "src")
283 libs += [ "X11" ]
284 }
Geoff Langc588ac72015-02-13 15:41:41 -0500285 }
286
Jamie Madill562e81b2015-01-14 14:31:02 -0500287 if (is_debug) {
288 defines += [
289 "ANGLE_GENERATE_SHADER_DEBUG_INFO",
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400290 ]
291 }
292
Jamie Madill562e81b2015-01-14 14:31:02 -0500293 configs -= [ "//build/config/compiler:chromium_code" ]
294 configs += [
295 ":commit_id_config",
Cooper Partin75da1972015-06-16 15:03:14 -0700296 ":debug_annotations_config",
Jamie Madill562e81b2015-01-14 14:31:02 -0500297 ":libANGLE_config",
298 ":internal_config",
299 "//build/config/compiler:no_chromium_code",
300 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400301
Jamie Madill562e81b2015-01-14 14:31:02 -0500302 deps = [
303 ":commit_id",
304 ":includes",
Brett Wilsona662abb2015-04-07 12:55:30 -0700305 ":translator_static",
Jamie Madill562e81b2015-01-14 14:31:02 -0500306 ":angle_common",
307 ]
308
309 if (is_win) {
310 deps += [ ":copy_compiler_dll" ]
311 }
312}
313
314shared_library("libGLESv2") {
315 sources = rebase_path(gles_gypi.libglesv2_sources, ".", "src")
316
317 if (is_win) {
John Abd-El-Malek330f0ad2014-11-05 13:14:01 -0800318 ldflags = [ "/DEF:" +
Jamie Madill562e81b2015-01-14 14:31:02 -0500319 rebase_path("src/libGLESv2/libGLESv2.def", root_build_dir) ]
Geoff Lang2b5420c2014-11-19 14:20:15 -0500320 }
John Abd-El-Malek657cd682014-11-05 14:04:19 -0800321
Jamie Madill562e81b2015-01-14 14:31:02 -0500322 configs -= [ "//build/config/compiler:chromium_code" ]
323 configs += [
324 ":internal_config",
325 ":commit_id_config",
Cooper Partin75da1972015-06-16 15:03:14 -0700326 ":debug_annotations_config",
Jamie Madill562e81b2015-01-14 14:31:02 -0500327 ":libANGLE_config",
328 "//build/config/compiler:no_chromium_code",
329 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400330
Jamie Madill562e81b2015-01-14 14:31:02 -0500331 defines = [
332 "LIBGLESV2_IMPLEMENTATION",
333 ]
334
335 deps = [
336 ":includes",
337 ":libANGLE",
338 ]
339}
340
341shared_library("libEGL") {
342 sources = rebase_path(gles_gypi.libegl_sources, ".", "src")
343
344 if (is_win) {
Geoff Lang2b5420c2014-11-19 14:20:15 -0500345 ldflags = [ "/DEF:" +
Jamie Madill562e81b2015-01-14 14:31:02 -0500346 rebase_path("src/libEGL/libEGL.def", root_build_dir) ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400347 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500348
349 configs -= [ "//build/config/compiler:chromium_code" ]
350 configs += [
351 ":internal_config",
352 ":commit_id_config",
Corentin Wallezbeb81582015-09-02 10:30:55 -0400353 ":debug_annotations_config",
Jamie Madill562e81b2015-01-14 14:31:02 -0500354 ":libANGLE_config",
355 "//build/config/compiler:no_chromium_code",
356 ]
357
358 defines = [
359 "LIBEGL_IMPLEMENTATION",
360 ]
361
362 deps = [
363 ":includes",
364 ":libGLESv2",
365 ]
366}
Corentin Wallezbeb81582015-09-02 10:30:55 -0400367
368util_gypi = exec_script(
369 "//build/gypi_to_gn.py",
370 [ rebase_path("util/util.gyp") ],
371 "scope",
372 [ "util/util.gyp" ])
373
374static_library("angle_util") {
375 sources = rebase_path(util_gypi.util_sources, ".", "util")
376
377 if (is_win) {
378 sources += rebase_path(util_gypi.util_win32_sources, ".", "util")
379 }
380
381 if (is_linux) {
382 sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
Dirk Prankeac0f9b12015-11-12 14:54:10 -0800383 libs = [ "rt" ]
Corentin Wallezbeb81582015-09-02 10:30:55 -0400384 }
385
386 if (is_mac) {
387 sources += rebase_path(util_gypi.util_osx_sources, ".", "util")
388 }
389
390 if (use_x11) {
391 sources += rebase_path(util_gypi.util_x11_sources, ".", "util")
392 }
393
Geoff Langee483762015-09-15 13:12:07 -0400394 defines = [
395 "GL_GLEXT_PROTOTYPES",
396 "EGL_EGLEXT_PROTOTYPES",
397 ]
398
Corentin Wallezbeb81582015-09-02 10:30:55 -0400399 configs += [
400 ":internal_config",
401 ":debug_annotations_config",
402 ]
403
404 include_dirs = [
405 "util",
406 ]
407
408 deps = [
409 ":libEGL",
410 ":libGLESv2",
411 ]
412}