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