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