Revert "Upgrade NodeJS binary to v16.13.0"
[platform/framework/web/chromium-efl.git] / third_party / angle / BUILD.gn
1 # Copyright 2019 The ANGLE Project Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 # import the ozone_platform_x11 variable
6 import("gni/angle.gni")
7 if (angle_enable_vulkan) {
8   import("//build_overrides//vulkan_headers.gni")
9 }
10 if (angle_use_wayland) {
11   import("//build_overrides/wayland.gni")
12 }
13 if (angle_has_build) {
14   import("//build/config/linux/pkg_config.gni")
15   import("//build/config/sanitizers/sanitizers.gni")
16   import("//build/config/ui.gni")
17   import("//testing/libfuzzer/fuzzer_test.gni")
18
19   if (is_android) {
20     # android/rules.gni can only be imported for Android targets
21     import("//build/config/android/config.gni")
22     import("//build/config/android/rules.gni")
23     import("android/angle_apk.gni")
24   }
25 } else {
26   using_sanitizer = false
27 }
28
29 declare_args() {
30   # Use the PCI lib to collect GPU information on Linux.
31   use_libpci = (is_linux || is_chromeos) && (angle_use_x11 || use_ozone) &&
32                angle_has_build
33
34   # Enable using Vulkan to collect system info as a fallback.
35   angle_enable_vulkan_system_info = false
36
37   # Link in system libGL, to work with apitrace.  See doc/DebuggingTips.md.
38   angle_link_glx = false
39
40   # Don't build extra (test, samples etc) for Windows UWP. We don't have
41   # infrastructure (e.g. windowing helper functions) in place to run them.
42   # Also don't build them with MSVC, because tests and unused dependencies
43   # often have problems building with it, e.g. for C++20.
44   angle_build_all = !build_with_chromium && !angle_is_winuwp &&
45                     !angle_is_msvc && angle_has_build && angle_build_tests
46
47   # Enable generating current commit information using git
48   angle_enable_commit_id = true
49
50   # Abseil has trouble supporting MSVC, particularly regarding component builds.
51   # http://crbug.com/1126524
52   angle_enable_abseil = angle_has_build && is_clang
53
54   # Adds run-time checks to filter out EVENT() messages when the debug annotator is disabled.
55   angle_enable_annotator_run_time_checks = false
56
57   # Enables non-conformant extensions and features
58   angle_expose_non_conformant_extensions_and_versions = false
59
60   # Optional feature that forces dirty state whenever we use a new context regardless of thread.
61   angle_force_context_check_every_call = false
62
63   # Allow shared library custom name extensions for setting soname such as libEGL.so.1
64   angle_egl_extension = ""
65   angle_glesv2_extension = ""
66
67   # Enable share context lock. If it is false, the client need to use gl calls in a threadsafe way.
68   # Chromium only uses share contexts on the GPU thread.
69   # angle_deqp_tests contains threading related tests.
70   angle_enable_share_context_lock =
71       !build_with_chromium || build_angle_deqp_tests
72
73   if (is_android) {
74     # Use Android TLS slot to store current context.
75     angle_use_android_tls_slot = !build_with_chromium
76   }
77
78   angle_enable_global_mutex_recursion = is_android && angle_enable_vulkan
79 }
80
81 if (angle_build_all) {
82   group("all") {
83     testonly = true
84     deps = [
85       ":angle",
86       ":angle_shader_translator",
87       ":translator_fuzzer",
88       ":xxhash_fuzzer",
89       "$angle_root/samples:angle_samples",
90       "$angle_root/src/tests:angle_tests",
91     ]
92     if (angle_enable_cl) {
93       deps += [ "$angle_root/src/libOpenCL:angle_cl" ]
94     }
95     if (angle_build_mesa) {
96       deps += [ "$angle_root/third_party/mesa" ]
97     }
98   }
99 }
100
101 import("src/angle_program_serialize_data_version.gni")
102 import("src/compiler.gni")
103 import("src/libGLESv2.gni")
104
105 # This config is exported to dependent targets (and also applied to internal
106 # ones).
107 config("external_config") {
108   include_dirs = [ "include" ]
109 }
110
111 # Prevent the GL headers from redeclaring ANGLE entry points.
112 config("no_gl_prototypes") {
113   defines = [
114     "GL_GLES_PROTOTYPES=0",
115     "EGL_EGL_PROTOTYPES=0",
116   ]
117 }
118
119 config("gl_prototypes") {
120   defines = [
121     "GL_GLES_PROTOTYPES=1",
122     "EGL_EGL_PROTOTYPES=1",
123     "GL_GLEXT_PROTOTYPES",
124     "EGL_EGLEXT_PROTOTYPES",
125   ]
126 }
127
128 # This config is applied to internal Angle targets (not pushed to dependents).
129 config("internal_config") {
130   include_dirs = [
131     "include",
132     "src",
133   ]
134
135   # Handle breaking changes in VulkanMemoryAllocator.
136   angle_vma_version_define = "ANGLE_VMA_VERSION="
137   if (defined(angle_vma_version)) {
138     angle_vma_version_define += angle_vma_version
139   } else {
140     # Default to 2.3.0. This can be bumped and include guards removed when all
141     # clients have migrated to 3.x.
142     angle_vma_version_define += 2003000
143   }
144
145   defines = [ angle_vma_version_define ]
146
147   if (is_win) {
148     defines += [ "ANGLE_IS_WIN" ]
149     if (angle_is_winuwp) {
150       defines += [ "ANGLE_IS_WINUWP" ]
151     }
152   } else if (is_linux || is_chromeos) {
153     defines += [ "ANGLE_IS_LINUX" ]
154   }
155
156   if (angle_enable_share_context_lock) {
157     defines += [ "ANGLE_ENABLE_SHARE_CONTEXT_LOCK=1" ]
158   }
159
160   if (is_android) {
161     if (angle_use_android_tls_slot) {
162       defines += [ "ANGLE_USE_ANDROID_TLS_SLOT=1" ]
163     }
164   }
165
166   if (angle_enable_global_mutex_recursion) {
167     defines += [ "ANGLE_ENABLE_GLOBAL_MUTEX_RECURSION=1" ]
168   }
169
170   # Enables debug/trace-related functionality, including logging every GLES/EGL API command to the
171   # "angle_debug.txt" file on desktop.  Enables debug markers for AGI, but must also set
172   # angle_enable_annotator_run_time_checks to improve performance.
173   if (angle_enable_trace) {
174     defines += [ "ANGLE_ENABLE_DEBUG_TRACE=1" ]
175   }
176
177   # When used with angle_enable_trace, enables logging every GLES/EGL API command to Android logcat
178   # Enables debug markers for AGI regardless of run-time checks.
179   if (angle_enable_trace_android_logcat) {
180     defines += [ "ANGLE_ENABLE_TRACE_ANDROID_LOGCAT=1" ]
181   }
182
183   # When used with angle_enable_trace, enables logging every GLES/EGL API command to the terminal
184   if (angle_enable_trace_events) {
185     defines += [ "ANGLE_ENABLE_TRACE_EVENTS=1" ]
186   }
187
188   # Checks that unwind backtrace support for Android is enabled only for debug mode.
189   assert(is_debug || !angle_enable_unwind_backtrace_support)
190
191   if (is_chromeos) {
192     defines += [ "ANGLE_PLATFORM_CHROMEOS" ]
193   }
194
195   if (is_ggp) {
196     defines += [ "__ggp__" ]
197   }
198
199   if (angle_use_vulkan_null_display) {
200     defines += [ "ANGLE_USE_VULKAN_NULL_DISPLAY" ]
201   } else if (angle_use_vulkan_display) {
202     defines += [ "ANGLE_USE_VULKAN_DISPLAY" ]
203     if (!angle_use_x11) {
204       defines += [ "EGL_NO_X11" ]
205     }
206
207     # These two are needed here to correctly select OSWindow::New
208     if (angle_use_x11) {
209       defines += [ "ANGLE_USE_X11" ]
210     }
211     if (angle_use_wayland) {
212       defines += [ "ANGLE_USE_WAYLAND" ]
213     }
214
215     if (angle_vulkan_display_mode == "simple") {
216       defines += [ "ANGLE_VULKAN_DISPLAY_MODE_SIMPLE" ]
217     } else if (angle_vulkan_display_mode == "headless") {
218       defines += [ "ANGLE_VULKAN_DISPLAY_MODE_HEADLESS" ]
219     }
220   }
221
222   if (is_lsan) {
223     defines += [ "ANGLE_WITH_LSAN" ]
224   }
225
226   if (angle_has_astc_encoder) {
227     defines += [ "ANGLE_HAS_ASTCENC" ]
228   }
229
230   if (angle_test_enable_system_egl) {
231     defines += [ "ANGLE_TEST_ENABLE_SYSTEM_EGL" ]
232   }
233
234   if (angle_debug_layers_enabled) {
235     defines += [ "ANGLE_DEBUG_LAYERS_ENABLED" ]
236   }
237
238   if (angle_build_mesa) {
239     defines += [ "ANGLE_HAS_MESA" ]
240   }
241
242   if (angle_standalone || build_with_chromium) {
243     defines += [ "ANGLE_OUTSIDE_WEBKIT" ]
244   }
245 }
246
247 config("constructor_and_destructor_warnings") {
248   if (is_clang) {
249     cflags = [
250       "-Wexit-time-destructors",
251       "-Wglobal-constructors",
252     ]
253   }
254 }
255
256 config("extra_warnings") {
257   cflags = []
258
259   is_gcc = !is_clang && !is_win
260
261   # Avoid failing builds for warnings enabled by Skia build.
262   if (defined(is_skia_standalone)) {
263     cflags += [ "-w" ]
264   }
265
266   # Enable more default warnings on Windows.
267   if (is_win) {
268     cflags += [
269       "/we4244",  # Conversion: possible loss of data.
270       "/we4312",  # Conversion: greater size.
271       "/we4456",  # Variable shadowing.
272       "/we4458",  # declaration hides class member.
273       "/we4715",  # not all control paths return a value
274       "/we4800",  # forcing value to bool.
275       "/we4838",  # narrowing conversion.
276     ]
277   }
278   if (is_clang) {
279     cflags += [
280       "-Wbad-function-cast",
281       "-Wconditional-uninitialized",
282       "-Wextra-semi-stmt",
283       "-Wfloat-conversion",
284       "-Winconsistent-missing-destructor-override",
285       "-Wmissing-field-initializers",
286       "-Wnewline-eof",
287       "-Wnon-virtual-dtor",
288       "-Wredundant-parens",
289       "-Wreturn-std-move",
290       "-Wshadow",
291       "-Wshadow-field",
292       "-Wtautological-type-limit-compare",
293       "-Wundefined-reinterpret-cast",
294       "-Wunneeded-internal-declaration",
295       "-Wunused-but-set-variable",
296       "-Wsuggest-destructor-override",
297       "-Wsuggest-override",
298
299       # The below warnings are used by WebKit. We enable them to make rolling
300       # ANGLE in WebKit easier.
301       "-Wparentheses",
302       "-Wrange-loop-analysis",
303       "-Wstrict-prototypes",
304       "-Wunreachable-code-aggressive",
305       "-Wshorten-64-to-32",
306     ]
307   }
308
309   if (is_gcc) {
310     cflags_cc = [ "-Wdeprecated-copy" ]
311   }
312
313   if (angle_is_winuwp) {
314     cflags += [
315       "/wd4091",  # keyword ignored on left of type when no variable is declared
316       "/wd4447",  # 'main' signature found without threading model.
317     ]
318   }
319 }
320
321 # This config adds build-ids to the associated library.
322 # -Wl is a special option that indicates that clang should pass the associated
323 # option --build-id to the linker. This will cause a build-id section to be added
324 # to the associated library. The build-id makes it possible for a debugger to
325 # find the right symbol file to use.
326 config("build_id_config") {
327   ldflags = [ "-Wl,--build-id" ]
328 }
329
330 _use_copy_compiler_dll = angle_has_build && is_win
331
332 if (_use_copy_compiler_dll) {
333   copy("copy_compiler_dll") {
334     sources = [ "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll" ]
335     outputs = [ "$root_out_dir/{{source_file_part}}" ]
336   }
337 }
338
339 # Holds the shared includes so we only need to list them once.
340 config("includes_config") {
341   include_dirs = [ "include" ]
342 }
343
344 config("angle_uwp_env") {
345   if (angle_is_winuwp) {
346     defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ]
347   }
348 }
349
350 angle_source_set("cl_includes") {
351   sources = cl_includes
352   public_configs = [ ":external_config" ]
353 }
354
355 angle_source_set("includes") {
356   sources = libangle_includes
357   public_configs = [ ":includes_config" ]
358   if (angle_enable_cl) {
359     public_deps = [ ":cl_includes" ]
360   }
361 }
362
363 config("disable_unreachable_code_break_warning") {
364   if (is_clang) {
365     cflags = [ "-Wno-unreachable-code-break" ]
366   }
367 }
368
369 angle_static_library("preprocessor") {
370   sources = angle_preprocessor_sources
371
372   # preprocessor_tab_autogen.cpp contains an instance of this.
373   configs += [ ":disable_unreachable_code_break_warning" ]
374
375   public_deps = [
376     ":angle_common",
377     ":angle_translator_headers",
378   ]
379 }
380
381 config("angle_disable_pool_alloc") {
382   defines = [ "ANGLE_DISABLE_POOL_ALLOC" ]
383 }
384
385 config("debug_annotations_config") {
386   defines = []
387   if (is_debug) {
388     defines += [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
389   }
390   if (angle_enable_annotator_run_time_checks) {
391     # When used with angle_enable_trace, enables debug markers for AGI with run-time checks to
392     # filter out EVENT() messages when the debug annotator is disabled.
393     defines += [ "ANGLE_ENABLE_ANNOTATOR_RUN_TIME_CHECKS" ]
394   }
395 }
396
397 config("angle_asserts_config") {
398   if (angle_assert_always_on) {
399     defines = [ "ANGLE_ASSERT_ALWAYS_ON" ]
400   }
401 }
402
403 config("angle_common_config") {
404   include_dirs = [
405     "src/common/base",
406     "src/common/third_party/xxhash",
407   ]
408   if (is_android) {
409     libs = [ "log" ]
410   }
411
412   defines = []
413   if (angle_delegate_workers) {
414     defines += [ "ANGLE_DELEGATE_WORKERS" ]
415   }
416 }
417
418 # Silences the "indirect call of a function with wrong dynamic type" cfi error
419 config("angle_no_cfi_icall") {
420   if (is_cfi && use_cfi_icall && current_toolchain == default_toolchain) {
421     cflags = [ "-fno-sanitize=cfi-icall" ]
422   }
423 }
424
425 # Silences the "cast from void* or another unrelated type to the wrong dynamic type" cfi error
426 config("angle_no_cfi_unrelated_cast") {
427   if (is_cfi && use_cfi_cast && current_toolchain == default_toolchain) {
428     cflags = [ "-fno-sanitize=cfi-unrelated-cast" ]
429   }
430 }
431
432 angle_source_set("xxhash") {
433   sources = xxhash_sources
434   if (is_clang) {
435     cflags_c = [ "-Wno-implicit-fallthrough" ]
436   }
437 }
438
439 if (angle_has_build) {
440   fuzzer_test("xxhash_fuzzer") {
441     sources = [ "src/common/third_party/xxhash/xxhash_fuzzer.cpp" ]
442     deps = [ ":xxhash" ]
443   }
444 }
445
446 template("angle_common_lib") {
447   angle_static_library(target_name) {
448     sources = invoker.sources
449
450     configs += [
451       ":angle_common_config",
452       ":debug_annotations_config",
453     ]
454
455     deps = [ ":xxhash" ]
456
457     public_deps = [
458       ":angle_abseil",
459       ":includes",
460     ]
461     public_configs += [ ":angle_common_config" ]
462     if (angle_has_build && use_fuzzing_engine) {
463       all_dependent_configs = [ ":angle_disable_pool_alloc" ]
464     }
465
466     if (is_linux || is_chromeos) {
467       libs = [ "dl" ]
468     }
469
470     if (is_android && (angle_enable_gl || angle_enable_vulkan)) {
471       # In API level 26 ANativeWindow APIs were moved from libandroid.so
472       # into a separate library, libnativewindow.so
473       if (ndk_api_level_at_least_26) {
474         libs = [ "nativewindow" ]
475       } else {
476         libs = [ "android" ]
477       }
478     }
479
480     if (angle_expose_non_conformant_extensions_and_versions) {
481       defines = [ "ANGLE_EXPOSE_NON_CONFORMANT_EXTENSIONS_AND_VERSIONS" ]
482     }
483
484     if (using_sanitizer && !build_with_chromium) {
485       data_deps =
486           [ "//build/config/clang:llvm-symbolizer_data($host_toolchain)" ]
487     }
488
489     if (is_apple) {
490       frameworks = [ "Metal.framework" ]
491     }
492   }
493 }
494
495 angle_common_lib("angle_common") {
496   sources = libangle_common_sources
497   if (angle_enable_cl) {
498     sources += libangle_common_cl_sources
499   }
500 }
501
502 angle_common_lib("angle_common_shader_state") {
503   sources = libangle_common_shader_state_sources
504 }
505
506 angle_source_set("angle_capture_common") {
507   sources = [
508     "src/common/frame_capture_utils.cpp",
509     "src/common/frame_capture_utils.h",
510     "src/common/frame_capture_utils_autogen.cpp",
511     "src/common/frame_capture_utils_autogen.h",
512   ]
513   deps = [ ":angle_common" ]
514   public_deps = [ ":angle_gl_enum_utils" ]
515 }
516
517 config("angle_image_util_config") {
518   include_dirs = [
519     "include",
520     "src",
521   ]
522 }
523
524 angle_source_set("angle_image_util_headers") {
525   sources = libangle_image_util_headers
526   public_deps = [ ":angle_common" ]
527 }
528
529 angle_static_library("angle_image_util") {
530   sources = libangle_image_util_sources
531   public_configs += [ ":angle_image_util_config" ]
532   public_deps = [ ":angle_image_util_headers" ]
533
534   if (angle_has_astc_encoder) {
535     public_deps += [ "third_party/astc-encoder:astcenc" ]
536     include_dirs = [ "third_party/astc-encoder/src/Source/" ]
537   }
538 }
539
540 config("angle_gl_visibility_config") {
541   if (is_win) {
542     defines = [
543       "GL_APICALL=",
544       "GL_API=",
545     ]
546   } else {
547     defines = [
548       "GL_APICALL=__attribute__((visibility(\"default\")))",
549       "GL_API=__attribute__((visibility(\"default\")))",
550     ]
551   }
552 }
553
554 config("angle_vulkan_wayland_config") {
555   if (angle_enable_vulkan && angle_use_wayland &&
556       defined(vulkan_wayland_include_dirs)) {
557     include_dirs = vulkan_wayland_include_dirs
558   }
559 }
560
561 config("angle_gpu_info_util_config") {
562   include_dirs = [
563     "include",
564     "src",
565   ]
566 }
567
568 angle_static_library("angle_gpu_info_util") {
569   public_configs += [
570     ":angle_gpu_info_util_config",
571     ":angle_backend_config",
572   ]
573   public_deps = [ ":angle_common" ]
574   sources = libangle_gpu_info_util_sources
575   deps = []
576   libs = []
577   defines = []
578
579   if (angle_build_vulkan_system_info) {
580     sources += libangle_gpu_info_util_vulkan_sources
581     deps += [
582       "$angle_vulkan_headers_dir:vulkan_headers",
583       "src/common/vulkan:angle_libvulkan_loader",
584       "src/common/vulkan:angle_vulkan_icd",
585     ]
586     configs += [ "$angle_root:angle_no_cfi_icall" ]
587     if (angle_enable_vulkan_system_info) {
588       defines += [ "ANGLE_USE_VULKAN_SYSTEM_INFO" ]
589     }
590   }
591
592   if (is_android) {
593     sources += libangle_gpu_info_util_android_sources
594   }
595
596   if (is_fuchsia) {
597     sources += libangle_gpu_info_util_fuchsia_sources
598     deps += [ "$angle_root/src/common/vulkan:angle_vulkan_entry_points" ]
599   }
600
601   if (is_win) {
602     sources += libangle_gpu_info_util_win_sources
603     if (!angle_is_winuwp) {
604       libs += [ "setupapi.lib" ]
605     }
606     libs += [ "dxgi.lib" ]
607   }
608
609   if (is_linux || is_chromeos || is_tizen) {
610     sources += libangle_gpu_info_util_linux_sources
611
612     if (angle_use_x11 && angle_has_build) {
613       sources += libangle_gpu_info_util_x11_sources
614       deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
615       defines += [ "GPU_INFO_USE_X11" ]
616       libs += [
617         "X11",
618         "Xi",
619         "Xext",
620       ]
621     }
622
623     if (angle_use_wayland && angle_has_build) {
624       public_deps += [ ":angle_wayland" ]
625     }
626   }
627
628   if (use_libpci) {
629     sources += libangle_gpu_info_util_libpci_sources
630     defines += [ "GPU_INFO_USE_LIBPCI" ]
631     libs += [ "pci" ]
632   }
633
634   if (is_apple) {
635     frameworks = [
636       "IOKit.framework",
637       "CoreFoundation.framework",
638       "CoreGraphics.framework",
639     ]
640     if (angle_enable_eagl) {
641       frameworks += [ "OpenGLES.framework" ]
642     } else if (angle_enable_cgl) {
643       frameworks += [ "OpenGL.framework" ]
644     }
645     if (is_mac || angle_enable_cgl) {
646       sources += libangle_gpu_info_util_mac_sources
647     }
648     if (is_ios && !angle_enable_cgl) {
649       sources += libangle_gpu_info_util_ios_sources
650     }
651   }
652 }
653
654 angle_source_set("angle_translator_headers") {
655   sources = angle_translator_exported_headers
656   public_deps = [ ":includes" ]
657 }
658
659 template("translator_lib") {
660   angle_static_library(target_name) {
661     sources = angle_translator_sources
662     defines = []
663
664     _needs_glsl_base = false
665     _needs_glsl_and_vulkan_base = false
666     _uses_spirv = false
667
668     # Frontend support:
669     if (angle_enable_desktop_glsl) {
670       sources += angle_translator_glsl_symbol_table_sources
671     } else {
672       sources += angle_translator_essl_symbol_table_sources
673     }
674
675     # Backend support:
676     if (angle_enable_essl || use_fuzzing_engine) {
677       _needs_glsl_base = true
678       sources += angle_translator_essl_sources
679       defines += [ "ANGLE_ENABLE_ESSL" ]
680     }
681
682     if (angle_enable_glsl || use_fuzzing_engine) {
683       _needs_glsl_base = true
684       _needs_glsl_and_vulkan_base = true
685       sources += angle_translator_glsl_sources
686       defines += [ "ANGLE_ENABLE_GLSL" ]
687
688       if (is_apple) {
689         sources += angle_translator_glsl_apple_sources
690       }
691     }
692
693     if (angle_enable_hlsl || use_fuzzing_engine) {
694       sources += angle_translator_hlsl_sources
695       defines += [ "ANGLE_ENABLE_HLSL" ]
696     }
697
698     if (!invoker.gl_d3d_only) {
699       if (angle_enable_vulkan || use_fuzzing_engine ||
700           angle_enable_msl_through_spirv) {
701         _needs_glsl_base = true
702         _needs_glsl_and_vulkan_base = true
703         _uses_spirv = true
704
705         # This translator is needed by metal backend also.
706         sources += angle_translator_lib_vulkan_sources
707       }
708
709       if (angle_enable_vulkan || use_fuzzing_engine) {
710         defines += [ "ANGLE_ENABLE_VULKAN" ]
711       }
712
713       if (angle_enable_metal) {
714         sources += angle_translator_lib_metal_sources
715         defines += [ "ANGLE_ENABLE_METAL" ]
716         if (angle_enable_msl_through_spirv) {
717           defines += [ "ANGLE_ENABLE_METAL_SPIRV" ]
718         }
719       }
720     }
721
722     if (_needs_glsl_base) {
723       sources += angle_translator_glsl_base_sources
724     }
725     if (_needs_glsl_and_vulkan_base) {
726       sources += angle_translator_glsl_and_vulkan_base_sources
727     }
728
729     public_configs += [ ":external_config" ]
730
731     deps = [
732       ":angle_common_shader_state",
733       ":includes",
734       ":preprocessor",
735       "$angle_root/src/common/spirv:angle_spirv_headers",
736     ]
737
738     if (_uses_spirv) {
739       deps += [
740         "$angle_root/src/common/spirv:angle_spirv_base",
741         "$angle_root/src/common/spirv:angle_spirv_builder",
742         "${angle_spirv_headers_dir}:spv_headers",
743         "${angle_spirv_tools_dir}:spvtools_headers",
744         "${angle_spirv_tools_dir}:spvtools_val",
745       ]
746     }
747
748     public_deps = [
749       ":angle_common",
750       ":angle_translator_headers",
751       ":angle_version_info",
752     ]
753
754     if (is_win) {
755       # Necessary to suppress some system header xtree warnings in Release.
756       # For some reason this warning doesn't get triggered in Chromium
757       cflags = [ "/wd4718" ]
758     }
759   }
760 }
761
762 translator_lib("translator") {
763   gl_d3d_only = false
764 }
765
766 if (angle_enable_essl || angle_enable_glsl || angle_enable_hlsl) {
767   translator_lib("translator_gl_d3d_only") {
768     gl_d3d_only = true
769   }
770 }
771
772 angle_source_set("translator_fuzzer") {
773   sources = [ "src/compiler/fuzz/translator_fuzzer.cpp" ]
774
775   include_dirs = [
776     "include",
777     "src",
778   ]
779
780   deps = [ ":translator" ]
781 }
782
783 config("angle_program_version_id_config") {
784   include_dirs = [ "$root_gen_dir/angle" ]
785   visibility = [ ":angle_program_version_id" ]
786 }
787
788 action("angle_program_version_id") {
789   response_file_contents =
790       rebase_path(angle_code_affecting_program_serialize, root_build_dir)
791
792   _program_version_header = "$root_gen_dir/angle/ANGLEShaderProgramVersion.h"
793   script = "src/program_serialize_data_version.py"
794   outputs = [ _program_version_header ]
795
796   visibility = [ ":angle_version" ]
797
798   inputs = angle_code_affecting_program_serialize
799
800   args = [
801     rebase_path(_program_version_header, root_build_dir),
802     "{{response_file_name}}",
803   ]
804
805   public_configs = [ ":angle_program_version_id_config" ]
806 }
807
808 config("angle_commit_id_config") {
809   include_dirs = [ "$root_gen_dir/angle" ]
810   visibility = [ ":angle_commit_id" ]
811 }
812
813 action("angle_commit_id") {
814   _commit_id_header = "$root_gen_dir/angle/angle_commit.h"
815   script = "src/commit_id.py"
816   outputs = [ _commit_id_header ]
817
818   visibility = [ ":angle_version" ]
819
820   # Add git as a dependency if it is available.
821   if (angle_enable_commit_id &&
822       exec_script("src/commit_id.py", [ "check" ], "value") == 1) {
823     # commit id should depend on angle's HEAD revision
824     git_dirs = exec_script("src/commit_id.py", [ "get_git_dirs" ], "list lines")
825     inputs = [ git_dirs[0] + "/HEAD" ]
826     branch = read_file(git_dirs[0] + "/HEAD", "string")
827     result = string_split(branch)
828     if (result[0] == "ref:") {
829       _ref_file = result[1]
830
831       # If git has packed the contents of .git/refs/heads/ in .git/packed-refs,
832       # unpack the head before depending on it.
833       exec_script("src/commit_id.py",
834                   [
835                     "unpack",
836                     _ref_file,
837                   ],
838                   "")
839       inputs += [ git_dirs[1] + "/" + _ref_file ]
840     }
841   }
842
843   args = [
844     "gen",
845     rebase_path(_commit_id_header, root_build_dir),
846   ]
847
848   public_configs = [ ":angle_commit_id_config" ]
849 }
850
851 angle_source_set("angle_version") {
852   sources = [ "src/common/angle_version.h" ]
853   public_deps = [
854     ":angle_commit_id",
855     ":angle_program_version_id",
856   ]
857   visibility = [ ":angle_version_info" ]
858
859   # The version headers are used directly in Windows .RC files.
860   if (is_win) {
861     visibility += [
862       ":libEGL",
863       ":libGL",
864       ":libGLESv1_CM",
865       ":libGLESv2",
866       ":libGLESv2_capture_complement",
867     ]
868     if (angle_enable_vulkan) {
869       visibility += [
870         ":libEGL_vulkan_secondaries",
871         ":libGLESv2_vulkan_secondaries",
872       ]
873     }
874   }
875 }
876
877 angle_source_set("angle_version_info") {
878   sources = [
879     "src/common/angle_version_info.cpp",
880     "src/common/angle_version_info.h",
881   ]
882   deps = [
883     ":angle_translator_headers",
884     ":angle_version",
885   ]
886 }
887
888 config("angle_backend_config") {
889   defines = []
890
891   if (angle_force_context_check_every_call) {
892     defines += [ "ANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL=1" ]
893   }
894
895   if (angle_expose_non_conformant_extensions_and_versions) {
896     defines += [ "ANGLE_EXPOSE_NON_CONFORMANT_EXTENSIONS_AND_VERSIONS" ]
897   }
898
899   configs = []
900
901   if (angle_enable_d3d11) {
902     configs += [ "src/libANGLE/renderer/d3d:angle_d3d11_backend_config" ]
903   }
904
905   if (angle_enable_d3d9) {
906     configs += [ "src/libANGLE/renderer/d3d:angle_d3d9_backend_config" ]
907   }
908
909   if (angle_enable_gl) {
910     configs += [ "src/libANGLE/renderer/gl:angle_gl_backend_config" ]
911   }
912
913   if (angle_enable_null) {
914     configs += [ "src/libANGLE/renderer/null:angle_null_backend_config" ]
915   }
916
917   if (angle_enable_metal) {
918     configs += [ "src/libANGLE/renderer/metal:angle_metal_backend_config" ]
919   }
920
921   if (angle_enable_vulkan) {
922     configs += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ]
923   }
924
925   if (angle_enable_cl_passthrough) {
926     configs += [ "src/libANGLE/renderer/cl:angle_cl_backend_config" ]
927   }
928
929   if (angle_is_winuwp) {
930     configs += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp_config" ]
931   }
932 }
933
934 config("libANGLE_config") {
935   cflags = []
936   defines = []
937   libs = []
938   ldflags = []
939   defines += [ "LIBANGLE_IMPLEMENTATION" ]
940
941   if (is_win) {
942     cflags += [ "/wd4530" ]  # C++ exception handler used, but unwind semantics
943                              # are not enabled.
944   }
945
946   if (is_android && (angle_enable_gl || angle_enable_vulkan)) {
947     # In API level 26 ANativeWindow APIs were moved from libandroid.so
948     # into a separate library, libnativewindow.so
949     if (ndk_api_level_at_least_26) {
950       libs += [ "nativewindow" ]
951     } else {
952       libs += [ "android" ]
953     }
954   }
955
956   if (angle_use_x11) {
957     defines += [ "ANGLE_USE_X11" ]
958   }
959
960   if (angle_use_wayland) {
961     defines += [ "ANGLE_USE_WAYLAND" ]
962   }
963
964   if (angle_enable_overlay) {
965     defines += [ "ANGLE_ENABLE_OVERLAY=1" ]
966   }
967   if (angle_enable_perf_counter_output) {
968     defines += [ "ANGLE_ENABLE_PERF_COUNTER_OUTPUT=1" ]
969   }
970 }
971
972 angle_source_set("libANGLE_headers") {
973   sources = libangle_headers
974   if (angle_enable_cl) {
975     sources += libangle_cl_headers
976   }
977   public_deps = [
978     ":angle_common",
979     ":angle_translator_headers",
980   ]
981   public_configs += [ ":libANGLE_config" ]
982 }
983
984 if ((is_win && angle_enable_gl) || angle_enable_d3d11 || angle_enable_d3d9) {
985   angle_source_set("angle_d3d_format_tables") {
986     sources = [
987       "src/libANGLE/renderer/dxgi_format_map.h",
988       "src/libANGLE/renderer/dxgi_format_map_autogen.cpp",
989       "src/libANGLE/renderer/dxgi_support_table.h",
990       "src/libANGLE/renderer/dxgi_support_table_autogen.cpp",
991     ]
992
993     if (!angle_is_winuwp) {
994       sources += [
995         "src/libANGLE/renderer/d3d_format.cpp",
996         "src/libANGLE/renderer/d3d_format.h",
997       ]
998     }
999
1000     public_deps = [ ":libANGLE_headers" ]
1001     configs += [ ":angle_backend_config" ]
1002   }
1003 }
1004
1005 # Vulkan gets mixed in later depending on secondary command buffer configs
1006 angle_source_set("libANGLE_no_vulkan") {
1007   sources = libangle_sources
1008   if (angle_enable_cl) {
1009     sources += libangle_cl_sources
1010   }
1011   defines = []
1012   if (angle_enable_gl_desktop_frontend) {
1013     defines += [ "ANGLE_ENABLE_GL_DESKTOP_FRONTEND" ]
1014   }
1015
1016   include_dirs = []
1017   libs = []
1018   if (angle_link_glx) {
1019     libs += [ "GL" ]
1020     defines += [ "ANGLE_LINK_GLX" ]
1021   }
1022   public_deps = [
1023     ":angle_common",
1024     ":angle_common_shader_state",
1025     ":angle_gpu_info_util",
1026     ":angle_image_util",
1027     ":angle_version_info",
1028     ":libANGLE_headers",
1029     ":translator",
1030   ]
1031   deps = [
1032     ":angle_compression",
1033     ":includes",
1034   ]
1035
1036   if (is_win && !angle_is_winuwp) {
1037     libs += [
1038       "gdi32.lib",
1039       "user32.lib",
1040     ]
1041   }
1042
1043   if (angle_enable_d3d11) {
1044     public_deps += [ "src/libANGLE/renderer/d3d:angle_d3d11_backend" ]
1045   }
1046
1047   if (angle_enable_d3d9) {
1048     public_deps += [ "src/libANGLE/renderer/d3d:angle_d3d9_backend" ]
1049   }
1050
1051   if (angle_enable_gl) {
1052     public_deps += [ "src/libANGLE/renderer/gl:angle_gl_backend" ]
1053   }
1054
1055   if (angle_enable_null) {
1056     public_deps += [ "src/libANGLE/renderer/null:angle_null_backend" ]
1057   }
1058
1059   if (angle_is_winuwp) {
1060     public_deps += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp" ]
1061   }
1062
1063   if (angle_enable_d3d11) {
1064     libs += [ "dxguid.lib" ]
1065   }
1066
1067   if (angle_enable_metal) {
1068     public_deps += [ "src/libANGLE/renderer/metal:angle_metal_backend" ]
1069   }
1070
1071   if (angle_enable_cl_passthrough) {
1072     public_deps += [ "src/libANGLE/renderer/cl:angle_cl_backend" ]
1073   }
1074
1075   # Enable extra Chromium style warnings for libANGLE.
1076   if (is_clang && angle_has_build) {
1077     suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ]
1078   }
1079
1080   if (is_apple) {
1081     sources += libangle_mac_sources
1082   }
1083
1084   if (is_ios) {
1085     sources += [ "src/libANGLE/renderer/driver_utils_ios.mm" ]
1086   }
1087
1088   if (is_debug) {
1089     defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
1090   }
1091
1092   configs += [ ":debug_annotations_config" ]
1093   public_configs += [
1094     ":libANGLE_config",
1095     ":angle_backend_config",
1096   ]
1097
1098   if (_use_copy_compiler_dll) {
1099     data_deps = [ ":copy_compiler_dll" ]
1100   }
1101 }
1102
1103 config("angle_frame_capture_disabled") {
1104   defines = [ "ANGLE_CAPTURE_ENABLED=0" ]
1105 }
1106
1107 angle_source_set("angle_frame_capture_mock") {
1108   public_deps = [ ":libANGLE_headers" ]
1109   public_configs = [ ":angle_frame_capture_disabled" ]
1110   sources = [
1111     "src/common/frame_capture_utils.h",
1112     "src/common/frame_capture_utils_autogen.h",
1113     "src/common/gl_enum_utils_autogen.h",
1114     "src/libANGLE/capture/FrameCapture.h",
1115     "src/libANGLE/capture/FrameCapture_mock.cpp",
1116     "src/libANGLE/capture/serialize.h",
1117     "src/libANGLE/capture/serialize_mock.cpp",
1118   ]
1119 }
1120
1121 angle_source_set("angle_gl_enum_utils") {
1122   deps = [ ":angle_common" ]
1123   sources = [
1124     "src/common/gl_enum_utils.cpp",
1125     "src/common/gl_enum_utils.h",
1126     "src/common/gl_enum_utils_autogen.cpp",
1127     "src/common/gl_enum_utils_autogen.h",
1128   ]
1129 }
1130
1131 if (angle_use_wayland) {
1132   config("angle_wayland_config") {
1133     if ("$wayland_gn_dir" == "") {
1134       libs = [
1135         "wayland-client",
1136         "wayland-egl",
1137       ]
1138     }
1139
1140     include_dirs = [
1141       "$wayland_dir/egl",
1142       "$wayland_dir/src",
1143     ]
1144   }
1145
1146   group("angle_wayland") {
1147     public_configs = [ ":angle_wayland_config" ]
1148
1149     if ("$wayland_gn_dir" != "") {
1150       # Use third-party targets
1151       public_deps = [
1152         "$wayland_gn_dir:wayland_client",
1153         "$wayland_gn_dir:wayland_egl",
1154       ]
1155     }
1156   }
1157 }
1158
1159 if (!defined(angle_abseil_cpp_dir)) {
1160   angle_abseil_cpp_dir = "//third_party/abseil-cpp"
1161 }
1162
1163 config("angle_abseil_config") {
1164   if (angle_enable_abseil) {
1165     defines = [ "ANGLE_USE_ABSEIL" ]
1166
1167     configs = [
1168       "$angle_abseil_cpp_dir:absl_define_config",
1169       "$angle_abseil_cpp_dir:absl_include_config",
1170     ]
1171   }
1172 }
1173
1174 group("angle_abseil") {
1175   if (angle_enable_abseil) {
1176     # When build_with_chromium=true we need to include "//third_party/abseil-cpp:absl" while
1177     # we can be more specific when building standalone ANGLE.
1178     if (build_with_chromium || is_component_build) {
1179       public_deps = [ "$angle_abseil_cpp_dir:absl" ]
1180     } else {
1181       public_deps = [
1182         "$angle_abseil_cpp_dir/absl/container:flat_hash_map",
1183         "$angle_abseil_cpp_dir/absl/container:flat_hash_set",
1184       ]
1185     }
1186
1187     public_configs = [ ":angle_abseil_config" ]
1188   }
1189 }
1190
1191 config("angle_compression_config") {
1192   include_dirs = [ "//third_party/zlib/google" ]
1193 }
1194
1195 group("angle_compression") {
1196   public_configs = [
1197     ":angle_compression_config",
1198     "//third_party/zlib:zlib_config",
1199   ]
1200   public_deps =
1201       [ "$angle_zlib_compression_utils_dir:compression_utils_portable" ]
1202 }
1203
1204 if (angle_has_rapidjson) {
1205   config("angle_rapidjson_config") {
1206     defines = [ "ANGLE_HAS_RAPIDJSON" ]
1207   }
1208   angle_source_set("angle_json_serializer") {
1209     public_deps = [
1210       ":angle_common",
1211       "$angle_root/third_party/rapidjson",
1212     ]
1213     sources = [
1214       "src/common/serializer/JsonSerializer.cpp",
1215       "src/common/serializer/JsonSerializer.h",
1216     ]
1217     public_configs = [ ":angle_rapidjson_config" ]
1218   }
1219 }
1220
1221 assert(angle_has_frame_capture || !angle_with_capture_by_default)
1222 if (angle_has_frame_capture) {
1223   config("angle_frame_capture_enabled") {
1224     defines = [ "ANGLE_CAPTURE_ENABLED=1" ]
1225   }
1226 }
1227
1228 template("libANGLE_template") {
1229   angle_source_set("${target_name}") {
1230     public_deps = invoker.public_deps + [ ":libANGLE_no_vulkan" ]
1231     public_configs = [ ":angle_frame_capture_disabled" ]
1232
1233     # gl_enum_utils defaults included in with_capture build
1234     deps = [ ":angle_frame_capture_mock" ]
1235     if (angle_enable_trace || is_debug) {
1236       deps += [ ":angle_gl_enum_utils" ]
1237     }
1238   }
1239
1240   if (angle_has_frame_capture) {
1241     angle_source_set("${target_name}_with_capture") {
1242       public_deps = invoker.public_deps + [
1243                       ":angle_gl_enum_utils",
1244                       ":libANGLE_no_vulkan",
1245                     ]
1246       deps = [
1247         ":angle_capture_common",
1248         ":angle_compression",
1249       ]
1250       public_configs = [ ":angle_frame_capture_enabled" ]
1251       sources = libangle_capture_sources
1252
1253       if (angle_has_rapidjson) {
1254         public_deps += [ ":angle_json_serializer" ]
1255         sources += [ "src/libANGLE/capture/serialize.cpp" ]
1256       } else {
1257         sources += [ "src/libANGLE/capture/serialize_mock.cpp" ]
1258       }
1259     }
1260   }
1261 }
1262
1263 libANGLE_template("libANGLE") {
1264   public_deps = []
1265   if (angle_enable_vulkan) {
1266     public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ]
1267   }
1268 }
1269
1270 if (angle_enable_vulkan) {
1271   libANGLE_template("libANGLE_vulkan_secondaries") {
1272     public_deps =
1273         [ "src/libANGLE/renderer/vulkan:angle_vulkan_secondaries_backend" ]
1274   }
1275 }
1276
1277 config("shared_library_public_config") {
1278   if (is_mac && !is_component_build) {
1279     # Executable targets that depend on the shared libraries below need to have
1280     # the rpath setup in non-component build configurations.
1281     ldflags = [
1282       "-rpath",
1283       "@executable_path/",
1284     ]
1285     if (build_with_chromium) {
1286       ldflags += [
1287         # Path for loading shared libraries for unbundled binaries.
1288         # From //build/config/mac/BUILD.gn, this is only added for
1289         # component builds. However, since ANGLE always dynamically
1290         # links to libvulkan, it should be re-added for non-component
1291         # builds. (anglebug.com/4455)
1292         "-Wl,-rpath,@loader_path/.",
1293       ]
1294     }
1295   }
1296
1297   if (angle_is_winuwp) {
1298     ldflags = [
1299       "/APPCONTAINER",
1300
1301       # Disable warning about invalid subsystem number.
1302       # A default appropriate subsystem is selected automatically.
1303       "/IGNORE:4010",
1304     ]
1305   }
1306 }
1307
1308 if (is_android && is_component_build) {
1309   _cr_suffix = ".cr"
1310 } else {
1311   _cr_suffix = ""
1312 }
1313
1314 if (angle_expose_wgl_entry_points) {
1315   _angle_glesv2_library_name = "opengl32${angle_libs_suffix}${_cr_suffix}"
1316 } else {
1317   _angle_glesv2_library_name = "libGLESv2${angle_libs_suffix}${_cr_suffix}"
1318 }
1319 _angle_glesv2_vulkan_secondaries_library_name =
1320     "libGLESv2_vulkan_secondaries${angle_libs_suffix}${_cr_suffix}"
1321
1322 config("library_name_config") {
1323   _egllib = "libEGL${angle_libs_suffix}${_cr_suffix}"
1324   _vk2egllib = "libEGL_vulkan_secondaries${angle_libs_suffix}${_cr_suffix}"
1325   defines = [
1326     "ANGLE_EGL_LIBRARY_NAME=\"${_egllib}\"",
1327     "ANGLE_GLESV2_LIBRARY_NAME=\"${_angle_glesv2_library_name}\"",
1328     "ANGLE_MESA_EGL_LIBRARY_NAME=\"mesa/src/egl/libEGL\"",
1329     "ANGLE_MESA_GLESV2_LIBRARY_NAME=\"mesa/src/mapi/es2api/libGLESv2\"",
1330     "ANGLE_VULKAN_SECONDARIES_EGL_LIBRARY_NAME=\"${_vk2egllib}\"",
1331     "ANGLE_VULKAN_SECONDARIES_GLESV2_LIBRARY_NAME=\"${_angle_glesv2_vulkan_secondaries_library_name}\"",
1332   ]
1333 }
1334
1335 # This config controls export definitions on ANGLE API calls.
1336 config("angle_static_config") {
1337   defines = [
1338     "ANGLE_EXPORT=",
1339     "ANGLE_STATIC=1",
1340     "ANGLE_UTIL_EXPORT=",
1341     "EGLAPI=",
1342     "GL_APICALL=",
1343     "GL_API=",
1344   ]
1345 }
1346
1347 set_defaults("angle_libGLESv2") {
1348   sources = []
1349   output_name = "libGLESv2"
1350 }
1351
1352 template("angle_libGLESv2") {
1353   angle_shared_library(target_name) {
1354     sources = invoker.sources + libglesv2_sources
1355     deps = invoker.deps + [ ":includes" ]
1356     defines = [ "LIBGLESV2_IMPLEMENTATION" ]
1357
1358     output_name = "${invoker.output_name}${angle_libs_suffix}"
1359     if (angle_glesv2_extension != "") {
1360       output_extension = angle_glesv2_extension
1361     }
1362
1363     configs += [
1364       ":angle_gl_visibility_config",
1365       ":debug_annotations_config",
1366       ":gl_prototypes",
1367     ]
1368
1369     if (angle_enable_gl_desktop_frontend) {
1370       sources += libglesv2_gl_sources
1371       defines += [ "ANGLE_ENABLE_GL_DESKTOP_FRONTEND" ]
1372       if (angle_expose_wgl_entry_points) {
1373         sources += [
1374           "src/libGLESv2/entry_points_wgl.cpp",
1375           "src/libGLESv2/entry_points_wgl.h",
1376           "src/libGLESv2/proc_table_wgl.h",
1377           "src/libGLESv2/proc_table_wgl_autogen.cpp",
1378         ]
1379         defines += [ "ANGLE_EXPOSE_WGL_ENTRY_POINTS" ]
1380       } else if (angle_expose_glx_entry_points) {
1381         sources += [
1382           "src/libGLESv2/entry_points_glx.cpp",
1383           "src/libGLESv2/entry_points_glx.h",
1384           "src/libGLESv2/proc_table_glx.h",
1385           "src/libGLESv2/proc_table_glx_autogen.cpp",
1386         ]
1387       } else {
1388         #TODO(http://anglebug.com/7533): Add CGL entry points for mac support
1389       }
1390     }
1391
1392     if (angle_enable_cl) {
1393       sources += libglesv2_cl_sources
1394     }
1395
1396     if (is_win) {
1397       if (angle_expose_wgl_entry_points) {
1398         sources += [ "src/libGLESv2/opengl32_with_wgl_autogen.def" ]
1399       } else {
1400         sources += [ "src/libGLESv2/${invoker.output_name}_autogen.def" ]
1401       }
1402       sources += [ "src/libGLESv2/libGLESv2.rc" ]
1403       deps += [ ":angle_version" ]
1404     }
1405   }
1406 }
1407
1408 angle_libGLESv2("libGLESv2") {
1409   if (angle_with_capture_by_default) {
1410     deps = [ ":libANGLE_with_capture" ]
1411   } else {
1412     deps = [ ":libANGLE" ]
1413   }
1414 }
1415
1416 if (angle_enable_vulkan) {
1417   angle_libGLESv2("libGLESv2_vulkan_secondaries") {
1418     output_name = "libGLESv2_vulkan_secondaries"
1419     if (angle_with_capture_by_default) {
1420       deps = [ ":libANGLE_vulkan_secondaries_with_capture" ]
1421     } else {
1422       deps = [ ":libANGLE_vulkan_secondaries" ]
1423     }
1424   }
1425 }
1426
1427 # Output capture lib when `angle_with_capture_by_default` disabled, vice versa.
1428 if (angle_has_frame_capture) {
1429   angle_libGLESv2("libGLESv2_capture_complement") {
1430     if (angle_with_capture_by_default) {
1431       deps = [ ":libANGLE" ]
1432       output_name += "_no_capture"
1433     } else {
1434       deps = [ ":libANGLE_with_capture" ]
1435       output_name += "_with_capture"
1436     }
1437   }
1438 }
1439
1440 if (angle_enable_gl_desktop_frontend) {
1441   angle_libGLESv2("libGL") {
1442     if (is_win) {
1443       output_name = "opengl32"
1444     } else {
1445       output_name = "libGL"
1446     }
1447
1448     deps = [ ":libANGLE" ]
1449   }
1450 }
1451
1452 angle_static_library("libGLESv2_static") {
1453   sources = libglesv2_sources
1454   if (angle_enable_gl_desktop_frontend) {
1455     sources += libglesv2_gl_sources
1456     defines = [ "ANGLE_ENABLE_GL_DESKTOP_FRONTEND" ]
1457     if (angle_expose_wgl_entry_points) {
1458       sources += [
1459         "src/libGLESv2/entry_points_wgl.cpp",
1460         "src/libGLESv2/entry_points_wgl.h",
1461         "src/libGLESv2/proc_table_wgl.h",
1462         "src/libGLESv2/proc_table_wgl_autogen.cpp",
1463       ]
1464       defines += [ "ANGLE_EXPOSE_WGL_ENTRY_POINTS" ]
1465     } else if (angle_expose_glx_entry_points) {
1466       sources += [
1467         "src/libGLESv2/entry_points_glx.cpp",
1468         "src/libGLESv2/entry_points_glx.h",
1469         "src/libGLESv2/proc_table_glx.h",
1470         "src/libGLESv2/proc_table_glx_autogen.cpp",
1471       ]
1472     } else {
1473       #TODO(http://anglebug.com/7533): Add CGL entry points for mac support
1474     }
1475   }
1476   if (angle_enable_cl) {
1477     sources += libglesv2_cl_sources
1478   }
1479   configs += [ ":debug_annotations_config" ]
1480
1481   public_configs += [ ":angle_static_config" ]
1482   deps = [ ":includes" ]
1483   public_deps = [ ":libANGLE" ]
1484 }
1485
1486 angle_shared_library("libGLESv1_CM") {
1487   sources = libglesv1_cm_sources
1488   output_name = "libGLESv1_CM${angle_libs_suffix}"
1489
1490   configs += [
1491     ":angle_gl_visibility_config",
1492     ":debug_annotations_config",
1493     ":gl_prototypes",
1494   ]
1495
1496   defines = []
1497
1498   deps = [
1499     ":includes",
1500     ":libGLESv2",
1501   ]
1502
1503   if (is_win) {
1504     sources += [ "src/libGLESv1_CM/libGLESv1_CM.def" ]
1505     deps += [ ":angle_version" ]
1506   }
1507 }
1508
1509 config("libEGL_egl_loader_config") {
1510   defines = [ "ANGLE_USE_EGL_LOADER" ]
1511 }
1512
1513 angle_source_set("libEGL_egl_loader") {
1514   sources = [
1515     "src/libEGL/egl_loader_autogen.cpp",
1516     "src/libEGL/egl_loader_autogen.h",
1517   ]
1518
1519   public_configs += [
1520     ":libEGL_egl_loader_config",
1521     ":gl_prototypes",
1522   ]
1523
1524   deps = [ ":includes" ]
1525 }
1526
1527 set_defaults("libEGL_template") {
1528   sources = []
1529   deps = []
1530   public_configs = []
1531 }
1532
1533 template("libEGL_template") {
1534   target(invoker.target_type, target_name) {
1535     forward_variables_from(invoker, "*")
1536     sources += libegl_sources
1537     configs += [
1538       ":debug_annotations_config",
1539       ":library_name_config",
1540     ]
1541     deps += [ ":includes" ]
1542   }
1543 }
1544
1545 template("libEGL_shared_template") {
1546   libEGL_template(target_name) {
1547     target_type = "angle_shared_library"
1548     output_name = "${invoker.output_name}${angle_libs_suffix}"
1549     if (angle_egl_extension != "") {
1550       output_extension = angle_egl_extension
1551     }
1552
1553     defines = invoker.defines + [ "LIBEGL_IMPLEMENTATION" ]
1554     if (is_win) {
1555       defines += [ "EGLAPI=" ]
1556     } else {
1557       defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
1558     }
1559
1560     deps = [
1561       ":angle_common",
1562       ":libEGL_egl_loader",
1563     ]
1564
1565     sources += invoker.sources
1566
1567     if (is_win) {
1568       sources += [ "src/libEGL/libEGL.rc" ]
1569       deps += [ ":angle_version" ]
1570     }
1571
1572     data_deps = [ ":${invoker.gles_library}" ]
1573   }
1574 }
1575
1576 libEGL_shared_template("libEGL") {
1577   defines = [ "ANGLE_DISPATCH_LIBRARY=\"${_angle_glesv2_library_name}\"" ]
1578   output_name = "libEGL"
1579   gles_library = "libGLESv2"
1580   sources = []
1581   if (is_win) {
1582     sources += [ "src/libEGL/libEGL_autogen.def" ]
1583   }
1584 }
1585
1586 if (angle_enable_vulkan) {
1587   libEGL_shared_template("libEGL_vulkan_secondaries") {
1588     defines = [ "ANGLE_DISPATCH_LIBRARY=\"${_angle_glesv2_vulkan_secondaries_library_name}\"" ]
1589     output_name = "libEGL_vulkan_secondaries"
1590     gles_library = "libGLESv2_vulkan_secondaries"
1591     sources = []
1592     if (is_win) {
1593       sources += [ "src/libEGL/libEGL_vulkan_secondaries_autogen.def" ]
1594     }
1595   }
1596 }
1597
1598 libEGL_template("libEGL_static") {
1599   target_type = "angle_static_library"
1600   public_configs = [ ":angle_static_config" ]
1601   deps = [ ":libGLESv2_static" ]
1602 }
1603
1604 # Convenience targets for some of the samples so they can be built
1605 # with Chromium's toolchain.
1606 angle_executable("angle_shader_translator") {
1607   testonly = true
1608
1609   sources = [ "samples/shader_translator/shader_translator.cpp" ]
1610
1611   deps = [ ":translator" ]
1612
1613   defines = []
1614
1615   if (angle_enable_vulkan) {
1616     deps += [
1617       "${angle_spirv_tools_dir}:spvtools_headers",
1618       "${angle_spirv_tools_dir}:spvtools_val",
1619     ]
1620
1621     defines += [ "ANGLE_ENABLE_VULKAN" ]
1622   }
1623 }
1624
1625 if (angle_standalone || build_with_chromium) {
1626   config("angle_feature_support_config") {
1627     include_dirs = [
1628       "include",
1629       "src",
1630     ]
1631     defines = [ "LIBFEATURE_SUPPORT_IMPLEMENTATION" ]
1632     if (is_debug) {
1633       defines += [ "ANGLE_FEATURE_UTIL_LOG_VERBOSE" ]
1634     }
1635   }
1636
1637   angle_shared_library("libfeature_support") {
1638     output_name = "libfeature_support${angle_libs_suffix}"
1639
1640     if (is_android) {
1641       libs = [ "log" ]
1642     }
1643
1644     configs += [
1645       ":angle_feature_support_config",
1646       "${angle_jsoncpp_dir}:jsoncpp_config",
1647     ]
1648
1649     if (is_apple && !is_component_build) {
1650       ldflags = [
1651         "-install_name",
1652         "@rpath/${target_name}.dylib",
1653       ]
1654     }
1655
1656     sources = [
1657       "src/feature_support_util/feature_support_util.cpp",
1658       "src/feature_support_util/feature_support_util.h",
1659     ]
1660
1661     deps = [
1662       ":angle_gpu_info_util",
1663       "${angle_jsoncpp_dir}:jsoncpp",
1664     ]
1665   }
1666 }
1667
1668 if (angle_enable_cgl) {
1669   config("supports_automatic_graphics_switching") {
1670     # For discussion about config, inputs, etc, see:
1671     # https://bugs.chromium.org/p/chromium/issues/detail?id=781858
1672     _plist_file = "util/osx/supports_automatic_graphics_switching.plist"
1673     inputs = [ _plist_file ]
1674     ldflags = [
1675       "-sectcreate",
1676       "__TEXT",
1677       "__info_plist",
1678       rebase_path(_plist_file, root_build_dir),
1679     ]
1680   }
1681 }
1682
1683 if (is_android && symbol_level != 0) {
1684   action_foreach("compressed_symbols") {
1685     sources = []
1686     foreach(_library, angle_libraries) {
1687       if (is_component_build) {
1688         sources += [ "$root_out_dir/${_library}${angle_libs_suffix}.cr.so" ]
1689       } else {
1690         sources += [ "$root_out_dir/${_library}${angle_libs_suffix}.so" ]
1691       }
1692     }
1693     if (angle_enable_vulkan_validation_layers) {
1694       foreach(_layer, vulkan_validation_layers) {
1695         if (is_component_build) {
1696           sources += [ "$root_out_dir/lib${_layer}.cr.so" ]
1697         } else {
1698           sources += [ "$root_out_dir/lib${_layer}.so" ]
1699         }
1700       }
1701     }
1702
1703     script = rebase_path("${root_build_dir}/android/compress_symbols.py",
1704                          root_build_dir)
1705
1706     deps = []
1707     foreach(_library, angle_libraries) {
1708       deps += [ ":$_library" ]
1709     }
1710
1711     if (angle_enable_vulkan_validation_layers) {
1712       foreach(_layer, vulkan_validation_layers) {
1713         deps += [ "$angle_vulkan_validation_layers_dir:${_layer}" ]
1714       }
1715     }
1716
1717     outputs = [ "$root_out_dir/lib.compressed/{{source_file_part}}" ]
1718
1719     android_nm = "${android_tool_prefix}nm"
1720     android_strip = "${android_tool_prefix}strip"
1721
1722     args = [
1723       "--objcopy",
1724       rebase_path(android_objcopy, root_build_dir),
1725       "--nm",
1726       rebase_path(android_nm, root_build_dir),
1727       "--strip",
1728       rebase_path(android_strip, root_build_dir),
1729       "--unstrippedsofile",
1730       "{{source_dir}}/lib.unstripped/{{source_file_part}}",
1731       "--output",
1732       "{{source_dir}}/lib.compressed/{{source_file_part}}",
1733     ]
1734   }
1735 }
1736
1737 if ((angle_standalone || build_with_chromium) && is_android &&
1738     current_toolchain == default_toolchain) {
1739   apk_version_code = "0"
1740   if (angle_enable_commit_id) {
1741     apk_version_code =
1742         exec_script("src/commit_id.py", [ "position" ], "trim string")
1743   }
1744
1745   # Package ANGLE libraries for normal use on Android
1746   angle_apk("angle_chromium_apk") {
1747     package_name = "org.chromium.angle"
1748     apk_name = "AngleLibraries"
1749     version_name = "ANGLE Developer Build"
1750     version_code = apk_version_code
1751   }
1752
1753   # Package ANGLE libraries for AGI use on Android
1754   angle_apk("angle_agi_chromium_apk") {
1755     package_name = "org.chromium.angle.agi"
1756     apk_name = "AngleAgiLibraries"
1757     version_name = "ANGLE AGI Build"
1758     version_code = apk_version_code
1759   }
1760
1761   group("angle_apks") {
1762     deps = [
1763       ":angle_agi_chromium_apk",
1764       ":angle_chromium_apk",
1765     ]
1766   }
1767 }
1768
1769 group("angle") {
1770   data_deps = [
1771     ":libEGL",
1772     ":libGLESv1_CM",
1773     ":libGLESv2",
1774   ]
1775   if (angle_enable_vulkan) {
1776     data_deps += [
1777       ":libEGL_vulkan_secondaries",
1778       ":libGLESv2_vulkan_secondaries",
1779     ]
1780   }
1781   if (is_ios) {
1782     # Need to bundle the libraries inside the .app.
1783     deps = data_deps
1784   }
1785 }
1786
1787 group("angle_static") {
1788   public_deps = [
1789     ":libEGL_static",
1790     ":libGLESv2_static",
1791     ":preprocessor",
1792     ":translator",
1793   ]
1794 }