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.
5 # import the ozone_platform_x11 variable
6 import("gni/angle.gni")
7 if (angle_enable_vulkan) {
8 import("//build_overrides//vulkan_headers.gni")
10 if (angle_use_wayland) {
11 import("//build_overrides/wayland.gni")
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")
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")
26 using_sanitizer = false
30 # Use the PCI lib to collect GPU information on Linux.
31 use_libpci = (is_linux || is_chromeos) && (angle_use_x11 || use_ozone) &&
34 # Enable using Vulkan to collect system info as a fallback.
35 angle_enable_vulkan_system_info = false
37 # Link in system libGL, to work with apitrace. See doc/DebuggingTips.md.
38 angle_link_glx = false
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
47 # Enable generating current commit information using git
48 angle_enable_commit_id = true
50 # Abseil has trouble supporting MSVC, particularly regarding component builds.
51 # http://crbug.com/1126524
52 angle_enable_abseil = angle_has_build && is_clang
54 # Adds run-time checks to filter out EVENT() messages when the debug annotator is disabled.
55 angle_enable_annotator_run_time_checks = false
57 # Enables non-conformant extensions and features
58 angle_expose_non_conformant_extensions_and_versions = false
60 # Optional feature that forces dirty state whenever we use a new context regardless of thread.
61 angle_force_context_check_every_call = false
63 # Allow shared library custom name extensions for setting soname such as libEGL.so.1
64 angle_egl_extension = ""
65 angle_glesv2_extension = ""
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
74 # Use Android TLS slot to store current context.
75 angle_use_android_tls_slot = !build_with_chromium
78 angle_enable_global_mutex_recursion = is_android && angle_enable_vulkan
81 if (angle_build_all) {
86 ":angle_shader_translator",
89 "$angle_root/samples:angle_samples",
90 "$angle_root/src/tests:angle_tests",
92 if (angle_enable_cl) {
93 deps += [ "$angle_root/src/libOpenCL:angle_cl" ]
95 if (angle_build_mesa) {
96 deps += [ "$angle_root/third_party/mesa" ]
101 import("src/angle_program_serialize_data_version.gni")
102 import("src/compiler.gni")
103 import("src/libGLESv2.gni")
105 # This config is exported to dependent targets (and also applied to internal
107 config("external_config") {
108 include_dirs = [ "include" ]
111 # Prevent the GL headers from redeclaring ANGLE entry points.
112 config("no_gl_prototypes") {
114 "GL_GLES_PROTOTYPES=0",
115 "EGL_EGL_PROTOTYPES=0",
119 config("gl_prototypes") {
121 "GL_GLES_PROTOTYPES=1",
122 "EGL_EGL_PROTOTYPES=1",
123 "GL_GLEXT_PROTOTYPES",
124 "EGL_EGLEXT_PROTOTYPES",
128 # This config is applied to internal Angle targets (not pushed to dependents).
129 config("internal_config") {
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
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
145 defines = [ angle_vma_version_define ]
148 defines += [ "ANGLE_IS_WIN" ]
149 if (angle_is_winuwp) {
150 defines += [ "ANGLE_IS_WINUWP" ]
152 } else if (is_linux || is_chromeos) {
153 defines += [ "ANGLE_IS_LINUX" ]
156 if (angle_enable_share_context_lock) {
157 defines += [ "ANGLE_ENABLE_SHARE_CONTEXT_LOCK=1" ]
161 if (angle_use_android_tls_slot) {
162 defines += [ "ANGLE_USE_ANDROID_TLS_SLOT=1" ]
166 if (angle_enable_global_mutex_recursion) {
167 defines += [ "ANGLE_ENABLE_GLOBAL_MUTEX_RECURSION=1" ]
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" ]
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" ]
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" ]
188 # Checks that unwind backtrace support for Android is enabled only for debug mode.
189 assert(is_debug || !angle_enable_unwind_backtrace_support)
192 defines += [ "ANGLE_PLATFORM_CHROMEOS" ]
196 defines += [ "__ggp__" ]
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" ]
207 # These two are needed here to correctly select OSWindow::New
209 defines += [ "ANGLE_USE_X11" ]
211 if (angle_use_wayland) {
212 defines += [ "ANGLE_USE_WAYLAND" ]
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" ]
223 defines += [ "ANGLE_WITH_LSAN" ]
226 if (angle_has_astc_encoder) {
227 defines += [ "ANGLE_HAS_ASTCENC" ]
230 if (angle_test_enable_system_egl) {
231 defines += [ "ANGLE_TEST_ENABLE_SYSTEM_EGL" ]
234 if (angle_debug_layers_enabled) {
235 defines += [ "ANGLE_DEBUG_LAYERS_ENABLED" ]
238 if (angle_build_mesa) {
239 defines += [ "ANGLE_HAS_MESA" ]
242 if (angle_standalone || build_with_chromium) {
243 defines += [ "ANGLE_OUTSIDE_WEBKIT" ]
247 config("constructor_and_destructor_warnings") {
250 "-Wexit-time-destructors",
251 "-Wglobal-constructors",
256 config("extra_warnings") {
259 is_gcc = !is_clang && !is_win
261 # Avoid failing builds for warnings enabled by Skia build.
262 if (defined(is_skia_standalone)) {
266 # Enable more default warnings on Windows.
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.
280 "-Wbad-function-cast",
281 "-Wconditional-uninitialized",
283 "-Wfloat-conversion",
284 "-Winconsistent-missing-destructor-override",
285 "-Wmissing-field-initializers",
287 "-Wnon-virtual-dtor",
288 "-Wredundant-parens",
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",
299 # The below warnings are used by WebKit. We enable them to make rolling
300 # ANGLE in WebKit easier.
302 "-Wrange-loop-analysis",
303 "-Wstrict-prototypes",
304 "-Wunreachable-code-aggressive",
305 "-Wshorten-64-to-32",
310 cflags_cc = [ "-Wdeprecated-copy" ]
313 if (angle_is_winuwp) {
315 "/wd4091", # keyword ignored on left of type when no variable is declared
316 "/wd4447", # 'main' signature found without threading model.
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" ]
330 _use_copy_compiler_dll = angle_has_build && is_win
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}}" ]
339 # Holds the shared includes so we only need to list them once.
340 config("includes_config") {
341 include_dirs = [ "include" ]
344 config("angle_uwp_env") {
345 if (angle_is_winuwp) {
346 defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ]
350 angle_source_set("cl_includes") {
351 sources = cl_includes
352 public_configs = [ ":external_config" ]
355 angle_source_set("includes") {
356 sources = libangle_includes
357 public_configs = [ ":includes_config" ]
358 if (angle_enable_cl) {
359 public_deps = [ ":cl_includes" ]
363 config("disable_unreachable_code_break_warning") {
365 cflags = [ "-Wno-unreachable-code-break" ]
369 angle_static_library("preprocessor") {
370 sources = angle_preprocessor_sources
372 # preprocessor_tab_autogen.cpp contains an instance of this.
373 configs += [ ":disable_unreachable_code_break_warning" ]
377 ":angle_translator_headers",
381 config("angle_disable_pool_alloc") {
382 defines = [ "ANGLE_DISABLE_POOL_ALLOC" ]
385 config("debug_annotations_config") {
388 defines += [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
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" ]
397 config("angle_asserts_config") {
398 if (angle_assert_always_on) {
399 defines = [ "ANGLE_ASSERT_ALWAYS_ON" ]
403 config("angle_common_config") {
406 "src/common/third_party/xxhash",
413 if (angle_delegate_workers) {
414 defines += [ "ANGLE_DELEGATE_WORKERS" ]
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" ]
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" ]
432 angle_source_set("xxhash") {
433 sources = xxhash_sources
435 cflags_c = [ "-Wno-implicit-fallthrough" ]
439 if (angle_has_build) {
440 fuzzer_test("xxhash_fuzzer") {
441 sources = [ "src/common/third_party/xxhash/xxhash_fuzzer.cpp" ]
446 template("angle_common_lib") {
447 angle_static_library(target_name) {
448 sources = invoker.sources
451 ":angle_common_config",
452 ":debug_annotations_config",
461 public_configs += [ ":angle_common_config" ]
462 if (angle_has_build && use_fuzzing_engine) {
463 all_dependent_configs = [ ":angle_disable_pool_alloc" ]
466 if (is_linux || is_chromeos) {
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" ]
480 if (angle_expose_non_conformant_extensions_and_versions) {
481 defines = [ "ANGLE_EXPOSE_NON_CONFORMANT_EXTENSIONS_AND_VERSIONS" ]
484 if (using_sanitizer && !build_with_chromium) {
486 [ "//build/config/clang:llvm-symbolizer_data($host_toolchain)" ]
490 frameworks = [ "Metal.framework" ]
495 angle_common_lib("angle_common") {
496 sources = libangle_common_sources
497 if (angle_enable_cl) {
498 sources += libangle_common_cl_sources
502 angle_common_lib("angle_common_shader_state") {
503 sources = libangle_common_shader_state_sources
506 angle_source_set("angle_capture_common") {
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",
513 deps = [ ":angle_common" ]
514 public_deps = [ ":angle_gl_enum_utils" ]
517 config("angle_image_util_config") {
524 angle_source_set("angle_image_util_headers") {
525 sources = libangle_image_util_headers
526 public_deps = [ ":angle_common" ]
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" ]
534 if (angle_has_astc_encoder) {
535 public_deps += [ "third_party/astc-encoder:astcenc" ]
536 include_dirs = [ "third_party/astc-encoder/src/Source/" ]
540 config("angle_gl_visibility_config") {
548 "GL_APICALL=__attribute__((visibility(\"default\")))",
549 "GL_API=__attribute__((visibility(\"default\")))",
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
561 config("angle_gpu_info_util_config") {
568 angle_static_library("angle_gpu_info_util") {
570 ":angle_gpu_info_util_config",
571 ":angle_backend_config",
573 public_deps = [ ":angle_common" ]
574 sources = libangle_gpu_info_util_sources
579 if (angle_build_vulkan_system_info) {
580 sources += libangle_gpu_info_util_vulkan_sources
582 "$angle_vulkan_headers_dir:vulkan_headers",
583 "src/common/vulkan:angle_libvulkan_loader",
584 "src/common/vulkan:angle_vulkan_icd",
586 configs += [ "$angle_root:angle_no_cfi_icall" ]
587 if (angle_enable_vulkan_system_info) {
588 defines += [ "ANGLE_USE_VULKAN_SYSTEM_INFO" ]
593 sources += libangle_gpu_info_util_android_sources
597 sources += libangle_gpu_info_util_fuchsia_sources
598 deps += [ "$angle_root/src/common/vulkan:angle_vulkan_entry_points" ]
602 sources += libangle_gpu_info_util_win_sources
603 if (!angle_is_winuwp) {
604 libs += [ "setupapi.lib" ]
606 libs += [ "dxgi.lib" ]
609 if (is_linux || is_chromeos || is_tizen) {
610 sources += libangle_gpu_info_util_linux_sources
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" ]
623 if (angle_use_wayland && angle_has_build) {
624 public_deps += [ ":angle_wayland" ]
629 sources += libangle_gpu_info_util_libpci_sources
630 defines += [ "GPU_INFO_USE_LIBPCI" ]
637 "CoreFoundation.framework",
638 "CoreGraphics.framework",
640 if (angle_enable_eagl) {
641 frameworks += [ "OpenGLES.framework" ]
642 } else if (angle_enable_cgl) {
643 frameworks += [ "OpenGL.framework" ]
645 if (is_mac || angle_enable_cgl) {
646 sources += libangle_gpu_info_util_mac_sources
648 if (is_ios && !angle_enable_cgl) {
649 sources += libangle_gpu_info_util_ios_sources
654 angle_source_set("angle_translator_headers") {
655 sources = angle_translator_exported_headers
656 public_deps = [ ":includes" ]
659 template("translator_lib") {
660 angle_static_library(target_name) {
661 sources = angle_translator_sources
664 _needs_glsl_base = false
665 _needs_glsl_and_vulkan_base = false
669 if (angle_enable_desktop_glsl) {
670 sources += angle_translator_glsl_symbol_table_sources
672 sources += angle_translator_essl_symbol_table_sources
676 if (angle_enable_essl || use_fuzzing_engine) {
677 _needs_glsl_base = true
678 sources += angle_translator_essl_sources
679 defines += [ "ANGLE_ENABLE_ESSL" ]
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" ]
689 sources += angle_translator_glsl_apple_sources
693 if (angle_enable_hlsl || use_fuzzing_engine) {
694 sources += angle_translator_hlsl_sources
695 defines += [ "ANGLE_ENABLE_HLSL" ]
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
705 # This translator is needed by metal backend also.
706 sources += angle_translator_lib_vulkan_sources
709 if (angle_enable_vulkan || use_fuzzing_engine) {
710 defines += [ "ANGLE_ENABLE_VULKAN" ]
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" ]
722 if (_needs_glsl_base) {
723 sources += angle_translator_glsl_base_sources
725 if (_needs_glsl_and_vulkan_base) {
726 sources += angle_translator_glsl_and_vulkan_base_sources
729 public_configs += [ ":external_config" ]
732 ":angle_common_shader_state",
735 "$angle_root/src/common/spirv:angle_spirv_headers",
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",
750 ":angle_translator_headers",
751 ":angle_version_info",
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" ]
762 translator_lib("translator") {
766 if (angle_enable_essl || angle_enable_glsl || angle_enable_hlsl) {
767 translator_lib("translator_gl_d3d_only") {
772 angle_source_set("translator_fuzzer") {
773 sources = [ "src/compiler/fuzz/translator_fuzzer.cpp" ]
780 deps = [ ":translator" ]
783 config("angle_program_version_id_config") {
784 include_dirs = [ "$root_gen_dir/angle" ]
785 visibility = [ ":angle_program_version_id" ]
788 action("angle_program_version_id") {
789 response_file_contents =
790 rebase_path(angle_code_affecting_program_serialize, root_build_dir)
792 _program_version_header = "$root_gen_dir/angle/ANGLEShaderProgramVersion.h"
793 script = "src/program_serialize_data_version.py"
794 outputs = [ _program_version_header ]
796 visibility = [ ":angle_version" ]
798 inputs = angle_code_affecting_program_serialize
801 rebase_path(_program_version_header, root_build_dir),
802 "{{response_file_name}}",
805 public_configs = [ ":angle_program_version_id_config" ]
808 config("angle_commit_id_config") {
809 include_dirs = [ "$root_gen_dir/angle" ]
810 visibility = [ ":angle_commit_id" ]
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 ]
818 visibility = [ ":angle_version" ]
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]
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",
839 inputs += [ git_dirs[1] + "/" + _ref_file ]
845 rebase_path(_commit_id_header, root_build_dir),
848 public_configs = [ ":angle_commit_id_config" ]
851 angle_source_set("angle_version") {
852 sources = [ "src/common/angle_version.h" ]
855 ":angle_program_version_id",
857 visibility = [ ":angle_version_info" ]
859 # The version headers are used directly in Windows .RC files.
866 ":libGLESv2_capture_complement",
868 if (angle_enable_vulkan) {
870 ":libEGL_vulkan_secondaries",
871 ":libGLESv2_vulkan_secondaries",
877 angle_source_set("angle_version_info") {
879 "src/common/angle_version_info.cpp",
880 "src/common/angle_version_info.h",
883 ":angle_translator_headers",
888 config("angle_backend_config") {
891 if (angle_force_context_check_every_call) {
892 defines += [ "ANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL=1" ]
895 if (angle_expose_non_conformant_extensions_and_versions) {
896 defines += [ "ANGLE_EXPOSE_NON_CONFORMANT_EXTENSIONS_AND_VERSIONS" ]
901 if (angle_enable_d3d11) {
902 configs += [ "src/libANGLE/renderer/d3d:angle_d3d11_backend_config" ]
905 if (angle_enable_d3d9) {
906 configs += [ "src/libANGLE/renderer/d3d:angle_d3d9_backend_config" ]
909 if (angle_enable_gl) {
910 configs += [ "src/libANGLE/renderer/gl:angle_gl_backend_config" ]
913 if (angle_enable_null) {
914 configs += [ "src/libANGLE/renderer/null:angle_null_backend_config" ]
917 if (angle_enable_metal) {
918 configs += [ "src/libANGLE/renderer/metal:angle_metal_backend_config" ]
921 if (angle_enable_vulkan) {
922 configs += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ]
925 if (angle_enable_cl_passthrough) {
926 configs += [ "src/libANGLE/renderer/cl:angle_cl_backend_config" ]
929 if (angle_is_winuwp) {
930 configs += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp_config" ]
934 config("libANGLE_config") {
939 defines += [ "LIBANGLE_IMPLEMENTATION" ]
942 cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics
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" ]
952 libs += [ "android" ]
957 defines += [ "ANGLE_USE_X11" ]
960 if (angle_use_wayland) {
961 defines += [ "ANGLE_USE_WAYLAND" ]
964 if (angle_enable_overlay) {
965 defines += [ "ANGLE_ENABLE_OVERLAY=1" ]
967 if (angle_enable_perf_counter_output) {
968 defines += [ "ANGLE_ENABLE_PERF_COUNTER_OUTPUT=1" ]
972 angle_source_set("libANGLE_headers") {
973 sources = libangle_headers
974 if (angle_enable_cl) {
975 sources += libangle_cl_headers
979 ":angle_translator_headers",
981 public_configs += [ ":libANGLE_config" ]
984 if ((is_win && angle_enable_gl) || angle_enable_d3d11 || angle_enable_d3d9) {
985 angle_source_set("angle_d3d_format_tables") {
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",
993 if (!angle_is_winuwp) {
995 "src/libANGLE/renderer/d3d_format.cpp",
996 "src/libANGLE/renderer/d3d_format.h",
1000 public_deps = [ ":libANGLE_headers" ]
1001 configs += [ ":angle_backend_config" ]
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
1012 if (angle_enable_gl_desktop_frontend) {
1013 defines += [ "ANGLE_ENABLE_GL_DESKTOP_FRONTEND" ]
1018 if (angle_link_glx) {
1020 defines += [ "ANGLE_LINK_GLX" ]
1024 ":angle_common_shader_state",
1025 ":angle_gpu_info_util",
1026 ":angle_image_util",
1027 ":angle_version_info",
1028 ":libANGLE_headers",
1032 ":angle_compression",
1036 if (is_win && !angle_is_winuwp) {
1043 if (angle_enable_d3d11) {
1044 public_deps += [ "src/libANGLE/renderer/d3d:angle_d3d11_backend" ]
1047 if (angle_enable_d3d9) {
1048 public_deps += [ "src/libANGLE/renderer/d3d:angle_d3d9_backend" ]
1051 if (angle_enable_gl) {
1052 public_deps += [ "src/libANGLE/renderer/gl:angle_gl_backend" ]
1055 if (angle_enable_null) {
1056 public_deps += [ "src/libANGLE/renderer/null:angle_null_backend" ]
1059 if (angle_is_winuwp) {
1060 public_deps += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp" ]
1063 if (angle_enable_d3d11) {
1064 libs += [ "dxguid.lib" ]
1067 if (angle_enable_metal) {
1068 public_deps += [ "src/libANGLE/renderer/metal:angle_metal_backend" ]
1071 if (angle_enable_cl_passthrough) {
1072 public_deps += [ "src/libANGLE/renderer/cl:angle_cl_backend" ]
1075 # Enable extra Chromium style warnings for libANGLE.
1076 if (is_clang && angle_has_build) {
1077 suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ]
1081 sources += libangle_mac_sources
1085 sources += [ "src/libANGLE/renderer/driver_utils_ios.mm" ]
1089 defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
1092 configs += [ ":debug_annotations_config" ]
1095 ":angle_backend_config",
1098 if (_use_copy_compiler_dll) {
1099 data_deps = [ ":copy_compiler_dll" ]
1103 config("angle_frame_capture_disabled") {
1104 defines = [ "ANGLE_CAPTURE_ENABLED=0" ]
1107 angle_source_set("angle_frame_capture_mock") {
1108 public_deps = [ ":libANGLE_headers" ]
1109 public_configs = [ ":angle_frame_capture_disabled" ]
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",
1121 angle_source_set("angle_gl_enum_utils") {
1122 deps = [ ":angle_common" ]
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",
1131 if (angle_use_wayland) {
1132 config("angle_wayland_config") {
1133 if ("$wayland_gn_dir" == "") {
1146 group("angle_wayland") {
1147 public_configs = [ ":angle_wayland_config" ]
1149 if ("$wayland_gn_dir" != "") {
1150 # Use third-party targets
1152 "$wayland_gn_dir:wayland_client",
1153 "$wayland_gn_dir:wayland_egl",
1159 if (!defined(angle_abseil_cpp_dir)) {
1160 angle_abseil_cpp_dir = "//third_party/abseil-cpp"
1163 config("angle_abseil_config") {
1164 if (angle_enable_abseil) {
1165 defines = [ "ANGLE_USE_ABSEIL" ]
1168 "$angle_abseil_cpp_dir:absl_define_config",
1169 "$angle_abseil_cpp_dir:absl_include_config",
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" ]
1182 "$angle_abseil_cpp_dir/absl/container:flat_hash_map",
1183 "$angle_abseil_cpp_dir/absl/container:flat_hash_set",
1187 public_configs = [ ":angle_abseil_config" ]
1191 config("angle_compression_config") {
1192 include_dirs = [ "//third_party/zlib/google" ]
1195 group("angle_compression") {
1197 ":angle_compression_config",
1198 "//third_party/zlib:zlib_config",
1201 [ "$angle_zlib_compression_utils_dir:compression_utils_portable" ]
1204 if (angle_has_rapidjson) {
1205 config("angle_rapidjson_config") {
1206 defines = [ "ANGLE_HAS_RAPIDJSON" ]
1208 angle_source_set("angle_json_serializer") {
1211 "$angle_root/third_party/rapidjson",
1214 "src/common/serializer/JsonSerializer.cpp",
1215 "src/common/serializer/JsonSerializer.h",
1217 public_configs = [ ":angle_rapidjson_config" ]
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" ]
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" ]
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" ]
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",
1247 ":angle_capture_common",
1248 ":angle_compression",
1250 public_configs = [ ":angle_frame_capture_enabled" ]
1251 sources = libangle_capture_sources
1253 if (angle_has_rapidjson) {
1254 public_deps += [ ":angle_json_serializer" ]
1255 sources += [ "src/libANGLE/capture/serialize.cpp" ]
1257 sources += [ "src/libANGLE/capture/serialize_mock.cpp" ]
1263 libANGLE_template("libANGLE") {
1265 if (angle_enable_vulkan) {
1266 public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ]
1270 if (angle_enable_vulkan) {
1271 libANGLE_template("libANGLE_vulkan_secondaries") {
1273 [ "src/libANGLE/renderer/vulkan:angle_vulkan_secondaries_backend" ]
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.
1283 "@executable_path/",
1285 if (build_with_chromium) {
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/.",
1297 if (angle_is_winuwp) {
1301 # Disable warning about invalid subsystem number.
1302 # A default appropriate subsystem is selected automatically.
1308 if (is_android && is_component_build) {
1314 if (angle_expose_wgl_entry_points) {
1315 _angle_glesv2_library_name = "opengl32${angle_libs_suffix}${_cr_suffix}"
1317 _angle_glesv2_library_name = "libGLESv2${angle_libs_suffix}${_cr_suffix}"
1319 _angle_glesv2_vulkan_secondaries_library_name =
1320 "libGLESv2_vulkan_secondaries${angle_libs_suffix}${_cr_suffix}"
1322 config("library_name_config") {
1323 _egllib = "libEGL${angle_libs_suffix}${_cr_suffix}"
1324 _vk2egllib = "libEGL_vulkan_secondaries${angle_libs_suffix}${_cr_suffix}"
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}\"",
1335 # This config controls export definitions on ANGLE API calls.
1336 config("angle_static_config") {
1340 "ANGLE_UTIL_EXPORT=",
1347 set_defaults("angle_libGLESv2") {
1349 output_name = "libGLESv2"
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" ]
1358 output_name = "${invoker.output_name}${angle_libs_suffix}"
1359 if (angle_glesv2_extension != "") {
1360 output_extension = angle_glesv2_extension
1364 ":angle_gl_visibility_config",
1365 ":debug_annotations_config",
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) {
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",
1379 defines += [ "ANGLE_EXPOSE_WGL_ENTRY_POINTS" ]
1380 } else if (angle_expose_glx_entry_points) {
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",
1388 #TODO(http://anglebug.com/7533): Add CGL entry points for mac support
1392 if (angle_enable_cl) {
1393 sources += libglesv2_cl_sources
1397 if (angle_expose_wgl_entry_points) {
1398 sources += [ "src/libGLESv2/opengl32_with_wgl_autogen.def" ]
1400 sources += [ "src/libGLESv2/${invoker.output_name}_autogen.def" ]
1402 sources += [ "src/libGLESv2/libGLESv2.rc" ]
1403 deps += [ ":angle_version" ]
1408 angle_libGLESv2("libGLESv2") {
1409 if (angle_with_capture_by_default) {
1410 deps = [ ":libANGLE_with_capture" ]
1412 deps = [ ":libANGLE" ]
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" ]
1422 deps = [ ":libANGLE_vulkan_secondaries" ]
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"
1434 deps = [ ":libANGLE_with_capture" ]
1435 output_name += "_with_capture"
1440 if (angle_enable_gl_desktop_frontend) {
1441 angle_libGLESv2("libGL") {
1443 output_name = "opengl32"
1445 output_name = "libGL"
1448 deps = [ ":libANGLE" ]
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) {
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",
1464 defines += [ "ANGLE_EXPOSE_WGL_ENTRY_POINTS" ]
1465 } else if (angle_expose_glx_entry_points) {
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",
1473 #TODO(http://anglebug.com/7533): Add CGL entry points for mac support
1476 if (angle_enable_cl) {
1477 sources += libglesv2_cl_sources
1479 configs += [ ":debug_annotations_config" ]
1481 public_configs += [ ":angle_static_config" ]
1482 deps = [ ":includes" ]
1483 public_deps = [ ":libANGLE" ]
1486 angle_shared_library("libGLESv1_CM") {
1487 sources = libglesv1_cm_sources
1488 output_name = "libGLESv1_CM${angle_libs_suffix}"
1491 ":angle_gl_visibility_config",
1492 ":debug_annotations_config",
1504 sources += [ "src/libGLESv1_CM/libGLESv1_CM.def" ]
1505 deps += [ ":angle_version" ]
1509 config("libEGL_egl_loader_config") {
1510 defines = [ "ANGLE_USE_EGL_LOADER" ]
1513 angle_source_set("libEGL_egl_loader") {
1515 "src/libEGL/egl_loader_autogen.cpp",
1516 "src/libEGL/egl_loader_autogen.h",
1520 ":libEGL_egl_loader_config",
1524 deps = [ ":includes" ]
1527 set_defaults("libEGL_template") {
1533 template("libEGL_template") {
1534 target(invoker.target_type, target_name) {
1535 forward_variables_from(invoker, "*")
1536 sources += libegl_sources
1538 ":debug_annotations_config",
1539 ":library_name_config",
1541 deps += [ ":includes" ]
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
1553 defines = invoker.defines + [ "LIBEGL_IMPLEMENTATION" ]
1555 defines += [ "EGLAPI=" ]
1557 defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
1562 ":libEGL_egl_loader",
1565 sources += invoker.sources
1568 sources += [ "src/libEGL/libEGL.rc" ]
1569 deps += [ ":angle_version" ]
1572 data_deps = [ ":${invoker.gles_library}" ]
1576 libEGL_shared_template("libEGL") {
1577 defines = [ "ANGLE_DISPATCH_LIBRARY=\"${_angle_glesv2_library_name}\"" ]
1578 output_name = "libEGL"
1579 gles_library = "libGLESv2"
1582 sources += [ "src/libEGL/libEGL_autogen.def" ]
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"
1593 sources += [ "src/libEGL/libEGL_vulkan_secondaries_autogen.def" ]
1598 libEGL_template("libEGL_static") {
1599 target_type = "angle_static_library"
1600 public_configs = [ ":angle_static_config" ]
1601 deps = [ ":libGLESv2_static" ]
1604 # Convenience targets for some of the samples so they can be built
1605 # with Chromium's toolchain.
1606 angle_executable("angle_shader_translator") {
1609 sources = [ "samples/shader_translator/shader_translator.cpp" ]
1611 deps = [ ":translator" ]
1615 if (angle_enable_vulkan) {
1617 "${angle_spirv_tools_dir}:spvtools_headers",
1618 "${angle_spirv_tools_dir}:spvtools_val",
1621 defines += [ "ANGLE_ENABLE_VULKAN" ]
1625 if (angle_standalone || build_with_chromium) {
1626 config("angle_feature_support_config") {
1631 defines = [ "LIBFEATURE_SUPPORT_IMPLEMENTATION" ]
1633 defines += [ "ANGLE_FEATURE_UTIL_LOG_VERBOSE" ]
1637 angle_shared_library("libfeature_support") {
1638 output_name = "libfeature_support${angle_libs_suffix}"
1645 ":angle_feature_support_config",
1646 "${angle_jsoncpp_dir}:jsoncpp_config",
1649 if (is_apple && !is_component_build) {
1652 "@rpath/${target_name}.dylib",
1657 "src/feature_support_util/feature_support_util.cpp",
1658 "src/feature_support_util/feature_support_util.h",
1662 ":angle_gpu_info_util",
1663 "${angle_jsoncpp_dir}:jsoncpp",
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 ]
1678 rebase_path(_plist_file, root_build_dir),
1683 if (is_android && symbol_level != 0) {
1684 action_foreach("compressed_symbols") {
1686 foreach(_library, angle_libraries) {
1687 if (is_component_build) {
1688 sources += [ "$root_out_dir/${_library}${angle_libs_suffix}.cr.so" ]
1690 sources += [ "$root_out_dir/${_library}${angle_libs_suffix}.so" ]
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" ]
1698 sources += [ "$root_out_dir/lib${_layer}.so" ]
1703 script = rebase_path("${root_build_dir}/android/compress_symbols.py",
1707 foreach(_library, angle_libraries) {
1708 deps += [ ":$_library" ]
1711 if (angle_enable_vulkan_validation_layers) {
1712 foreach(_layer, vulkan_validation_layers) {
1713 deps += [ "$angle_vulkan_validation_layers_dir:${_layer}" ]
1717 outputs = [ "$root_out_dir/lib.compressed/{{source_file_part}}" ]
1719 android_nm = "${android_tool_prefix}nm"
1720 android_strip = "${android_tool_prefix}strip"
1724 rebase_path(android_objcopy, root_build_dir),
1726 rebase_path(android_nm, root_build_dir),
1728 rebase_path(android_strip, root_build_dir),
1729 "--unstrippedsofile",
1730 "{{source_dir}}/lib.unstripped/{{source_file_part}}",
1732 "{{source_dir}}/lib.compressed/{{source_file_part}}",
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) {
1742 exec_script("src/commit_id.py", [ "position" ], "trim string")
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
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
1761 group("angle_apks") {
1763 ":angle_agi_chromium_apk",
1764 ":angle_chromium_apk",
1775 if (angle_enable_vulkan) {
1777 ":libEGL_vulkan_secondaries",
1778 ":libGLESv2_vulkan_secondaries",
1782 # Need to bundle the libraries inside the .app.
1787 group("angle_static") {
1790 ":libGLESv2_static",