blob: 7547a4d1b90bc89658f129b1bc26d61372045195 [file] [log] [blame]
Jamie Madill0cb3b0f2019-01-28 09:55:20 -05001# Copyright 2019 The ANGLE Project 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
Frank Henigmand0ef13a2017-08-28 22:53:24 -04006import("gni/angle.gni")
Jamie Madill1ba72542019-10-04 15:17:49 -04007if (angle_has_build) {
8 import("//build/config/linux/pkg_config.gni")
9 import("//build/config/ui.gni")
10 import("//testing/libfuzzer/fuzzer_test.gni")
11
12 if (is_android) {
13 # android/rules.gni can only be imported for Android targets
14 import("//build/config/android/config.gni")
15 import("//build/config/android/rules.gni")
16 import("android/angle_apk.gni")
17 }
Courtney Goeltzenleuchter2565d482018-04-12 17:06:48 -060018}
Corentin Wallez51e2ad12015-05-26 11:32:58 -040019
Corentin Wallez16d4e472017-03-20 13:06:19 -040020declare_args() {
21 # Use the PCI lib to collect GPU information on Linux.
22 use_libpci = is_linux && (!is_chromecast || is_cast_desktop_build) &&
Jamie Madill8970ad32020-08-26 12:59:19 -040023 (angle_use_x11 || use_ozone) && angle_has_build
Frank Henigmane42ec182017-12-11 23:58:53 -050024
25 # Link in system libGL, to work with apitrace. See doc/DebuggingTips.md.
26 angle_link_glx = false
Jamie Madilleb1b1642019-07-30 17:22:17 -040027
28 # Defaults to capture building to $root_out_dir/angle_libs/with_capture.
29 # Switch on to build capture to $root_out_dir.
30 angle_with_capture_by_default = false
Austin Kinross11dc1632019-09-18 14:46:23 -070031
32 # Don't build extra (test, samples etc) for Windows UWP. We don't have
33 # infrastructure (e.g. windowing helper functions) in place to run them.
Jamie Madille3c25712019-12-03 14:08:36 -050034 angle_build_all = !build_with_chromium && !angle_is_winuwp && angle_has_build
Geoff Lange8883562020-03-06 09:32:18 -050035
36 # Enable generating current commit information using git
37 angle_enable_commit_id = true
Corentin Wallez16d4e472017-03-20 13:06:19 -040038}
39
Jamie Madille3c25712019-12-03 14:08:36 -050040if (angle_build_all) {
Frank Henigmand0ef13a2017-08-28 22:53:24 -040041 group("all") {
42 testonly = true
43 deps = [
Jamie Madille3c25712019-12-03 14:08:36 -050044 ":angle",
Frank Henigmand0ef13a2017-08-28 22:53:24 -040045 ":angle_shader_translator",
46 ":translator_fuzzer",
Jamie Madill238c19e2019-02-07 09:09:41 -050047 ":xxhash_fuzzer",
Jamie Madille3c25712019-12-03 14:08:36 -050048 "$angle_root/samples:angle_samples",
49 "$angle_root/src/tests:angle_tests",
Frank Henigmand0ef13a2017-08-28 22:53:24 -040050 ]
51 }
52}
53
Frank Henigmane8d5c5c2016-07-07 13:17:47 -040054if (ozone_platform_gbm) {
Frank Henigman62ba9622016-06-27 17:08:28 -040055 pkg_config("libdrm") {
56 packages = [ "libdrm" ]
57 }
Frank Henigman77df6762016-06-13 16:39:01 -040058}
59
Tim Van Pattenc4e0a1e2018-11-28 16:08:11 +000060import("src/compiler.gni")
Tim Van Pattenfdccaa32018-11-01 17:47:10 -060061import("src/libGLESv2.gni")
Brett Wilson04bac602014-07-16 14:19:18 -070062
Brett Wilson2f5469c2014-07-22 17:00:17 -070063# This config is exported to dependent targets (and also applied to internal
64# ones).
65config("external_config") {
Jamie Madilledbc2442016-01-04 11:25:00 -050066 include_dirs = [ "include" ]
Brett Wilson2f5469c2014-07-22 17:00:17 -070067}
68
Jamie Madill4638dc92018-12-17 13:13:49 -050069# Prevent the GL headers from redeclaring ANGLE entry points.
70config("no_gl_prototypes") {
71 defines = [
72 "GL_GLES_PROTOTYPES=0",
73 "EGL_EGL_PROTOTYPES=0",
74 ]
75}
76
77config("gl_prototypes") {
78 defines = [
79 "GL_GLES_PROTOTYPES=1",
80 "EGL_EGL_PROTOTYPES=1",
81 "GL_GLEXT_PROTOTYPES",
82 "EGL_EGLEXT_PROTOTYPES",
83 ]
84}
85
Jamie Madill72f5b5e2014-06-23 15:13:02 -040086# This config is applied to internal Angle targets (not pushed to dependents).
87config("internal_config") {
88 include_dirs = [
89 "include",
90 "src",
91 ]
Jamie Madill80ab03c2017-01-03 11:03:23 -050092
Jamie Madill4638dc92018-12-17 13:13:49 -050093 defines = []
Jamie Madill6de51852017-04-12 09:53:01 -040094
Courtney Goeltzenleuchterb0015282018-05-18 16:48:50 -060095 if (angle_64bit_current_cpu) {
Yuly Novikovc4f1dd82017-10-25 17:02:29 -040096 defines += [ "ANGLE_IS_64_BIT_CPU" ]
Courtney Goeltzenleuchterb0015282018-05-18 16:48:50 -060097 } else {
98 defines += [ "ANGLE_IS_32_BIT_CPU" ]
Jamie Madill6de51852017-04-12 09:53:01 -040099 }
Geoff Langb02fc662018-08-21 09:48:01 -0400100
Manh Nguyendce37b72020-06-21 22:27:06 -0400101 if (is_win) {
102 defines += [ "ANGLE_IS_WIN" ]
103 } else if (is_linux) {
104 defines += [ "ANGLE_IS_LINUX" ]
105 }
106
Tobin Ehlis573f76b2018-05-03 11:10:44 -0600107 if (angle_enable_trace) {
108 defines += [ "ANGLE_ENABLE_DEBUG_TRACE=1" ]
109 }
Tobin Ehlis93121f32019-10-17 08:18:16 -0600110
111 if (is_chromeos) {
112 defines += [ "ANGLE_PLATFORM_CHROMEOS" ]
113 }
Ethan Leefcef6dc2020-01-24 22:41:35 -0500114
115 if (is_ggp) {
116 defines += [ "__ggp__" ]
117 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400118}
119
Jamie Madilla9f11bf2019-10-21 08:39:14 -0400120config("constructor_and_destructor_warnings") {
121 if (is_clang) {
122 cflags = [
123 "-Wexit-time-destructors",
124 "-Wglobal-constructors",
125 ]
126 }
127}
128
Jamie Madill509a1d42016-07-18 10:10:29 -0400129config("extra_warnings") {
Ben Wagner211bff32017-10-10 23:53:20 -0400130 cflags = []
Frank Henigmand0ef13a2017-08-28 22:53:24 -0400131
Jamie Madill509a1d42016-07-18 10:10:29 -0400132 # Enable more default warnings on Windows.
133 if (is_win) {
Ben Wagner211bff32017-10-10 23:53:20 -0400134 cflags += [
Jamie Madill509a1d42016-07-18 10:10:29 -0400135 "/we4244", # Conversion: possible loss of data.
136 "/we4456", # Variable shadowing.
Jamie Madill1db8a262016-09-22 13:53:47 -0400137 "/we4458", # declaration hides class member.
Ben Wagner1e064012019-04-12 14:10:17 -0400138 "/we4715", # not all control paths return a value
Geoff Langb9440532017-11-28 13:26:34 -0500139 "/we4800", # forcing value to bool.
140 "/we4838", # narrowing conversion.
Jamie Madill509a1d42016-07-18 10:10:29 -0400141 ]
142 }
Ben Wagner211bff32017-10-10 23:53:20 -0400143 if (is_clang) {
Michael Spang229fc832019-01-21 18:09:15 -0500144 cflags += [
Jamie Madillc7217aa2020-08-28 14:45:14 -0400145 "-Wbad-function-cast",
Jamie Madill155947f2019-10-24 12:55:11 -0400146 "-Wconditional-uninitialized",
Jamie Madill44a0e732019-09-02 13:55:59 -0400147 "-Wextra-semi-stmt",
Jiacheng Lu73e5e9b2019-07-22 15:26:17 -0600148 "-Wfloat-conversion",
Jamie Madill16370a62019-10-24 12:55:11 -0400149 "-Winconsistent-missing-destructor-override",
Jamie Madilla6206852019-10-24 12:55:09 -0400150 "-Wmissing-field-initializers",
Stuart Morgan5dba7232020-06-16 09:29:16 -0700151 "-Wnewline-eof",
Olli Etuaho8073a952018-05-09 16:41:39 +0300152 "-Wnon-virtual-dtor",
Jamie Madill68945f12019-10-24 12:55:09 -0400153 "-Wredundant-parens",
Jamie Madill1ab8b752020-08-28 14:45:15 -0400154 "-Wreturn-std-move-in-c++11",
Jamie Madill859ca032019-10-24 12:55:08 -0400155 "-Wshadow-field",
Jamie Madill5c56f222020-08-28 14:45:14 -0400156 "-Wsuggest-destructor-override",
157 "-Wsuggest-override",
Jamie Madillfd58d222019-10-24 12:55:07 -0400158 "-Wtautological-type-limit-compare",
Jamie Madillc017cee2019-10-24 12:55:10 -0400159 "-Wundefined-reinterpret-cast",
Jamie Madillc09ae152019-02-01 14:16:32 -0500160 "-Wunneeded-internal-declaration",
James Darpinianefa898a2019-08-07 17:05:35 -0700161
162 # The below warnings are used by WebKit. We enable them to make rolling
163 # ANGLE in WebKit easier.
164 "-Wparentheses",
165 "-Wrange-loop-analysis",
166 "-Wstrict-prototypes",
167 "-Wunreachable-code",
James Darpinian7e48c9e2019-08-06 17:17:19 -0700168 "-Wshorten-64-to-32",
Nico Weber79de62c2018-01-31 10:47:14 -0500169 ]
Ben Wagner211bff32017-10-10 23:53:20 -0400170 }
Austin Kinross11dc1632019-09-18 14:46:23 -0700171
172 if (angle_is_winuwp) {
173 cflags += [ "/wd4447" ] # 'main' signature found without threading model.
174 }
Jamie Madill509a1d42016-07-18 10:10:29 -0400175}
176
Courtney Goeltzenleuchter46071482018-05-15 13:35:15 -0600177# This config adds build-ids to the associated library.
178# -Wl is a special option that indicates that clang should pass the associated
179# option --build-id to the linker. This will cause a build-id section to be added
180# to the associated library. The build-id makes it possible for a debugger to
181# find the right symbol file to use.
182config("build_id_config") {
183 ldflags = [ "-Wl,--build-id" ]
184}
185
Jamie Madill20d380f2019-06-03 15:21:47 -0400186# Useful for more informative stack traces.
187config("better_linux_stack_traces") {
188 if (angle_better_stack_traces) {
189 ldflags = [ "-Wl,--export-dynamic" ]
190 }
191}
192
Jamie Madill1ba72542019-10-04 15:17:49 -0400193_use_copy_compiler_dll = angle_has_build && is_win && target_cpu != "arm64"
194
Tom Tan5c317532018-11-30 17:01:01 -0800195# Windows ARM64 is available since 10.0.16299 so no need to copy
196# d3dcompiler_47.dll because this file is available as inbox.
Jamie Madill1ba72542019-10-04 15:17:49 -0400197if (_use_copy_compiler_dll) {
Jamie Madilld09546e2019-02-22 10:24:44 -0500198 # We also ship an older DLL for compatiblity with Windows 7 machines without
199 # the UCRT. This DLL isn't available in the standard SDK distribution.
200 _old_compiler = "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_old.dll"
201 _has_old_compiler =
202 exec_script("scripts/file_exists.py", [ _old_compiler ], "value")
203
Daniel Bratell73941de2015-02-25 14:34:49 +0100204 copy("copy_compiler_dll") {
Julien Isorce5641d192020-02-04 21:31:47 -0800205 sources = [ "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll" ]
Jamie Madilld09546e2019-02-22 10:24:44 -0500206
207 if (_has_old_compiler) {
208 sources += [ _old_compiler ]
209 }
210
Julien Isorce5641d192020-02-04 21:31:47 -0800211 outputs = [ "$root_out_dir/{{source_file_part}}" ]
Daniel Bratell73941de2015-02-25 14:34:49 +0100212 }
Daniel Bratell73941de2015-02-25 14:34:49 +0100213}
214
Jamie Madill55959b02019-03-05 10:07:41 -0500215# Holds the shared includes so we only need to list them once.
Jamie Madillcd4f1fb2019-02-07 15:26:10 -0500216config("includes_config") {
217 include_dirs = [ "include" ]
218}
219
Jamie Madill7098cff2019-01-15 18:33:42 -0500220angle_source_set("includes") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400221 sources = libangle_includes
Jamie Madillcd4f1fb2019-02-07 15:26:10 -0500222 public_configs = [ ":includes_config" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400223}
224
Jamie Madill7098cff2019-01-15 18:33:42 -0500225angle_static_library("preprocessor") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400226 sources = angle_preprocessor_sources
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400227
Corentin Wallez054f7ed2016-09-20 17:15:59 -0400228 public_deps = [
229 ":angle_common",
Jamie Madill1f08ab22019-10-03 16:22:52 -0400230 ":angle_translator_headers",
Corentin Wallez054f7ed2016-09-20 17:15:59 -0400231 ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400232}
233
Tobin Ehlis5546fb42019-01-17 12:25:54 -0500234config("angle_disable_pool_alloc") {
235 defines = [ "ANGLE_DISABLE_POOL_ALLOC" ]
Jamie Madille5c97ab2014-08-07 12:31:38 -0400236}
237
Cooper Partin75da1972015-06-16 15:03:14 -0700238config("debug_annotations_config") {
Corentin Wallez105bc9d2019-03-06 16:32:40 +0000239 if (is_debug) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500240 defines = [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
Cooper Partin75da1972015-06-16 15:03:14 -0700241 }
242}
243
Jamie Madille31fd872016-05-27 08:35:36 -0400244config("angle_release_asserts_config") {
245 if (dcheck_always_on) {
246 defines = [ "ANGLE_ENABLE_RELEASE_ASSERTS" ]
247 }
248}
249
Jamie Madille2e406c2016-06-02 13:04:10 -0400250config("angle_common_config") {
Jamie Madill5ea762a2017-06-07 14:59:51 -0400251 include_dirs = [ "src/common/third_party/base" ]
Yuly Novikove7624002018-01-27 18:27:07 -0500252 if (is_android) {
253 libs = [ "log" ]
254 }
Jamie Madille2e406c2016-06-02 13:04:10 -0400255}
256
Alexis Hetua20f5b12020-08-18 11:26:50 -0400257# Silences the "indirect call of a function with wrong dynamic type" cfi error
258config("angle_no_cfi_icall") {
259 if (is_cfi && use_cfi_icall && current_toolchain == default_toolchain) {
260 cflags = [ "-fno-sanitize=cfi-icall" ]
261 }
262}
263
264# Silences the "cast from void* or another unrelated type to the wrong dynamic type" cfi error
265config("angle_no_cfi_unrelated_cast") {
266 if (is_cfi && use_cfi_cast && current_toolchain == default_toolchain) {
267 cflags = [ "-fno-sanitize=cfi-unrelated-cast" ]
268 }
269}
270
Jamie Madill7098cff2019-01-15 18:33:42 -0500271angle_source_set("angle_system_utils") {
Jamie Madill4638dc92018-12-17 13:13:49 -0500272 sources = angle_system_utils_sources
Jamie Madill8970ad32020-08-26 12:59:19 -0400273 if (is_linux) {
274 libs = [ "dl" ]
275 }
Jamie Madill4638dc92018-12-17 13:13:49 -0500276}
277
Jamie Madillc09ae152019-02-01 14:16:32 -0500278angle_source_set("xxhash") {
279 sources = xxhash_sources
Jamie Madillc09ae152019-02-01 14:16:32 -0500280}
281
Jamie Madill1ba72542019-10-04 15:17:49 -0400282if (angle_has_build) {
283 fuzzer_test("xxhash_fuzzer") {
Julien Isorce5641d192020-02-04 21:31:47 -0800284 sources = [ "src/common/third_party/xxhash/xxhash_fuzzer.cpp" ]
285 deps = [ ":xxhash" ]
Jamie Madill1ba72542019-10-04 15:17:49 -0400286 }
Jamie Madill238c19e2019-02-07 09:09:41 -0500287}
288
Jamie Madill7098cff2019-01-15 18:33:42 -0500289angle_static_library("angle_common") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400290 sources = libangle_common_sources
Cooper Partin75da1972015-06-16 15:03:14 -0700291
Jamie Madill562e81b2015-01-14 14:31:02 -0500292 configs += [
Jamie Madille2e406c2016-06-02 13:04:10 -0400293 ":angle_common_config",
Cooper Partin75da1972015-06-16 15:03:14 -0700294 ":debug_annotations_config",
Jamie Madill562e81b2015-01-14 14:31:02 -0500295 ]
Jeremy Roman06feb812016-04-06 16:39:52 -0400296
Julien Isorce5641d192020-02-04 21:31:47 -0800297 deps = [ ":xxhash" ]
Jamie Madillc09ae152019-02-01 14:16:32 -0500298
Yuly Novikov87ae8cd2016-05-19 17:59:55 -0400299 public_deps = [
Jamie Madill4638dc92018-12-17 13:13:49 -0500300 ":angle_system_utils",
301 ":angle_version",
Jamie Madill8d986bf2018-02-21 08:28:01 -0500302 ":includes",
Yuly Novikov87ae8cd2016-05-19 17:59:55 -0400303 ]
Jamie Madill7098cff2019-01-15 18:33:42 -0500304 public_configs += [ ":angle_common_config" ]
Jamie Madill1ba72542019-10-04 15:17:49 -0400305 if (angle_has_build && use_fuzzing_engine) {
Jamie Madill48aa52f2019-10-17 07:56:53 -0400306 all_dependent_configs = [ ":angle_disable_pool_alloc" ]
Tobin Ehlis5546fb42019-01-17 12:25:54 -0500307 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500308}
309
Geoff Lang6e4cfce2016-06-13 15:06:31 -0400310config("angle_image_util_config") {
311 include_dirs = [
312 "include",
313 "src",
314 ]
315}
316
Jamie Madill1f08ab22019-10-03 16:22:52 -0400317angle_source_set("angle_image_util_headers") {
318 sources = libangle_image_util_headers
Julien Isorce5641d192020-02-04 21:31:47 -0800319 public_deps = [ ":angle_common" ]
Jamie Madill1f08ab22019-10-03 16:22:52 -0400320}
321
Jamie Madill7098cff2019-01-15 18:33:42 -0500322angle_static_library("angle_image_util") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400323 sources = libangle_image_util_sources
Jamie Madill7098cff2019-01-15 18:33:42 -0500324 public_configs += [ ":angle_image_util_config" ]
Julien Isorce5641d192020-02-04 21:31:47 -0800325 public_deps = [ ":angle_image_util_headers" ]
Geoff Lang6e4cfce2016-06-13 15:06:31 -0400326}
327
Courtney Goeltzenleuchter7d81ae72018-10-08 19:25:19 -0600328config("angle_gl_visibility_config") {
329 if (is_win) {
330 defines = [
331 "GL_APICALL=",
332 "GL_API=",
333 ]
334 } else {
335 defines = [
336 "GL_APICALL=__attribute__((visibility(\"default\")))",
337 "GL_API=__attribute__((visibility(\"default\")))",
338 ]
Courtney Goeltzenleuchtere7ece9e2018-10-08 16:43:43 -0600339 }
Ian Elliottabcb2b32018-08-29 17:04:15 -0600340}
341
Corentin Wallez7b4e00d2017-02-08 10:43:47 -0500342config("angle_gpu_info_util_config") {
343 include_dirs = [
344 "include",
345 "src",
346 ]
347}
348
Jamie Madill7098cff2019-01-15 18:33:42 -0500349angle_static_library("angle_gpu_info_util") {
Jonah Ryan-Davis66e48502019-04-25 10:49:05 -0400350 public_configs += [
351 ":angle_gpu_info_util_config",
352 ":angle_backend_config",
353 ]
Julien Isorce5641d192020-02-04 21:31:47 -0800354 public_deps = [ ":angle_common" ]
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400355 sources = libangle_gpu_info_util_sources
Corentin Wallez7b4e00d2017-02-08 10:43:47 -0500356 deps = []
357 libs = []
358 defines = []
359
Michael Spangb630bf92020-01-24 17:27:01 -0500360 if (is_android || is_fuchsia) {
361 sources += libangle_gpu_info_util_vulkan_sources
Geoff Langdd90f5a2020-04-07 12:59:23 -0400362 deps += [ "$angle_root/third_party/vulkan-headers/src:vulkan_headers" ]
Michael Spangb630bf92020-01-24 17:27:01 -0500363 }
364
Ian Elliottd07c52e2018-06-22 15:42:09 -0600365 if (is_android) {
Michael Spangb630bf92020-01-24 17:27:01 -0500366 sources += libangle_gpu_info_util_android_sources
367 }
368
369 if (is_fuchsia) {
370 sources += libangle_gpu_info_util_fuchsia_sources
Antonio Maiorano13816d22020-06-16 14:27:04 -0400371 deps += [ "$angle_root/src/common/vulkan:angle_vulkan_entry_points" ]
Ian Elliottd07c52e2018-06-22 15:42:09 -0600372 }
373
Corentin Wallez8f77e5d2017-03-24 11:58:59 -0700374 if (is_win) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400375 sources += libangle_gpu_info_util_win_sources
Austin Kinross11dc1632019-09-18 14:46:23 -0700376 if (!angle_is_winuwp) {
377 libs += [ "setupapi.lib" ]
378 }
Jonah Ryan-Davis66e48502019-04-25 10:49:05 -0400379 libs += [ "dxgi.lib" ]
Corentin Wallez8f77e5d2017-03-24 11:58:59 -0700380 }
381
Michael Spangb630bf92020-01-24 17:27:01 -0500382 if (is_linux) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400383 sources += libangle_gpu_info_util_linux_sources
Corentin Wallez7b4e00d2017-02-08 10:43:47 -0500384
Jamie Madill8970ad32020-08-26 12:59:19 -0400385 if (angle_use_x11 && angle_has_build) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400386 sources += libangle_gpu_info_util_x11_sources
Corentin Wallez7b4e00d2017-02-08 10:43:47 -0500387 deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
388 defines += [ "GPU_INFO_USE_X11" ]
389 libs += [
390 "X11",
391 "Xi",
392 "Xext",
393 ]
394 }
395 }
396
Corentin Wallez7b4e00d2017-02-08 10:43:47 -0500397 if (use_libpci) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400398 sources += libangle_gpu_info_util_libpci_sources
Corentin Wallez7b4e00d2017-02-08 10:43:47 -0500399 defines += [ "GPU_INFO_USE_LIBPCI" ]
400 libs += [ "pci" ]
401 }
Corentin Wallezd83f64f2017-02-16 10:58:46 -0500402
403 if (is_mac) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400404 sources += libangle_gpu_info_util_mac_sources
Sylvain Defresnebae95f82020-07-02 17:19:14 +0200405 frameworks = [
Corentin Wallezd83f64f2017-02-16 10:58:46 -0500406 "IOKit.framework",
407 "CoreFoundation.framework",
Corentin Wallez163965d2017-10-11 11:38:55 -0400408 "CoreGraphics.framework",
Daksh Idnani5ec04882019-08-22 21:12:08 +0000409 "OpenGL.framework",
Corentin Wallezd83f64f2017-02-16 10:58:46 -0500410 ]
411 }
Corentin Wallez7b4e00d2017-02-08 10:43:47 -0500412}
413
Jamie Madill1f08ab22019-10-03 16:22:52 -0400414angle_source_set("angle_translator_headers") {
415 sources = angle_translator_exported_headers
Julien Isorce5641d192020-02-04 21:31:47 -0800416 public_deps = [ ":includes" ]
Jamie Madill1f08ab22019-10-03 16:22:52 -0400417}
418
Jamie Madill7098cff2019-01-15 18:33:42 -0500419angle_static_library("translator") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400420 sources = angle_translator_sources
Austin Kinross82b5ab62015-12-11 09:30:15 -0800421 defines = []
422
Jonathan Metzmanfb9051a2017-10-09 16:14:06 -0700423 if (angle_enable_essl || use_fuzzing_engine) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400424 sources += angle_translator_essl_sources
Austin Kinross82b5ab62015-12-11 09:30:15 -0800425 defines += [ "ANGLE_ENABLE_ESSL" ]
426 }
427
Jonathan Metzmanfb9051a2017-10-09 16:14:06 -0700428 if (angle_enable_glsl || use_fuzzing_engine) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400429 sources += angle_translator_glsl_sources
Austin Kinross82b5ab62015-12-11 09:30:15 -0800430 defines += [ "ANGLE_ENABLE_GLSL" ]
431 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400432
Jonathan Metzmanfb9051a2017-10-09 16:14:06 -0700433 if (angle_enable_hlsl || use_fuzzing_engine) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400434 sources += angle_translator_hlsl_sources
Austin Kinross82b5ab62015-12-11 09:30:15 -0800435 defines += [ "ANGLE_ENABLE_HLSL" ]
Daniel Bratell73941de2015-02-25 14:34:49 +0100436 }
Jamie Madille794cd82017-01-13 17:29:51 -0500437
Le Quyend200a772019-10-10 00:44:01 +0800438 if (angle_enable_vulkan || use_fuzzing_engine || angle_enable_metal) {
439 # This translator is needed by metal backend also.
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400440 sources += angle_translator_lib_vulkan_sources
Le Quyend200a772019-10-10 00:44:01 +0800441 }
442
443 if (angle_enable_vulkan || use_fuzzing_engine) {
Jamie Madille794cd82017-01-13 17:29:51 -0500444 defines += [ "ANGLE_ENABLE_VULKAN" ]
445 }
446
Le Quyend200a772019-10-10 00:44:01 +0800447 if (angle_enable_metal) {
448 sources += angle_translator_lib_metal_sources
449 defines += [ "ANGLE_ENABLE_METAL" ]
450 }
451
Jonah Ryan-Davis5afd5ec2019-10-25 10:53:40 -0600452 if (angle_enable_swiftshader) {
453 defines += [ "ANGLE_ENABLE_SWIFTSHADER" ]
454 }
455
Jamie Madill7098cff2019-01-15 18:33:42 -0500456 public_configs += [ ":external_config" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400457
458 deps = [
459 ":includes",
460 ":preprocessor",
461 ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500462
463 public_deps = [
464 ":angle_common",
Jamie Madill1f08ab22019-10-03 16:22:52 -0400465 ":angle_translator_headers",
Jamie Madill562e81b2015-01-14 14:31:02 -0500466 ]
Jamie Madilla8503ce2016-07-18 13:47:12 -0400467
468 if (is_win) {
469 # Necessary to suppress some system header xtree warnigns in Release.
470 # For some reason this warning doesn't get triggered in Chromium
471 cflags = [ "/wd4718" ]
472 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400473}
474
Jamie Madill7098cff2019-01-15 18:33:42 -0500475angle_source_set("translator_fuzzer") {
Julien Isorce5641d192020-02-04 21:31:47 -0800476 sources = [ "src/compiler/fuzz/translator_fuzzer.cpp" ]
Corentin Wallez28b65282016-06-16 07:24:50 -0700477
478 include_dirs = [
479 "include",
480 "src",
481 ]
482
Julien Isorce5641d192020-02-04 21:31:47 -0800483 deps = [ ":translator" ]
Corentin Wallez28b65282016-06-16 07:24:50 -0700484}
485
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400486config("commit_id_config") {
487 include_dirs = [ "$root_gen_dir/angle" ]
Jamie Madill720ca442018-12-17 14:04:10 -0500488 visibility = [ ":commit_id" ]
489}
490
Geoff Langba8ef682020-02-24 14:13:40 -0500491commit_id_output_file = "$root_gen_dir/angle/commit.h"
492action("commit_id") {
493 script = "src/commit_id.py"
494 outputs = [ commit_id_output_file ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400495
Geoff Langba8ef682020-02-24 14:13:40 -0500496 # Add git as a dependency if it is available.
Geoff Lang20c69732020-03-06 11:02:31 -0500497 if (angle_enable_commit_id &&
498 exec_script("src/commit_id.py", [ "check" ], "value") == 1) {
Geoff Langdd19d552020-03-02 09:41:22 -0500499 # commit id should depend on angle's HEAD revision
500 inputs = [ ".git/HEAD" ]
Jamie Madill5f2ba632020-08-15 23:50:59 -0400501 branch = read_file(".git/HEAD", "string")
502 result = string_split(branch)
503 if (result[0] == "ref:") {
504 inputs += [ ".git/" + result[1] ]
505 }
Tomasz Moniuszko319fb8982015-07-30 14:34:54 +0200506 }
Geoff Langba8ef682020-02-24 14:13:40 -0500507
508 args = [
509 "gen",
510 rebase_path(commit_id_output_file, root_build_dir),
511 ]
512
513 public_configs = [ ":commit_id_config" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400514}
515
Jamie Madill7098cff2019-01-15 18:33:42 -0500516angle_source_set("angle_version") {
Julien Isorce5641d192020-02-04 21:31:47 -0800517 sources = [ "src/common/version.h" ]
518 public_deps = [ ":commit_id" ]
Jamie Madill4638dc92018-12-17 13:13:49 -0500519}
520
Jonah Ryan-Davis66e48502019-04-25 10:49:05 -0400521config("angle_backend_config") {
Jamie Madill562e81b2015-01-14 14:31:02 -0500522 defines = []
Jonah Ryan-Davis66e48502019-04-25 10:49:05 -0400523
Jamie Madill562e81b2015-01-14 14:31:02 -0500524 if (angle_enable_d3d9) {
525 defines += [ "ANGLE_ENABLE_D3D9" ]
Geoff Lang2b5420c2014-11-19 14:20:15 -0500526 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500527 if (angle_enable_d3d11) {
528 defines += [ "ANGLE_ENABLE_D3D11" ]
529 }
Geoff Langc588ac72015-02-13 15:41:41 -0500530 if (angle_enable_gl) {
531 defines += [ "ANGLE_ENABLE_OPENGL" ]
Jamie Madill6d94f062017-10-21 22:19:40 -0400532 if (angle_enable_gl_null) {
533 defines += [ "ANGLE_ENABLE_OPENGL_NULL" ]
534 }
Corentin Wallez51e2ad12015-05-26 11:32:58 -0400535 }
Geoff Langd08f3b32016-09-23 15:56:30 -0400536 if (angle_enable_null) {
537 defines += [ "ANGLE_ENABLE_NULL" ]
538 }
Etienne Bergeron9e83c152020-06-04 19:53:36 -0400539 if (angle_delegate_workers) {
540 defines += [ "ANGLE_DELEGATE_WORKERS" ]
541 }
Jamie Madill1f08ab22019-10-03 16:22:52 -0400542
Jonah Ryan-Davis5afd5ec2019-10-25 10:53:40 -0600543 configs = []
544
Le Quyend200a772019-10-10 00:44:01 +0800545 if (angle_enable_metal) {
Jonah Ryan-Davis5afd5ec2019-10-25 10:53:40 -0600546 configs += [ "src/libANGLE/renderer/metal:angle_metal_backend_config" ]
Le Quyend200a772019-10-10 00:44:01 +0800547 }
548
Jamie Madill1f08ab22019-10-03 16:22:52 -0400549 if (angle_enable_vulkan) {
Jonah Ryan-Davis5afd5ec2019-10-25 10:53:40 -0600550 configs += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ]
Jamie Madill1f08ab22019-10-03 16:22:52 -0400551 }
Jonah Ryan-Davis66e48502019-04-25 10:49:05 -0400552}
553
554config("libANGLE_config") {
555 cflags = []
556 defines = []
557 libs = []
558 ldflags = []
559 if (angle_enable_d3d9) {
560 ldflags += [ "/DELAYLOAD:d3d9.dll" ]
561 }
Jamie Madill80ab03c2017-01-03 11:03:23 -0500562 defines += [ "LIBANGLE_IMPLEMENTATION" ]
Corentin Wallezbeb81582015-09-02 10:30:55 -0400563
564 if (is_win) {
Julien Isorce5641d192020-02-04 21:31:47 -0800565 cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics
566 # are not enabled.
Austin Kinross40853472015-02-12 10:39:56 -0800567 }
Yuly Novikovb29fccf2018-11-28 10:09:39 -0500568
569 if (is_android && (angle_enable_gl || angle_enable_vulkan)) {
Yuly Novikov8edc68e2019-02-12 12:41:01 -0500570 # In API level 26 ANativeWindow APIs were moved from libandroid.so
571 # into a separate library, libnativewindow.so
572 if (ndk_api_level_at_least_26) {
Yuly Novikovb29fccf2018-11-28 10:09:39 -0500573 libs += [ "nativewindow" ]
574 } else {
575 libs += [ "android" ]
576 }
577 }
Michael Spang7cd5f642019-08-21 20:03:49 -0400578
Ethan Leed22b8be2019-11-15 12:26:39 -0500579 if (angle_use_x11) {
Michael Spang7cd5f642019-08-21 20:03:49 -0400580 defines += [ "ANGLE_USE_X11" ]
581 }
Jamie Madillaf5e3822020-01-28 10:05:36 -0500582
583 if (angle_enable_overlay) {
584 defines += [ "ANGLE_ENABLE_OVERLAY=1" ]
585 }
Jamie Madill562e81b2015-01-14 14:31:02 -0500586}
Geoff Lang2b5420c2014-11-19 14:20:15 -0500587
Jamie Madill1f08ab22019-10-03 16:22:52 -0400588angle_source_set("libANGLE_headers") {
589 sources = libangle_headers
590 public_deps = [
591 ":angle_common",
592 ":angle_translator_headers",
593 ]
Jamie Madillaf5e3822020-01-28 10:05:36 -0500594 public_configs += [ ":libANGLE_config" ]
Jamie Madillb62a1c22018-02-06 09:54:02 -0500595}
596
Jamie Madill2f718022019-10-28 11:48:46 -0400597# Don't even try to build glslang if Metal and Vulkan are disabled.
598if (angle_enable_vulkan || angle_enable_metal) {
599 angle_source_set("angle_glslang_wrapper") {
600 sources = [
601 "src/libANGLE/renderer/glslang_wrapper_utils.cpp",
602 "src/libANGLE/renderer/glslang_wrapper_utils.h",
603 ]
604 deps = [
605 ":libANGLE_headers",
606 "${angle_glslang_dir}:glslang_default_resource_limits_sources",
Shahbaz Youssefib291ad02020-07-03 23:53:10 -0400607 "${angle_glslang_dir}:glslang_lib_sources",
Shahbaz Youssefi71e6afb2020-01-14 14:12:31 -0500608 "${angle_spirv_headers_dir}:spv_headers",
609 "${angle_spirv_tools_dir}:spvtools_headers",
Jamie Madill2f718022019-10-28 11:48:46 -0400610 ]
611 }
Le Quyena48f95a2019-10-14 14:49:49 +0800612}
613
Jamie Madilleb1b1642019-07-30 17:22:17 -0400614angle_source_set("libANGLE_base") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400615 sources = libangle_sources
Geoff Lang2b5420c2014-11-19 14:20:15 -0500616
Jamie Madill5ea762a2017-06-07 14:59:51 -0400617 include_dirs = []
Jamie Madill562e81b2015-01-14 14:31:02 -0500618 libs = []
Corentin Wallez64598b52016-11-11 08:25:44 -0500619 defines = []
Frank Henigmane42ec182017-12-11 23:58:53 -0500620 if (angle_link_glx) {
621 libs += [ "GL" ]
622 defines += [ "ANGLE_LINK_GLX" ]
623 }
Jamie Madille2e406c2016-06-02 13:04:10 -0400624 public_deps = [
Corentin Wallezcc068e92016-02-29 16:37:04 -0500625 ":angle_common",
Jamie Madill720ca442018-12-17 14:04:10 -0500626 ":angle_gpu_info_util",
Jamie Madill4638dc92018-12-17 13:13:49 -0500627 ":angle_version",
Jamie Madill1f08ab22019-10-03 16:22:52 -0400628 ":libANGLE_headers",
Jamie Madill720ca442018-12-17 14:04:10 -0500629 ":translator",
Jamie Madille2e406c2016-06-02 13:04:10 -0400630 ]
631 deps = [
Tim Van Pattenb55f0f72020-06-02 18:01:24 -0600632 ":angle_compression",
Corentin Wallez878baf92017-02-15 13:57:16 -0500633 ":angle_image_util",
Corentin Wallezcc068e92016-02-29 16:37:04 -0500634 ":includes",
Corentin Wallezcc068e92016-02-29 16:37:04 -0500635 ]
636
Jamie Madille55374f2019-10-24 12:55:12 -0400637 if (is_win) {
Ethan Leed83dc172019-11-20 01:50:36 -0500638 if (angle_enable_d3d9) {
639 libs += [ "delayimp.lib" ]
640 }
Jamie Madille55374f2019-10-24 12:55:12 -0400641 libs += [
Jamie Madille55374f2019-10-24 12:55:12 -0400642 "gdi32.lib",
643 "user32.lib",
644 ]
645 }
646
Jamie Madill1f08ab22019-10-03 16:22:52 -0400647 if (angle_enable_vulkan) {
648 public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ]
649 }
650
Le Quyend200a772019-10-10 00:44:01 +0800651 if (angle_enable_metal) {
652 public_deps += [ "src/libANGLE/renderer/metal:angle_metal_backend" ]
653 }
654
Jamie Madillab2bfa82019-01-15 19:06:47 -0500655 # Enable extra Chromium style warnings for libANGLE.
Jamie Madill299b1ba2019-10-24 09:29:18 -0400656 if (is_clang && angle_has_build) {
Jamie Madillab2bfa82019-01-15 19:06:47 -0500657 suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ]
658 }
659
Jamie Madill562e81b2015-01-14 14:31:02 -0500660 # Shared D3D sources.
661 if (angle_enable_d3d9 || angle_enable_d3d11) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400662 sources += libangle_d3d_shared_sources
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400663
Jamie Madilledbc2442016-01-04 11:25:00 -0500664 defines += [ "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " + "\"d3dcompiler_47.dll\", \"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }" ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500665 }
Geoff Lang2b5420c2014-11-19 14:20:15 -0500666
Jamie Madill562e81b2015-01-14 14:31:02 -0500667 if (angle_enable_d3d9) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400668 sources += libangle_d3d9_sources
Jamie Madill562e81b2015-01-14 14:31:02 -0500669 libs += [ "d3d9.lib" ]
670 }
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400671
Jamie Madill562e81b2015-01-14 14:31:02 -0500672 if (angle_enable_d3d11) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400673 sources += libangle_d3d11_sources
Austin Kinross11dc1632019-09-18 14:46:23 -0700674
675 if (angle_is_winuwp) {
676 sources += libangle_d3d11_winuwp_sources
677 } else {
678 sources += libangle_d3d11_win32_sources
679 }
680
Austin Kinross91e71ed2016-08-23 09:29:22 -0700681 libs += [ "dxguid.lib" ]
Brandon Jonesb77884b2018-10-10 09:07:12 -0700682 import("src/libANGLE/renderer/d3d/d3d11/d3d11_blit_shaders_autogen.gni")
683 sources += libangle_d3d11_blit_shaders
Jamie Madill562e81b2015-01-14 14:31:02 -0500684 }
685
Wander Lairson Costaee9c4fe2020-07-14 15:29:40 -0300686 if (!angle_is_winuwp && (angle_enable_d3d11 || angle_enable_d3d9)) {
687 sources += libangle_d3d_win32_sources
688 }
689
690 if (is_win && (angle_enable_gl || angle_enable_d3d11)) {
691 sources += libangle_gl_wgl_d3d11_common_sources
692 }
693
Geoff Langc588ac72015-02-13 15:41:41 -0500694 if (angle_enable_gl) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400695 sources += libangle_gl_sources
Geoff Langc588ac72015-02-13 15:41:41 -0500696 include_dirs += [ "src/third_party/khronos" ]
697
Jamie Madill6d94f062017-10-21 22:19:40 -0400698 if (angle_enable_gl_null) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400699 sources += libangle_gl_null_sources
Jamie Madill6d94f062017-10-21 22:19:40 -0400700 }
Geoff Langc588ac72015-02-13 15:41:41 -0500701 if (is_win) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400702 sources += libangle_gl_wgl_sources
Geoff Langc588ac72015-02-13 15:41:41 -0500703 }
Ethan Leed22b8be2019-11-15 12:26:39 -0500704 if (angle_use_x11) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400705 sources += libangle_gl_glx_sources
Corentin Wallezcc068e92016-02-29 16:37:04 -0500706 libs += [
707 "X11",
708 "Xi",
709 "Xext",
710 ]
Corentin Wallez47fc1fe2015-05-14 10:54:18 -0400711 }
Nico Weberde44d3a2016-05-13 17:27:57 -0400712 if (is_mac) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400713 sources += libangle_gl_cgl_sources
Sylvain Defresnebae95f82020-07-02 17:19:14 +0200714 frameworks = [
Nico Weberde44d3a2016-05-13 17:27:57 -0400715 "Cocoa.framework",
716 "IOSurface.framework",
717 "OpenGL.framework",
718 "QuartzCore.framework",
719 ]
720 }
Yuly Novikova6426d62016-06-03 00:18:38 -0400721 if (is_android) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400722 sources += libangle_gl_egl_sources
723 sources += libangle_gl_egl_dl_sources
724 sources += libangle_gl_egl_android_sources
Yuly Novikova6426d62016-06-03 00:18:38 -0400725 }
Julien Isorce5641d192020-02-04 21:31:47 -0800726 if (is_linux) {
727 sources += libangle_gl_egl_sources
728 sources += libangle_gl_egl_dl_sources
729 }
Frank Henigmane8d5c5c2016-07-07 13:17:47 -0400730 if (ozone_platform_gbm) {
Frank Henigman77df6762016-06-13 16:39:01 -0400731 configs += [ ":libdrm" ]
Maksim Sisov56a4cc12020-05-21 13:17:21 +0300732 defines += [ "ANGLE_USE_GBM" ]
Frank Henigman77df6762016-06-13 16:39:01 -0400733 deps += [ "//third_party/minigbm" ]
Maksim Sisov56a4cc12020-05-21 13:17:21 +0300734 sources += libangle_gl_gbm_sources
Frank Henigman77df6762016-06-13 16:39:01 -0400735 }
Geoff Langc588ac72015-02-13 15:41:41 -0500736 }
737
Geoff Langd08f3b32016-09-23 15:56:30 -0400738 if (angle_enable_null) {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400739 sources += libangle_null_sources
Geoff Langd08f3b32016-09-23 15:56:30 -0400740 }
741
Geoff Langecd2e3b2019-07-09 15:39:39 -0400742 if (is_mac) {
743 sources += libangle_mac_sources
744 }
745
Jamie Madill562e81b2015-01-14 14:31:02 -0500746 if (is_debug) {
Jamie Madilledbc2442016-01-04 11:25:00 -0500747 defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400748 }
749
Jamie Madill7098cff2019-01-15 18:33:42 -0500750 configs += [ ":debug_annotations_config" ]
Jonah Ryan-Davis66e48502019-04-25 10:49:05 -0400751 public_configs += [
752 ":libANGLE_config",
753 ":angle_backend_config",
754 ]
Jamie Madill80ab03c2017-01-03 11:03:23 -0500755
Tom Tan5c317532018-11-30 17:01:01 -0800756 # Windows ARM64 is available since 10.0.16299 so no need to copy
757 # d3dcompiler_47.dll because this file is available as inbox.
Jamie Madill1ba72542019-10-04 15:17:49 -0400758 if (_use_copy_compiler_dll) {
Julien Isorce5641d192020-02-04 21:31:47 -0800759 data_deps = [ ":copy_compiler_dll" ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500760 }
761}
762
Jamie Madilleb1b1642019-07-30 17:22:17 -0400763config("angle_frame_capture_disabled") {
764 defines = [ "ANGLE_CAPTURE_ENABLED=0" ]
765}
766
767config("angle_frame_capture_enabled") {
768 defines = [ "ANGLE_CAPTURE_ENABLED=1" ]
769}
770
771angle_source_set("libANGLE") {
Julien Isorce5641d192020-02-04 21:31:47 -0800772 public_deps = [ ":libANGLE_base" ]
Jamie Madilleb1b1642019-07-30 17:22:17 -0400773 public_configs = [ ":angle_frame_capture_disabled" ]
Julien Isorce5641d192020-02-04 21:31:47 -0800774 sources = [ "src/libANGLE/FrameCapture_mock.cpp" ]
Jiacheng Lu9e14a192019-08-09 10:03:24 -0600775
776 # gl_enum_utils defaults included in with_capture build
Brandon Schade5cfab192019-10-28 09:12:53 -0700777 deps = []
Jiacheng Lu9e14a192019-08-09 10:03:24 -0600778 if (angle_enable_trace || is_debug) {
Brandon Schade5cfab192019-10-28 09:12:53 -0700779 deps += [ ":angle_gl_enum_utils" ]
Jiacheng Lu9e14a192019-08-09 10:03:24 -0600780 }
Jamie Madilleb1b1642019-07-30 17:22:17 -0400781}
782
Brandon Schade5cfab192019-10-28 09:12:53 -0700783angle_source_set("angle_gl_enum_utils") {
Julien Isorce5641d192020-02-04 21:31:47 -0800784 public_deps = [ ":libANGLE_base" ]
Brandon Schade5cfab192019-10-28 09:12:53 -0700785 sources = [
786 "src/libANGLE/gl_enum_utils.cpp",
787 "src/libANGLE/gl_enum_utils_autogen.cpp",
788 ]
789}
790
Jamie Madill7e453a22020-03-15 22:11:03 -0400791config("angle_compression_config") {
792 include_dirs = [ "//third_party/zlib/google" ]
793}
794
795group("angle_compression") {
796 public_configs = [
797 ":angle_compression_config",
798 "//third_party/zlib:zlib_config",
799 ]
Jamie Madill35d3c412020-08-26 12:59:18 -0400800 public_deps =
801 [ "$angle_zlib_compression_utils_dir:compression_utils_portable" ]
Jamie Madill7e453a22020-03-15 22:11:03 -0400802}
803
Jamie Madill612b7412019-07-05 11:13:30 -0400804angle_source_set("libANGLE_with_capture") {
Julien Isorce5641d192020-02-04 21:31:47 -0800805 public_deps = [ ":libANGLE_base" ]
Jamie Madill7e453a22020-03-15 22:11:03 -0400806 deps = [ ":angle_compression" ]
Jamie Madilleb1b1642019-07-30 17:22:17 -0400807 public_configs = [ ":angle_frame_capture_enabled" ]
Jamie Madill612b7412019-07-05 11:13:30 -0400808 sources = libangle_capture_sources
809}
810
Robert Sesekdb8ae832016-06-21 11:47:03 -0400811config("shared_library_public_config") {
812 if (is_mac && !is_component_build) {
813 # Executable targets that depend on the shared libraries below need to have
814 # the rpath setup in non-component build configurations.
Jamie Madilla8503ce2016-07-18 13:47:12 -0400815 ldflags = [
816 "-rpath",
817 "@executable_path/",
818 ]
Jonah Ryan-Davis90a8af32020-03-05 13:48:47 -0500819 if (build_with_chromium) {
820 ldflags += [
821 # Path for loading shared libraries for unbundled binaries.
822 # From //build/config/mac/BUILD.gn, this is only added for
823 # component builds. However, since ANGLE always dynamically
824 # links to libvulkan, it should be re-added for non-component
825 # builds. (anglebug.com/4455)
826 "-Wl,-rpath,@loader_path/.",
827 ]
828 }
Robert Sesekdb8ae832016-06-21 11:47:03 -0400829 }
Josh Matthews732c9d02019-11-29 13:59:03 -0500830
831 if (angle_is_winuwp) {
832 ldflags = [
833 "/APPCONTAINER",
834
835 # Disable warning about invalid subsystem number.
836 # A default appropriate subsystem is selected automatically.
837 "/IGNORE:4010",
838 ]
839 }
Robert Sesekdb8ae832016-06-21 11:47:03 -0400840}
841
Jamie Madill4638dc92018-12-17 13:13:49 -0500842config("library_name_config") {
Yuly Novikov8b8dc562020-02-26 19:09:31 -0500843 if (is_component_build && is_android) {
844 defines = [
845 "ANGLE_EGL_LIBRARY_NAME=\"libEGL${angle_libs_suffix}.cr\"",
846 "ANGLE_GLESV2_LIBRARY_NAME=\"libGLESv2${angle_libs_suffix}.cr\"",
847 ]
848 } else {
849 defines = [
850 "ANGLE_EGL_LIBRARY_NAME=\"libEGL${angle_libs_suffix}\"",
851 "ANGLE_GLESV2_LIBRARY_NAME=\"libGLESv2${angle_libs_suffix}\"",
852 ]
853 }
Jamie Madill4638dc92018-12-17 13:13:49 -0500854}
855
Jamie Madill80ab03c2017-01-03 11:03:23 -0500856# This config controls export definitions on ANGLE API calls.
857config("angle_static") {
858 defines = [
859 "ANGLE_EXPORT=",
Jamie Madillba319ba2018-12-29 10:29:33 -0500860 "ANGLE_UTIL_EXPORT=",
Jamie Madill80ab03c2017-01-03 11:03:23 -0500861 "EGLAPI=",
862 "GL_APICALL=",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500863 "GL_API=",
Jamie Madill80ab03c2017-01-03 11:03:23 -0500864 ]
865}
866
Jamie Madilleb1b1642019-07-30 17:22:17 -0400867set_defaults("angle_libGLESv2") {
868 sources = []
869 output_name = "libGLESv2"
870}
871
Jamie Madill612b7412019-07-05 11:13:30 -0400872template("angle_libGLESv2") {
873 angle_shared_library(target_name) {
Jamie Madilleb1b1642019-07-30 17:22:17 -0400874 sources = libglesv2_sources + invoker.sources
Jamie Madill562e81b2015-01-14 14:31:02 -0500875
Jamie Madill612b7412019-07-05 11:13:30 -0400876 if (is_win) {
Jamie Madilleb1b1642019-07-30 17:22:17 -0400877 sources += [ "src/libGLESv2/${invoker.output_name}_autogen.def" ]
Jamie Madill612b7412019-07-05 11:13:30 -0400878 }
879
Jamie Madilleb1b1642019-07-30 17:22:17 -0400880 output_name = "${invoker.output_name}${angle_libs_suffix}"
881
Jamie Madill612b7412019-07-05 11:13:30 -0400882 configs += [
883 ":angle_gl_visibility_config",
884 ":debug_annotations_config",
885 ":gl_prototypes",
886 ]
887
Jamie Madilleb1b1642019-07-30 17:22:17 -0400888 defines = [ "LIBGLESV2_IMPLEMENTATION" ]
Jamie Madill612b7412019-07-05 11:13:30 -0400889
Jamie Madilleb1b1642019-07-30 17:22:17 -0400890 deps = invoker.deps + [ ":includes" ]
Jamie Madill612b7412019-07-05 11:13:30 -0400891
Julien Isorce5641d192020-02-04 21:31:47 -0800892 public_deps = [ ":angle_version" ]
Geoff Lang2b5420c2014-11-19 14:20:15 -0500893 }
Jamie Madill612b7412019-07-05 11:13:30 -0400894}
John Abd-El-Malek657cd682014-11-05 14:04:19 -0800895
Jamie Madill612b7412019-07-05 11:13:30 -0400896angle_libGLESv2("libGLESv2") {
Jamie Madilleb1b1642019-07-30 17:22:17 -0400897 if (angle_with_capture_by_default) {
Julien Isorce5641d192020-02-04 21:31:47 -0800898 deps = [ ":libANGLE_with_capture" ]
Jiacheng Lu617f23d2019-08-12 10:11:53 -0600899 } else {
Julien Isorce5641d192020-02-04 21:31:47 -0800900 deps = [ ":libANGLE" ]
Jamie Madilleb1b1642019-07-30 17:22:17 -0400901 }
Jamie Madill612b7412019-07-05 11:13:30 -0400902}
Jamie Madill72f5b5e2014-06-23 15:13:02 -0400903
Jiacheng Lu617f23d2019-08-12 10:11:53 -0600904# Output capture lib when `angle_with_capture_by_default` disabled, vice versa.
905angle_libGLESv2("libGLESv2_capture_complement") {
906 if (angle_with_capture_by_default) {
Julien Isorce5641d192020-02-04 21:31:47 -0800907 deps = [ ":libANGLE" ]
Jiacheng Lu617f23d2019-08-12 10:11:53 -0600908 output_name += "_no_capture"
909 } else {
Julien Isorce5641d192020-02-04 21:31:47 -0800910 deps = [ ":libANGLE_with_capture" ]
Jiacheng Lu617f23d2019-08-12 10:11:53 -0600911 output_name += "_with_capture"
Jamie Madilleb1b1642019-07-30 17:22:17 -0400912 }
Jamie Madill80ab03c2017-01-03 11:03:23 -0500913}
914
Austin Kinross11dc1632019-09-18 14:46:23 -0700915if (is_win && !angle_is_winuwp) {
Clemen Dengcb8b4a52019-07-04 16:05:25 -0400916 angle_shared_library("libGL") {
917 sources = libgl_sources
Clemen Deng663b0482019-07-11 12:37:35 -0400918
Clemen Deng6e7dd1e2019-07-16 13:41:59 -0400919 output_name = "openGL32"
920 output_dir = "$root_out_dir/angle_libs"
Clemen Deng7558e832019-06-18 13:02:03 -0400921
922 configs += [
923 ":angle_gl_visibility_config",
924 ":debug_annotations_config",
925 ":gl_prototypes",
926 ]
927
Jamie Madill612b7412019-07-05 11:13:30 -0400928 defines = [
929 "ANGLE_CAPTURE_ENABLED=0",
Clemen Dengcb8b4a52019-07-04 16:05:25 -0400930 "LIBGL_IMPLEMENTATION",
Jamie Madill612b7412019-07-05 11:13:30 -0400931 ]
Clemen Deng7558e832019-06-18 13:02:03 -0400932
933 deps = [
934 ":includes",
935 ":libANGLE",
936 ]
937
Julien Isorce5641d192020-02-04 21:31:47 -0800938 public_deps = [ ":angle_version" ]
Clemen Deng7558e832019-06-18 13:02:03 -0400939 }
940}
941
Jamie Madill7098cff2019-01-15 18:33:42 -0500942angle_static_library("libGLESv2_static") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400943 sources = libglesv2_sources
Jamie Madill7098cff2019-01-15 18:33:42 -0500944 configs += [ ":debug_annotations_config" ]
945 public_configs += [ ":angle_static" ]
Julien Isorce5641d192020-02-04 21:31:47 -0800946 deps = [ ":includes" ]
947 public_deps = [ ":libANGLE" ]
Jamie Madill562e81b2015-01-14 14:31:02 -0500948}
949
Manh Nguyendce37b72020-06-21 22:27:06 -0400950angle_static_library("libGLESv2_with_capture_static") {
951 sources = libglesv2_sources
952 configs += [ ":debug_annotations_config" ]
953 public_configs += [ ":angle_static" ]
954 deps = [ ":includes" ]
955 public_deps = [ ":libANGLE_with_capture" ]
956}
957
Jamie Madill77c84962019-06-28 11:24:27 -0400958angle_shared_library("libGLESv1_CM") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400959 sources = libglesv1_cm_sources
Jamie Madill77c84962019-06-28 11:24:27 -0400960 output_name = "libGLESv1_CM${angle_libs_suffix}"
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500961
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500962 configs += [
Courtney Goeltzenleuchter7d81ae72018-10-08 19:25:19 -0600963 ":angle_gl_visibility_config",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500964 ":debug_annotations_config",
Jamie Madillba319ba2018-12-29 10:29:33 -0500965 ":gl_prototypes",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500966 ]
967
968 defines = []
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500969
970 deps = [
971 ":includes",
Jamie Madill77c84962019-06-28 11:24:27 -0400972 ":libGLESv2",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500973 ]
Jamie Madill8970ad32020-08-26 12:59:19 -0400974
975 if (is_win) {
976 sources += [ "src/libGLESv1_CM/libGLESv1_CM.def" ]
977 }
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500978}
979
Jamie Madill7098cff2019-01-15 18:33:42 -0500980angle_static_library("libGLESv1_CM_static") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -0400981 sources = libglesv1_cm_sources
Jamie Madill7098cff2019-01-15 18:33:42 -0500982 configs += [ ":debug_annotations_config" ]
983 public_configs += [ ":angle_static" ]
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500984 deps = [
985 ":includes",
986 ":libGLESv2_static",
987 ]
988}
989
Jamie Madill4638dc92018-12-17 13:13:49 -0500990config("libEGL_egl_loader_config") {
991 defines = [ "ANGLE_USE_EGL_LOADER" ]
992}
993
Jamie Madill7098cff2019-01-15 18:33:42 -0500994angle_source_set("libEGL_egl_loader") {
Jamie Madill4638dc92018-12-17 13:13:49 -0500995 sources = [
996 "src/libEGL/egl_loader_autogen.cpp",
997 "src/libEGL/egl_loader_autogen.h",
998 ]
999
Jamie Madill7098cff2019-01-15 18:33:42 -05001000 public_configs += [
Jamie Madill4638dc92018-12-17 13:13:49 -05001001 ":libEGL_egl_loader_config",
1002 ":gl_prototypes",
Jamie Madill4638dc92018-12-17 13:13:49 -05001003 ]
1004
Julien Isorce5641d192020-02-04 21:31:47 -08001005 deps = [ ":includes" ]
Jamie Madill4638dc92018-12-17 13:13:49 -05001006}
1007
Jamie Madill77c84962019-06-28 11:24:27 -04001008angle_shared_library("libEGL") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -04001009 sources = libegl_sources
Jamie Madill77c84962019-06-28 11:24:27 -04001010 output_name = "libEGL${angle_libs_suffix}"
Jamie Madill562e81b2015-01-14 14:31:02 -05001011
Jamie Madill562e81b2015-01-14 14:31:02 -05001012 configs += [
Corentin Wallezbeb81582015-09-02 10:30:55 -04001013 ":debug_annotations_config",
Jamie Madill4638dc92018-12-17 13:13:49 -05001014 ":library_name_config",
Jamie Madill562e81b2015-01-14 14:31:02 -05001015 ]
1016
Jamie Madilledbc2442016-01-04 11:25:00 -05001017 defines = [ "LIBEGL_IMPLEMENTATION" ]
Yuly Novikova4ab5802016-12-19 17:44:22 -05001018 if (is_win) {
1019 defines += [ "EGLAPI=" ]
1020 } else {
1021 defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
1022 }
Jamie Madill562e81b2015-01-14 14:31:02 -05001023
Jamie Madill80ab03c2017-01-03 11:03:23 -05001024 if (is_win) {
Nico Weber9db8df42019-01-04 14:47:27 -05001025 sources += [ "src/libEGL/libEGL.def" ]
Jamie Madill80ab03c2017-01-03 11:03:23 -05001026 }
1027
Jamie Madill562e81b2015-01-14 14:31:02 -05001028 deps = [
James Darpinian22ec7dc2019-08-06 10:10:52 -07001029 ":angle_common",
Jamie Madill4638dc92018-12-17 13:13:49 -05001030 ":angle_system_utils",
1031 ":angle_version",
1032 ":libEGL_egl_loader",
Jamie Madill562e81b2015-01-14 14:31:02 -05001033 ]
Jamie Madill720ca442018-12-17 14:04:10 -05001034
Julien Isorce5641d192020-02-04 21:31:47 -08001035 public_deps = [ ":includes" ]
Jamie Madill4638dc92018-12-17 13:13:49 -05001036
Julien Isorce5641d192020-02-04 21:31:47 -08001037 data_deps = [ ":libGLESv2" ]
Jamie Madill562e81b2015-01-14 14:31:02 -05001038}
Corentin Wallezbeb81582015-09-02 10:30:55 -04001039
Jamie Madill7098cff2019-01-15 18:33:42 -05001040angle_static_library("libEGL_static") {
Frank Henigman44b2c0b2018-08-29 17:31:27 -04001041 sources = libegl_sources
Manh Nguyendce37b72020-06-21 22:27:06 -04001042 configs += [
1043 ":debug_annotations_config",
1044 ":library_name_config",
1045 ]
1046 public_configs += [ ":angle_static" ]
1047 deps = [
1048 ":includes",
1049 ":libGLESv2_static",
1050 ]
1051}
1052
1053angle_static_library("libEGL_with_capture_static") {
1054 sources = libegl_sources
Jamie Madill80ab03c2017-01-03 11:03:23 -05001055
Jamie Madill80ab03c2017-01-03 11:03:23 -05001056 configs += [
Jamie Madill80ab03c2017-01-03 11:03:23 -05001057 ":debug_annotations_config",
Jamie Madill4638dc92018-12-17 13:13:49 -05001058 ":library_name_config",
Jamie Madill80ab03c2017-01-03 11:03:23 -05001059 ]
1060
Jamie Madill7098cff2019-01-15 18:33:42 -05001061 public_configs += [ ":angle_static" ]
Jamie Madill80ab03c2017-01-03 11:03:23 -05001062
1063 deps = [
1064 ":includes",
Manh Nguyendce37b72020-06-21 22:27:06 -04001065 ":libGLESv2_with_capture_static",
Jamie Madill80ab03c2017-01-03 11:03:23 -05001066 ]
1067}
1068
Ken Russellfcadd082017-06-28 14:01:15 -07001069# Convenience targets for some of the samples so they can be built
1070# with Chromium's toolchain.
Jamie Madill7098cff2019-01-15 18:33:42 -05001071angle_executable("angle_shader_translator") {
Ken Russellfcadd082017-06-28 14:01:15 -07001072 testonly = true
1073
Julien Isorce5641d192020-02-04 21:31:47 -08001074 sources = [ "samples/shader_translator/shader_translator.cpp" ]
Ken Russellfcadd082017-06-28 14:01:15 -07001075
Julien Isorce5641d192020-02-04 21:31:47 -08001076 deps = [ ":translator" ]
Ken Russellfcadd082017-06-28 14:01:15 -07001077}
Courtney Goeltzenleuchter2565d482018-04-12 17:06:48 -06001078
Jamie Madill1ba72542019-10-04 15:17:49 -04001079if (angle_has_build) {
1080 config("angle_feature_support_config") {
1081 include_dirs = [
1082 "include",
1083 "src",
1084 ]
1085 defines = [ "LIBFEATURE_SUPPORT_IMPLEMENTATION" ]
1086 if (is_debug) {
1087 defines += [ "ANGLE_FEATURE_UTIL_LOG_VERBOSE" ]
1088 }
Ian Elliotta9d579e2018-11-28 11:44:48 -07001089 }
Courtney Goeltzenleuchter7d81ae72018-10-08 19:25:19 -06001090
Jamie Madill1ba72542019-10-04 15:17:49 -04001091 angle_shared_library("libfeature_support") {
1092 output_name = "libfeature_support${angle_libs_suffix}"
Ian Elliotta9d579e2018-11-28 11:44:48 -07001093
Jamie Madill1ba72542019-10-04 15:17:49 -04001094 if (is_android) {
1095 libs = [ "log" ]
1096 }
1097
1098 public_configs += [
1099 ":angle_feature_support_config",
1100 "${angle_jsoncpp_dir}:jsoncpp_config",
1101 ]
1102
1103 if (is_mac && !is_component_build) {
1104 ldflags = [
1105 "-install_name",
1106 "@rpath/${target_name}.dylib",
1107 ]
1108 }
1109
1110 sources = [
1111 "src/feature_support_util/feature_support_util.cpp",
1112 "src/feature_support_util/feature_support_util.h",
1113 ]
1114
1115 deps = [
1116 ":angle_gpu_info_util",
1117 "${angle_jsoncpp_dir}:jsoncpp",
Cezary Kulakowski4fb738f2019-02-01 10:53:44 +01001118 ]
1119 }
Ian Elliotta9d579e2018-11-28 11:44:48 -07001120}
1121
Jamie Madill1f56ed22019-01-03 15:24:22 -05001122if (!is_component_build && is_android && symbol_level != 0) {
1123 action_foreach("compressed_symbols") {
Courtney Goeltzenleuchterc05c1412019-01-03 12:40:13 -07001124 sources = []
1125 foreach(_library, angle_libraries) {
Jamie Madill77c84962019-06-28 11:24:27 -04001126 sources += [ "$root_out_dir/${_library}${angle_libs_suffix}.so" ]
Courtney Goeltzenleuchterc05c1412019-01-03 12:40:13 -07001127 }
1128 if (angle_enable_vulkan_validation_layers) {
1129 foreach(_layer, vulkan_validation_layers) {
Jamie Madill77c84962019-06-28 11:24:27 -04001130 sources += [ "$root_out_dir/lib${_layer}.so" ]
Courtney Goeltzenleuchterc05c1412019-01-03 12:40:13 -07001131 }
1132 }
Jamie Madill1f56ed22019-01-03 15:24:22 -05001133
1134 script = rebase_path("${root_build_dir}/android/compress_symbols.py",
1135 root_build_dir)
1136
Courtney Goeltzenleuchterc05c1412019-01-03 12:40:13 -07001137 deps = []
1138 foreach(_library, angle_libraries) {
Jamie Madill77c84962019-06-28 11:24:27 -04001139 deps += [ ":$_library" ]
Courtney Goeltzenleuchterc05c1412019-01-03 12:40:13 -07001140 }
1141
1142 if (angle_enable_vulkan_validation_layers) {
1143 foreach(_layer, vulkan_validation_layers) {
Tobin Ehlisf22f16d2019-07-18 15:10:49 -06001144 deps += [
1145 "${angle_root}/third_party/vulkan-validation-layers/src:${_layer}",
1146 ]
Courtney Goeltzenleuchterc05c1412019-01-03 12:40:13 -07001147 }
1148 }
Jamie Madill1f56ed22019-01-03 15:24:22 -05001149
Julien Isorce5641d192020-02-04 21:31:47 -08001150 outputs = [ "$root_out_dir/lib.compressed/{{source_file_part}}" ]
Jamie Madill1f56ed22019-01-03 15:24:22 -05001151
1152 android_nm = "${android_tool_prefix}nm"
Tim Van Patten73e17bf2019-05-14 10:42:25 -06001153 android_strip = "${android_tool_prefix}strip"
Jamie Madill1f56ed22019-01-03 15:24:22 -05001154
1155 args = [
1156 "--objcopy",
1157 rebase_path(android_objcopy, root_build_dir),
1158 "--nm",
1159 rebase_path(android_nm, root_build_dir),
Tim Van Patten73e17bf2019-05-14 10:42:25 -06001160 "--strip",
1161 rebase_path(android_strip, root_build_dir),
Jamie Madill1f56ed22019-01-03 15:24:22 -05001162 "--unstrippedsofile",
1163 "{{source_dir}}/lib.unstripped/{{source_file_part}}",
1164 "--output",
1165 "{{source_dir}}/lib.compressed/{{source_file_part}}",
1166 ]
1167 }
1168}
1169
Geoff Lang6e687af2019-10-17 14:36:41 -04001170if (build_with_chromium && !is_component_build && is_android &&
Courtney Goeltzenleuchter92b16ea2018-12-12 17:06:47 -07001171 current_toolchain == default_toolchain) {
Cody Northrop8cbd3212019-04-23 13:25:20 -06001172 # Package ANGLE libraries
1173 angle_apk("angle_chromium_apk") {
1174 package_name = "com.chromium.angle"
Tim Van Pattenee4fa072019-02-21 19:21:09 +00001175 apk_name = "AngleLibraries"
Cody Northrop8e636442018-11-30 16:24:11 -07001176 }
1177
1178 group("angle_apks") {
Julien Isorce5641d192020-02-04 21:31:47 -08001179 deps = [ ":angle_chromium_apk" ]
Courtney Goeltzenleuchter2565d482018-04-12 17:06:48 -06001180 }
1181}
Jamie Madill1ba72542019-10-04 15:17:49 -04001182
Jamie Madill1ba72542019-10-04 15:17:49 -04001183group("angle") {
1184 data_deps = [
Julien Isorce5641d192020-02-04 21:31:47 -08001185 ":libEGL",
Jamie Madille3c25712019-12-03 14:08:36 -05001186 ":libGLESv1_CM",
Jamie Madill1ba72542019-10-04 15:17:49 -04001187 ":libGLESv2",
Jamie Madill1ba72542019-10-04 15:17:49 -04001188 ]
1189}