blob: 707a488e755803ee3b2235bd9b9e837e06fdd238 [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 Madilledbc2442016-01-04 11:25:00 -050018gles_gypi = exec_script("//build/gypi_to_gn.py",
19 [ rebase_path("src/libGLESv2.gypi") ],
20 "scope",
21 [ "src/libGLESv2.gypi" ])
Brett Wilson04bac602014-07-16 14:19:18 -070022
Jamie Madilledbc2442016-01-04 11:25:00 -050023compiler_gypi = exec_script("//build/gypi_to_gn.py",
24 [ rebase_path("src/compiler.gypi") ],
25 "scope",
26 [ "src/compiler.gypi" ])
Brett Wilson04bac602014-07-16 14:19:18 -070027
Brett Wilson2f5469c2014-07-22 17:00:17 -070028# This config is exported to dependent targets (and also applied to internal
29# ones).
30config("external_config") {
Jamie Madilledbc2442016-01-04 11:25:00 -050031 include_dirs = [ "include" ]
Brett Wilson2f5469c2014-07-22 17:00:17 -070032}
33
Jamie Madill72f5b5e2014-06-23 15:13:02 -040034# This config is applied to internal Angle targets (not pushed to dependents).
35config("internal_config") {
36 include_dirs = [
37 "include",
38 "src",
39 ]
40}
41
Daniel Bratell73941de2015-02-25 14:34:49 +010042if (is_win) {
Daniel Bratell73941de2015-02-25 14:34:49 +010043 copy("copy_compiler_dll") {
Jamie Madilledbc2442016-01-04 11:25:00 -050044 sources = [
45 "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll",
46 ]
47 outputs = [
48 "$root_out_dir/d3dcompiler_47.dll",
49 ]
Daniel Bratell73941de2015-02-25 14:34:49 +010050 }
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
61 configs -= [ "//build/config/compiler:chromium_code" ]
62 configs += [
63 ":internal_config",
64 "//build/config/compiler:no_chromium_code",
65 ]
66
Brett Wilson10ac4042014-09-24 10:20:56 -070067 public_deps = [
Jamie Madill72f5b5e2014-06-23 15:13:02 -040068 ":translator_lib",
69 ]
70}
71
72# Holds the shared includes so we only need to list them once.
73source_set("includes") {
74 sources = [
75 "include/EGL/egl.h",
76 "include/EGL/eglext.h",
77 "include/EGL/eglplatform.h",
78 "include/GLES2/gl2.h",
79 "include/GLES2/gl2ext.h",
80 "include/GLES2/gl2platform.h",
81 "include/GLES3/gl3.h",
Geoff Langee483762015-09-15 13:12:07 -040082 "include/GLES3/gl31.h",
83 "include/GLES3/gl32.h",
Jamie Madilledbc2442016-01-04 11:25:00 -050084 "include/GLES3/gl3platform.h",
Jamie Madill72f5b5e2014-06-23 15:13:02 -040085 "include/GLSLANG/ShaderLang.h",
86 "include/KHR/khrplatform.h",
87 ]
88}
89
90static_library("preprocessor") {
Brett Wilson04bac602014-07-16 14:19:18 -070091 sources = rebase_path(compiler_gypi.angle_preprocessor_sources, ".", "src")
Jamie Madill72f5b5e2014-06-23 15:13:02 -040092
93 configs -= [ "//build/config/compiler:chromium_code" ]
94 configs += [
95 ":internal_config",
96 "//build/config/compiler:no_chromium_code",
97 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -040098}
99
Jamie Madille5c97ab2014-08-07 12:31:38 -0400100config("translator_static_config") {
101 defines = [ "ANGLE_TRANSLATOR_STATIC" ]
102}
103
Cooper Partin75da1972015-06-16 15:03:14 -0700104config("debug_annotations_config") {
105 if (is_debug) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500106 defines = [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
Cooper Partin75da1972015-06-16 15:03:14 -0700107 }
108}
109
Jamie Madill562e81b2015-01-14 14:31:02 -0500110static_library("angle_common") {
111 sources = rebase_path(gles_gypi.libangle_common_sources, ".", "src")
Cooper Partin75da1972015-06-16 15:03:14 -0700112
Jamie Madill562e81b2015-01-14 14:31:02 -0500113 configs -= [ "//build/config/compiler:chromium_code" ]
114 configs += [
115 ":internal_config",
Cooper Partin75da1972015-06-16 15:03:14 -0700116 ":debug_annotations_config",
Nico Weber47b53c02015-06-04 12:58:22 -0700117 "//build/config/compiler:no_chromium_code",
Jamie Madill562e81b2015-01-14 14:31:02 -0500118 ]
Jeremy Roman06feb812016-04-06 16:39:52 -0400119
Yuly Novikov87ae8cd2016-05-19 17:59:55 -0400120 public_deps = [
121 ":commit_id",
122 ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500123}
124
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400125static_library("translator_lib") {
Brett Wilson04bac602014-07-16 14:19:18 -0700126 sources = rebase_path(compiler_gypi.angle_translator_lib_sources, ".", "src")
Austin Kinross82b5ab62015-12-11 09:30:15 -0800127 defines = []
128
129 if (angle_enable_essl) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500130 sources +=
131 rebase_path(compiler_gypi.angle_translator_lib_essl_sources, ".", "src")
Austin Kinross82b5ab62015-12-11 09:30:15 -0800132 defines += [ "ANGLE_ENABLE_ESSL" ]
133 }
134
135 if (angle_enable_glsl) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500136 sources +=
137 rebase_path(compiler_gypi.angle_translator_lib_glsl_sources, ".", "src")
Austin Kinross82b5ab62015-12-11 09:30:15 -0800138 defines += [ "ANGLE_ENABLE_GLSL" ]
139 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400140
Daniel Bratell73941de2015-02-25 14:34:49 +0100141 if (angle_enable_hlsl) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500142 sources +=
143 rebase_path(compiler_gypi.angle_translator_lib_hlsl_sources, ".", "src")
Austin Kinross82b5ab62015-12-11 09:30:15 -0800144 defines += [ "ANGLE_ENABLE_HLSL" ]
Daniel Bratell73941de2015-02-25 14:34:49 +0100145 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400146 configs -= [ "//build/config/compiler:chromium_code" ]
147 configs += [
148 ":internal_config",
Jamie Madille5c97ab2014-08-07 12:31:38 -0400149 ":translator_static_config",
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400150 "//build/config/compiler:no_chromium_code",
151 ]
Brett Wilson10ac4042014-09-24 10:20:56 -0700152 public_configs = [ ":external_config" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400153
154 deps = [
155 ":includes",
156 ":preprocessor",
157 ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500158
159 public_deps = [
160 ":angle_common",
161 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400162}
163
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400164static_library("translator_static") {
165 sources = [
166 "src/compiler/translator/ShaderLang.cpp",
Jamie Madilla2ad4e82014-07-17 14:16:32 -0400167 "src/compiler/translator/ShaderVars.cpp",
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400168 ]
169
Daniel Bratell73941de2015-02-25 14:34:49 +0100170 if (angle_enable_hlsl) {
171 defines = [ "ANGLE_ENABLE_HLSL" ]
172 }
173
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400174 configs -= [ "//build/config/compiler:chromium_code" ]
175 configs += [
176 ":internal_config",
177 "//build/config/compiler:no_chromium_code",
178 ]
Brett Wilson10ac4042014-09-24 10:20:56 -0700179 public_configs = [ ":translator_static_config" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400180
Brett Wilson10ac4042014-09-24 10:20:56 -0700181 public_deps = [
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400182 ":translator_lib",
183 ]
184}
185
186config("commit_id_config") {
187 include_dirs = [ "$root_gen_dir/angle" ]
188}
189
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +0200190commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
191if (angle_use_commit_id) {
192 action("commit_id") {
193 script = "src/commit_id.py"
194 outputs = [
195 commit_id_output_file,
196 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400197
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +0200198 args = [
199 "gen",
200 rebase_path(".", root_build_dir),
201 rebase_path(commit_id_output_file, root_build_dir),
202 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400203
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +0200204 public_configs = [ ":commit_id_config" ]
205 }
206} else {
207 copy("commit_id") {
208 sources = [
209 "src/commit.h",
210 ]
211 outputs = [
212 commit_id_output_file,
213 ]
214 public_configs = [ ":commit_id_config" ]
215 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400216}
217
Jamie Madill562e81b2015-01-14 14:31:02 -0500218config("libANGLE_config") {
Austin Kinross40853472015-02-12 10:39:56 -0800219 cflags = []
Jamie Madill562e81b2015-01-14 14:31:02 -0500220 defines = []
221 if (angle_enable_d3d9) {
222 defines += [ "ANGLE_ENABLE_D3D9" ]
Geoff Lang2b5420c2014-11-19 14:20:15 -0500223 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500224 if (angle_enable_d3d11) {
225 defines += [ "ANGLE_ENABLE_D3D11" ]
226 }
Geoff Langc588ac72015-02-13 15:41:41 -0500227 if (angle_enable_gl) {
228 defines += [ "ANGLE_ENABLE_OPENGL" ]
Steven Bennetts369d03c2016-05-05 10:37:38 -0700229 if (use_x11) {
230 defines += [ "ANGLE_USE_X11" ]
231 }
Corentin Wallez51e2ad12015-05-26 11:32:58 -0400232 }
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400233 if (angle_enable_vulkan) {
234 defines += [ "ANGLE_ENABLE_VULKAN" ]
235 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500236 defines += [
Geoff Langee483762015-09-15 13:12:07 -0400237 "GL_GLEXT_PROTOTYPES",
Austin Kinross502f3df2015-12-02 12:33:18 -0800238 "EGL_EGLEXT_PROTOTYPES",
Jamie Madill562e81b2015-01-14 14:31:02 -0500239 ]
Corentin Wallezbeb81582015-09-02 10:30:55 -0400240
241 if (is_win) {
242 defines += [
243 "GL_APICALL=",
244 "EGLAPI=",
245 ]
246 } else {
247 defines += [
248 "GL_APICALL=__attribute__((visibility(\"default\")))",
249 "EGLAPI=__attribute__((visibility(\"default\")))",
250 ]
251 }
Austin Kinross40853472015-02-12 10:39:56 -0800252 if (is_win) {
253 cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics are not enabled.
254 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500255}
Geoff Lang2b5420c2014-11-19 14:20:15 -0500256
Jamie Madill562e81b2015-01-14 14:31:02 -0500257static_library("libANGLE") {
258 sources = rebase_path(gles_gypi.libangle_sources, ".", "src")
Geoff Lang2b5420c2014-11-19 14:20:15 -0500259
Geoff Langc588ac72015-02-13 15:41:41 -0500260 include_dirs = []
Jamie Madill562e81b2015-01-14 14:31:02 -0500261 libs = []
Jamie Madilledbc2442016-01-04 11:25:00 -0500262 defines = [ "LIBANGLE_IMPLEMENTATION" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400263
Corentin Wallezcc068e92016-02-29 16:37:04 -0500264 deps = [
265 ":angle_common",
266 ":commit_id",
267 ":includes",
268 ":translator_static",
269 ]
270
Jamie Madill562e81b2015-01-14 14:31:02 -0500271 # Shared D3D sources.
272 if (angle_enable_d3d9 || angle_enable_d3d11) {
273 sources += rebase_path(gles_gypi.libangle_d3d_shared_sources, ".", "src")
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400274
Jamie Madilledbc2442016-01-04 11:25:00 -0500275 defines += [ "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " + "\"d3dcompiler_47.dll\", \"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }" ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500276 }
Geoff Lang2b5420c2014-11-19 14:20:15 -0500277
Jamie Madill562e81b2015-01-14 14:31:02 -0500278 if (angle_enable_d3d9) {
279 sources += rebase_path(gles_gypi.libangle_d3d9_sources, ".", "src")
280 libs += [ "d3d9.lib" ]
281 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400282
Jamie Madill562e81b2015-01-14 14:31:02 -0500283 if (angle_enable_d3d11) {
284 sources += rebase_path(gles_gypi.libangle_d3d11_sources, ".", "src")
285 sources += rebase_path(gles_gypi.libangle_d3d11_win32_sources, ".", "src")
286 libs += [ "dxguid.lib" ]
287 }
288
Geoff Langc588ac72015-02-13 15:41:41 -0500289 if (angle_enable_gl) {
290 sources += rebase_path(gles_gypi.libangle_gl_sources, ".", "src")
291 include_dirs += [ "src/third_party/khronos" ]
292
293 if (is_win) {
294 sources += rebase_path(gles_gypi.libangle_gl_wgl_sources, ".", "src")
295 }
Corentin Wallez51e2ad12015-05-26 11:32:58 -0400296 if (use_x11) {
Corentin Wallez47fc1fe2015-05-14 10:54:18 -0400297 sources += rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "src")
Yuly Novikov87ae8cd2016-05-19 17:59:55 -0400298 deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
Corentin Wallezcc068e92016-02-29 16:37:04 -0500299 libs += [
300 "X11",
301 "Xi",
302 "Xext",
303 ]
Corentin Wallez47fc1fe2015-05-14 10:54:18 -0400304 }
Nico Weberde44d3a2016-05-13 17:27:57 -0400305 if (is_mac) {
306 sources += rebase_path(gles_gypi.libangle_gl_cgl_sources, ".", "src")
307 libs += [
308 "Cocoa.framework",
309 "IOSurface.framework",
310 "OpenGL.framework",
311 "QuartzCore.framework",
312 ]
313 }
Geoff Langc588ac72015-02-13 15:41:41 -0500314 }
315
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400316 if (angle_enable_vulkan) {
317 sources += rebase_path(gles_gypi.libangle_vulkan_sources, ".", "src")
318 }
319
Jamie Madill562e81b2015-01-14 14:31:02 -0500320 if (is_debug) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500321 defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400322 }
323
Jamie Madill562e81b2015-01-14 14:31:02 -0500324 configs -= [ "//build/config/compiler:chromium_code" ]
325 configs += [
326 ":commit_id_config",
Cooper Partin75da1972015-06-16 15:03:14 -0700327 ":debug_annotations_config",
Jamie Madill562e81b2015-01-14 14:31:02 -0500328 ":libANGLE_config",
329 ":internal_config",
330 "//build/config/compiler:no_chromium_code",
331 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400332
Jamie Madill562e81b2015-01-14 14:31:02 -0500333 if (is_win) {
John Baumane271a7e2016-05-11 17:03:32 -0700334 data_deps = [ ":copy_compiler_dll" ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500335 }
336}
337
338shared_library("libGLESv2") {
339 sources = rebase_path(gles_gypi.libglesv2_sources, ".", "src")
340
341 if (is_win) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500342 ldflags =
343 [ "/DEF:" + rebase_path("src/libGLESv2/libGLESv2.def", root_build_dir) ]
Geoff Lang2b5420c2014-11-19 14:20:15 -0500344 }
John Abd-El-Malek657cd682014-11-05 14:04:19 -0800345
Jamie Madill562e81b2015-01-14 14:31:02 -0500346 configs -= [ "//build/config/compiler:chromium_code" ]
347 configs += [
348 ":internal_config",
349 ":commit_id_config",
Cooper Partin75da1972015-06-16 15:03:14 -0700350 ":debug_annotations_config",
Jamie Madill562e81b2015-01-14 14:31:02 -0500351 ":libANGLE_config",
352 "//build/config/compiler:no_chromium_code",
353 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400354
Jamie Madilledbc2442016-01-04 11:25:00 -0500355 defines = [ "LIBGLESV2_IMPLEMENTATION" ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500356
357 deps = [
358 ":includes",
359 ":libANGLE",
360 ]
361}
362
363shared_library("libEGL") {
364 sources = rebase_path(gles_gypi.libegl_sources, ".", "src")
365
366 if (is_win) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500367 ldflags = [ "/DEF:" + rebase_path("src/libEGL/libEGL.def", root_build_dir) ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400368 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500369
370 configs -= [ "//build/config/compiler:chromium_code" ]
371 configs += [
372 ":internal_config",
373 ":commit_id_config",
Corentin Wallezbeb81582015-09-02 10:30:55 -0400374 ":debug_annotations_config",
Jamie Madill562e81b2015-01-14 14:31:02 -0500375 ":libANGLE_config",
376 "//build/config/compiler:no_chromium_code",
377 ]
378
Jamie Madilledbc2442016-01-04 11:25:00 -0500379 defines = [ "LIBEGL_IMPLEMENTATION" ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500380
381 deps = [
382 ":includes",
383 ":libGLESv2",
384 ]
385}
Corentin Wallezbeb81582015-09-02 10:30:55 -0400386
Jamie Madilledbc2442016-01-04 11:25:00 -0500387util_gypi = exec_script("//build/gypi_to_gn.py",
388 [ rebase_path("util/util.gyp") ],
389 "scope",
390 [ "util/util.gyp" ])
391
392config("angle_util_config") {
393 include_dirs = [ "util" ]
Jamie Madill1fae3552016-01-07 14:33:48 -0500394 if (is_linux) {
395 libs = [ "X11" ]
396 }
Jamie Madilledbc2442016-01-04 11:25:00 -0500397}
Corentin Wallezbeb81582015-09-02 10:30:55 -0400398
399static_library("angle_util") {
400 sources = rebase_path(util_gypi.util_sources, ".", "util")
401
402 if (is_win) {
403 sources += rebase_path(util_gypi.util_win32_sources, ".", "util")
404 }
405
406 if (is_linux) {
407 sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
Yuly Novikov87ae8cd2016-05-19 17:59:55 -0400408 libs = [
409 "rt",
410 "dl",
411 ]
Corentin Wallezbeb81582015-09-02 10:30:55 -0400412 }
413
414 if (is_mac) {
415 sources += rebase_path(util_gypi.util_osx_sources, ".", "util")
416 }
417
418 if (use_x11) {
419 sources += rebase_path(util_gypi.util_x11_sources, ".", "util")
420 }
421
Geoff Langee483762015-09-15 13:12:07 -0400422 defines = [
423 "GL_GLEXT_PROTOTYPES",
424 "EGL_EGLEXT_PROTOTYPES",
425 ]
426
Jamie Madilledbc2442016-01-04 11:25:00 -0500427 configs += [ ":debug_annotations_config" ]
Corentin Wallezbeb81582015-09-02 10:30:55 -0400428
Jamie Madilledbc2442016-01-04 11:25:00 -0500429 public_configs = [
430 ":angle_util_config",
431 ":internal_config",
Corentin Wallezbeb81582015-09-02 10:30:55 -0400432 ]
433
434 deps = [
Jamie Madill1fae3552016-01-07 14:33:48 -0500435 ":angle_common",
Corentin Wallezbeb81582015-09-02 10:30:55 -0400436 ":libEGL",
437 ":libGLESv2",
438 ]
439}