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 5import("//build_overrides/angle.gni") 6 7declare_args() { 8 is_ggp = false 9 10 # Extract native libs in ANGLE apk. Useful for flamegraph generation. 11 angle_extract_native_libs = false 12 13 # Display mode for ANGLE vulkan display, could be 'simple' or 'headless', default is 'simple'. 14 angle_vulkan_display_mode = "simple" 15 16 # Defaults to capture building to $root_out_dir/angle_libs/with_capture. 17 # Switch on to build capture to $root_out_dir. 18 angle_with_capture_by_default = false 19 20 # Enables OpenCL support, off by default. 21 angle_enable_cl = false 22 23 # Enables OpenCL testing support, off by default. 24 angle_enable_cl_testing = false 25 26 angle_restricted_traces = [] 27 28 # Don't build dEQP by default. 29 build_angle_deqp_tests = false 30 31 # Enable Desktop GL frontend support. 32 angle_enable_gl_desktop_frontend = false 33} 34 35declare_args() { 36 # Expose WGL entry points, which is necessary for running windows desktop GL applications against ANGLE. 37 # TODO(http://anglebug.com/7628): This condition should be `angle_enable_gl_desktop_frontend && is_win` 38 # This is disabled by default on Windows because it was causing some test failures. Once the WGL frontend 39 # has more functionality implemented, we can re-enable this. 40 angle_expose_wgl_entry_points = false 41 42 # Expose GLX entry points by default when using Desktop GL on Linux. 43 angle_expose_glx_entry_points = angle_enable_gl_desktop_frontend && is_linux 44 45 # Only bundle traces in the APK if we're building a subset 46 restricted_traces_outside_of_apk = is_android && angle_restricted_traces == [] 47} 48 49if (angle_has_build) { 50 import("//build/config/dcheck_always_on.gni") 51 import("//build/config/ozone.gni") # import the ozone_platform_x11 variable 52 import("//build/config/sanitizers/sanitizers.gni") 53 import("//build_overrides/build.gni") 54 import("//testing/test.gni") 55 if (is_android) { 56 import("//build/config/android/config.gni") 57 } 58 59 if (is_win) { 60 import("//build/config/win/visual_studio_version.gni") 61 } 62 63 if (is_chromeos) { 64 angle_vulkan_display_mode = "offscreen" 65 } else if (is_castos || ozone_platform_headless) { 66 angle_vulkan_display_mode = "headless" 67 } 68 69 declare_args() { 70 angle_use_gbm = ozone_platform_gbm 71 angle_use_x11 = ozone_platform_x11 && !is_ggp && (is_linux || is_chromeos) 72 angle_use_wayland = 73 ozone_platform_wayland && !is_ggp && is_linux && !is_castos 74 angle_use_vulkan_display = (is_linux || is_chromeos) && !is_ggp 75 } 76} else { 77 declare_args() { 78 is_ubsan = false 79 is_tsan = false 80 is_asan = false 81 is_lsan = false 82 build_with_chromium = false 83 dcheck_always_on = false 84 angle_use_x11 = (is_linux || is_chromeos) && !is_ggp 85 angle_use_wayland = is_linux && !is_ggp 86 use_ozone = false 87 ozone_platform_gbm = false 88 ozone_platform_wayland = false 89 ozone_platform_headless = false 90 use_fuzzing_engine = false 91 is_apple = is_mac || is_ios 92 } 93 94 declare_args() { 95 angle_use_vulkan_display = (is_linux || is_chromeos) && !is_ggp 96 } 97} 98 99if (!defined(checkout_angle_internal)) { 100 checkout_angle_internal = false 101} 102 103if (!defined(checkout_angle_restricted_traces)) { 104 checkout_angle_restricted_traces = false 105} 106 107# Subdirectory to place data files (e.g. layer JSON files). 108angle_data_dir = "angledata" 109 110declare_args() { 111 angle_assert_always_on = dcheck_always_on 112 113 if (current_cpu == "arm64" || current_cpu == "x64" || 114 current_cpu == "mips64el" || current_cpu == "s390x" || 115 current_cpu == "ppc64" || current_cpu == "loong64" || 116 current_cpu == "riscv64") { 117 angle_64bit_current_cpu = true 118 } else if (current_cpu == "arm" || current_cpu == "x86" || 119 current_cpu == "mipsel" || current_cpu == "s390" || 120 current_cpu == "ppc" || current_cpu == "loong32") { 121 angle_64bit_current_cpu = false 122 } else { 123 assert(false, "Unknown current CPU: $current_cpu") 124 } 125 126 # Indicate if the rapidJSON library is available to build with in third_party/. 127 angle_has_rapidjson = angle_has_build 128 129 angle_is_winappsdk = false 130 131 # Windows App SDK is a separate dependency from nuget.org that needs to 132 # be pre-processed before being used. 133 winappsdk_dir = "" 134} 135 136declare_args() { 137 # By default we enable debug layers when asserts are turned on. 138 angle_debug_layers_enabled = is_debug || angle_assert_always_on 139 140 if (!is_android) { 141 ndk_api_level_at_least_26 = false 142 } else { 143 ndk_api_level_at_least_26 = 144 (!angle_64bit_current_cpu && android32_ndk_api_level >= 26) || 145 (angle_64bit_current_cpu && android64_ndk_api_level >= 26) 146 } 147 148 # Vulkan loader is statically linked on Mac. http://anglebug.com/4477 149 angle_shared_libvulkan = !is_mac 150 151 # There's no "is_winuwp" helper in BUILDCONFIG.gn, so we define one ourselves 152 # Windows App SDK is almost UWP but for Win32, so we want all the same things 153 angle_is_winuwp = (is_win && target_os == "winuwp") || angle_is_winappsdk 154 155 angle_is_msvc = is_win && !is_clang 156 157 # Default to using "_angle" suffix on Android 158 if (is_android) { 159 angle_libs_suffix = "_angle" 160 } else { 161 angle_libs_suffix = "" 162 } 163 164 # Currently Windows on Arm doesn't support OpenGL or Vulkan. 165 is_win_arm64 = is_win && target_cpu == "arm64" 166 167 # Frame capture code is enabled by default if rapidjson is available. 168 angle_has_frame_capture = angle_has_rapidjson 169} 170 171declare_args() { 172 # By default, ANGLE is using a thread pool for parallel compilation. 173 # Activating the delegate worker results in posting the tasks using the 174 # embedder API. In Chromium code base, it results in sending tasks to the 175 # worker thread pool. 176 angle_delegate_workers = build_with_chromium 177 178 # True if we are building inside an ANGLE checkout. 179 angle_standalone = !build_with_chromium 180 181 angle_enable_d3d9 = is_win && !angle_is_winuwp 182 angle_enable_d3d11 = is_win 183 angle_enable_gl = 184 (ozone_platform_gbm || ozone_platform_wayland || !is_linux || 185 ((angle_use_x11 && !is_chromeos) || angle_use_wayland || is_castos)) && 186 !is_fuchsia && !angle_is_winuwp && !is_ggp && !is_win_arm64 187 188 angle_enable_vulkan = 189 angle_has_build && 190 !(is_android && build_with_chromium && is_official_build) && 191 ((is_win && !angle_is_winuwp) || 192 ((is_linux || is_chromeos) && 193 (angle_use_x11 || angle_use_wayland || angle_use_vulkan_display)) || 194 is_android || is_fuchsia || is_ggp || is_mac) 195 196 # When set to true, ANGLE will not use VK_KHR_surface and VK_KHR_swapchain 197 # extensions. Content can be rendered only off-screen. 198 angle_use_vulkan_null_display = build_with_chromium && is_fuchsia 199 200 # Disable null backend to save space for official build. 201 angle_enable_null = !is_official_build 202 angle_enable_gl_desktop_backend = !is_android && !is_ios 203 204 # http://anglebug.com/2634 205 angle_enable_metal = is_apple 206 207 # Enables the OpenCL pass-through back end 208 angle_enable_cl_passthrough = angle_enable_cl 209 210 # Disable WGPU backend. 211 # Currently disabled on Android, Fuschia, WinUWP, and Win MSVC. 212 # anglebug.com/8541 213 angle_enable_wgpu = 214 !is_official_build && !(is_android || is_fuchsia || angle_is_winuwp) && 215 (!is_win || is_clang) && defined(angle_dawn_dir) 216} 217 218declare_args() { 219 # ASTC emulation is only built on standalone non-android builds 220 angle_has_astc_encoder = angle_has_build && angle_standalone && !is_android 221} 222 223declare_args() { 224 angle_test_enable_system_egl = false 225} 226 227# OpenCL is not supported on Windows UWP, because the CL headers include DX9, which is not 228# supported by UWP. A workaround might be possible if CL support on UWP is required. 229assert(!angle_is_winuwp || !angle_enable_cl, 230 "OpenCL is not supported on Windows UWP") 231 232assert(!angle_is_winappsdk || winappsdk_dir != "", 233 "No path to Windows App SDK was provided using 'winappsdk_dir'") 234 235if (!angle_enable_cl) { 236 angle_enable_cl_passthrough = false 237} 238 239if (!defined(checkout_angle_mesa)) { 240 checkout_angle_mesa = false 241} 242 243declare_args() { 244 # Currently SwiftShader's Vulkan front-end doesn't build on Android. 245 # Disabled by default on MSVC because of compiler warnings/errors. 246 angle_enable_swiftshader = 247 angle_enable_vulkan && !is_android && !is_ggp && is_clang 248 249 # Translator frontend support: 250 angle_enable_desktop_glsl = angle_enable_gl_desktop_frontend 251 252 # Translator backend support: 253 angle_enable_hlsl = angle_enable_d3d9 || angle_enable_d3d11 254 angle_enable_essl = angle_enable_gl || use_ozone 255 angle_enable_glsl = angle_enable_gl || use_ozone 256 angle_enable_trace = false 257 angle_enable_trace_android_logcat = false 258 angle_enable_trace_events = false 259 angle_dump_pipeline_cache_graph = false 260 261 angle_always_log_info = false 262 263 # Unwind backtrace support. This feature is currently only implemented 264 # on Android for debugging purposes. Disabled by default. 265 angle_enable_unwind_backtrace_support = false 266 267 # Memory allocation logging support. This feature is for debugging only. 268 # Disabled by default. 269 angle_enable_memory_alloc_logging = false 270 271 # Disable the layers in ubsan builds because of really slow builds. 272 # Vulkan Validation Layers require Android NDK API level 26, i.e. Oreo, due to 273 # Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714. 274 # This is disabled in the Chromium build because the current build toolchain 275 # for APKs and bundles expect a single .so file in trichrome builds. See 276 # https://bugs.chromium.org/p/angleproject/issues/detail?id=8398 for details. 277 angle_enable_vulkan_validation_layers = 278 angle_enable_vulkan && !is_ubsan && !is_tsan && !is_asan && 279 angle_debug_layers_enabled && 280 (!is_android || (ndk_api_level_at_least_26 && !build_with_chromium)) 281 282 # ISpriteVisual windows cannot be validated and can lead to crashes if an invalid window is 283 # provided to ANGLE. Disable them for non-standalone ANGLE builds. crbug.com/1176118 284 angle_enable_d3d11_compositor_native_window = 285 angle_enable_d3d11 && angle_standalone 286 287 # Disable performance counter output by default 288 angle_enable_perf_counter_output = false 289 290 # We should use EAGL (ES) on iOS except on Mac Catalyst on Intel CPUs, which uses CGL (desktop GL). 291 angle_enable_eagl = angle_enable_gl && is_ios && 292 !(target_environment == "catalyst" && 293 (target_cpu == "x86" || target_cpu == "x64")) 294 295 # Directory where to find wayland source files 296 angle_wayland_dir = "$angle_root/third_party/wayland" 297 298 angle_vulkan_headers_dir = "$angle_root/third_party/vulkan-headers/src" 299 angle_vulkan_loader_dir = "$angle_root/third_party/vulkan-loader/src" 300 angle_vulkan_tools_dir = "$angle_root/third_party/vulkan-tools/src" 301 angle_vulkan_validation_layers_dir = 302 "$angle_root/third_party/vulkan-validation-layers/src" 303 304 angle_build_vulkan_system_info = angle_has_build && !angle_is_winuwp 305 306 # Enable overlay by default when debug layers are enabled. This is currently only implemented on 307 # Vulkan. 308 angle_enable_overlay = angle_enable_vulkan && angle_debug_layers_enabled 309 310 angle_build_mesa = false 311} 312 313declare_args() { 314 # TODO(jdarpinian): Support enabling CGL and EAGL at the same time using the soft linking code. Also support disabling both for Metal-only builds. 315 angle_enable_cgl = angle_enable_gl && !angle_enable_eagl && is_apple 316 317 angle_enable_apple_translator_workarounds = 318 is_apple && (angle_enable_glsl || use_fuzzing_engine) 319 320 angle_has_histograms = angle_has_build 321 322 # True if we want to build the ANGLE test suites. On by default in most configs. 323 angle_build_tests = angle_has_build 324} 325 326declare_args() { 327 angle_enable_renderdoc = angle_enable_vulkan_validation_layers 328} 329 330if (!defined(angle_zlib_compression_utils_dir)) { 331 angle_zlib_compression_utils_dir = "//third_party/zlib/google" 332} 333 334angle_common_configs = [ 335 angle_root + ":angle_asserts_config", 336 angle_root + ":constructor_and_destructor_warnings", 337 angle_root + ":extra_warnings", 338 angle_root + ":internal_config", 339 angle_root + ":angle_uwp_env", 340] 341 342angle_remove_configs = [] 343 344if (angle_has_build) { 345 angle_remove_configs += [ "//build/config/compiler:default_include_dirs" ] 346 347 if (is_clang) { 348 angle_remove_configs += [ "//build/config/clang:find_bad_constructs" ] 349 } 350 351 if (!is_debug && !is_fuchsia) { 352 # default->optimize_max (e.g. Android defaults to -Oz, optimize_max is -O2) 353 angle_remove_configs += [ "//build/config/compiler:default_optimization" ] 354 angle_common_configs += [ "//build/config/compiler:optimize_max" ] 355 } 356} 357 358set_defaults("angle_executable") { 359 configs = angle_common_configs 360 public_configs = [] 361 suppressed_configs = angle_remove_configs 362 data_deps = [] 363} 364 365set_defaults("angle_shared_library") { 366 configs = angle_common_configs 367 public_configs = [] 368 suppressed_configs = angle_remove_configs 369} 370 371set_defaults("angle_source_set") { 372 configs = angle_common_configs 373 public_configs = [] 374 suppressed_configs = angle_remove_configs 375} 376 377set_defaults("angle_static_library") { 378 configs = angle_common_configs 379 public_configs = [] 380 suppressed_configs = angle_remove_configs 381} 382 383set_defaults("angle_test") { 384 # Gtest itself can't pass all the strict warning filters. 385 configs = angle_common_configs - [ 386 "$angle_root:constructor_and_destructor_warnings", 387 "$angle_root:extra_warnings", 388 ] + [ "$angle_root/src/tests:angle_maybe_has_histograms" ] + 389 [ "$angle_root/src/tests:angle_enable_renderdoc" ] 390 391 public_configs = [] 392 public_deps = [] 393 sources = [] 394 data = [] 395 defines = [] 396 deps = [] 397 data_deps = [] 398 suppressed_configs = angle_remove_configs 399} 400 401template("angle_executable") { 402 executable(target_name) { 403 forward_variables_from(invoker, 404 "*", 405 [ 406 "configs", 407 "suppressed_configs", 408 "visibility", 409 ]) 410 411 # Needed because visibility is global. 412 forward_variables_from(invoker, [ "visibility" ]) 413 414 configs += invoker.configs 415 configs -= invoker.suppressed_configs 416 417 if (angle_has_build && is_win) { 418 data_deps += [ "//build/win:runtime_libs" ] 419 } 420 421 if (is_ios) { 422 check_includes = false 423 } 424 } 425} 426 427template("angle_shared_library") { 428 # On ios, define an ios_framework_bundle instead of a shared library. 429 # ios_framework_bundle doesn't automatically link, so we have to create 430 # a group that links and bundles the framework as well. 431 target_type = "shared_library" 432 internal_target_name = target_name 433 if (is_ios) { 434 target_type = "ios_framework_bundle" 435 internal_target_name = target_name + "_framework" 436 } 437 target(target_type, internal_target_name) { 438 forward_variables_from(invoker, 439 "*", 440 [ 441 "configs", 442 "suppressed_configs", 443 "visibility", 444 ]) 445 446 # Needed because visibility is global. 447 forward_variables_from(invoker, [ "visibility" ]) 448 449 configs += invoker.configs 450 configs -= invoker.suppressed_configs 451 452 if (is_apple) { 453 # If a "build with ARC" config is present, remove it. 454 if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) != 455 []) { 456 configs -= [ "//build/config/compiler:enable_arc" ] 457 } 458 } 459 460 public_configs += [ angle_root + ":shared_library_public_config" ] 461 462 if (is_android) { 463 configs += [ angle_root + ":build_id_config" ] 464 configs -= [ "//build/config/android:hide_all_but_jni_onload" ] 465 } 466 if (is_ios) { 467 info_plist = "$angle_root/util/ios/Info.plist" 468 469 # shared libraries are hidden inside ios_framework_bundle, but we include headers from them 470 # Specifically, libGLESv1_CM includes headers from libGLESv2 471 check_includes = false 472 } 473 } 474 if (is_ios) { 475 group(target_name) { 476 forward_variables_from(invoker, 477 [ 478 "testonly", 479 "visibility", 480 ]) 481 public_deps = [ 482 ":${internal_target_name}+bundle", 483 ":${internal_target_name}+link", 484 ] 485 } 486 } 487} 488 489template("angle_source_set") { 490 source_set(target_name) { 491 forward_variables_from(invoker, 492 "*", 493 [ 494 "configs", 495 "suppressed_configs", 496 "visibility", 497 ]) 498 499 # Needed because visibility is global. 500 forward_variables_from(invoker, [ "visibility" ]) 501 502 configs += invoker.configs 503 configs -= invoker.suppressed_configs 504 505 if (is_apple) { 506 # If a "build with ARC" config is present, remove it. 507 if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) != 508 []) { 509 configs -= [ "//build/config/compiler:enable_arc" ] 510 } 511 } 512 } 513} 514 515template("angle_static_library") { 516 static_library(target_name) { 517 forward_variables_from(invoker, 518 "*", 519 [ 520 "configs", 521 "suppressed_configs", 522 "visibility", 523 ]) 524 525 # Needed because visibility is global. 526 forward_variables_from(invoker, [ "visibility" ]) 527 528 configs += invoker.configs 529 configs -= invoker.suppressed_configs 530 531 if (is_apple) { 532 # If a "build with ARC" config is present, remove it. 533 if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) != 534 []) { 535 configs -= [ "//build/config/compiler:enable_arc" ] 536 } 537 } 538 } 539} 540 541if (angle_standalone || build_with_chromium) { 542 template("angle_test") { 543 test(target_name) { 544 forward_variables_from(invoker, 545 "*", 546 [ 547 "configs", 548 "data", 549 "public_deps", 550 ]) 551 552 configs += invoker.configs 553 configs -= invoker.suppressed_configs 554 555 if (is_apple) { 556 # If a "build with ARC" config is present, remove it. 557 if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) != 558 []) { 559 configs -= [ "//build/config/compiler:enable_arc" ] 560 } 561 } 562 563 if (is_ios) { 564 # shared libraries are hidden inside ios_framework_bundle, but we include headers from them 565 check_includes = false 566 } 567 568 public_deps = invoker.public_deps + [ 569 "$angle_root:angle_common", 570 "$angle_root:includes", 571 "$angle_root/src/tests:angle_test_expectations", 572 "$angle_root/third_party/rapidjson:rapidjson", 573 "$angle_root/util:angle_test_utils", 574 "//testing/gmock", 575 "//testing/gtest", 576 "//third_party/googletest:gmock", 577 "//third_party/googletest:gtest", 578 ] 579 580 data = invoker.data + [ 581 "$angle_root/src/tests/py_utils/android_helper.py", 582 "$angle_root/src/tests/py_utils/angle_path_util.py", 583 "$angle_root/src/tests/py_utils/angle_test_util.py", 584 "//testing/scripts/common.py", 585 "//testing/xvfb.py", 586 ] 587 588 sources += [ 589 "$angle_root/src/tests/test_utils/runner/HistogramWriter.h", 590 "$angle_root/src/tests/test_utils/runner/TestSuite.cpp", 591 "$angle_root/src/tests/test_utils/runner/TestSuite.h", 592 ] 593 594 if (angle_has_histograms) { 595 sources += 596 [ "$angle_root/src/tests/test_utils/runner/HistogramWriter.cpp" ] 597 deps += [ 598 "//third_party/catapult/tracing/tracing:histogram", 599 "//third_party/catapult/tracing/tracing:reserved_infos", 600 ] 601 } 602 603 if (is_mac) { 604 if (angle_enable_metal) { 605 # On macOS, compiling Metal shader sometimes takes very long time due to internal caching 606 # mechanism. This hooking library is a way to bypass this caching mechanism. 607 data_deps += [ "$angle_root/src/libANGLE/renderer/metal/file_hooking:metal_shader_cache_file_hooking" ] 608 } 609 if (angle_enable_cgl) { 610 configs += [ "$angle_root:supports_automatic_graphics_switching" ] 611 } 612 } 613 614 if ((is_linux && !is_chromeos) || 615 (build_with_chromium && is_chromeos_lacros && !is_chromeos_device)) { 616 use_xvfb = true 617 } 618 619 if ((is_linux || is_chromeos) && !is_component_build) { 620 # Set rpath to find shared libs in a non-component build. 621 configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] 622 } 623 624 if (is_android) { 625 public_configs += [ "$angle_root:build_id_config" ] 626 configs -= [ "//build/config/android:hide_all_but_jni" ] 627 use_default_launcher = false 628 generate_final_jni = false 629 android_manifest_template = "$angle_root/src/tests/test_utils/runner/android/java/AndroidManifest.xml.jinja2" 630 631 deps += [ 632 "$angle_root/src/tests:native_test_java", 633 "$angle_root/src/tests:native_test_support_android", 634 ] 635 } 636 if (is_ios) { 637 # We use a special main function on iOS to initialize UIKit before the normal main runs. 638 ldflags = [ 639 "-e", 640 "_ios_main", 641 ] 642 sources += [ "$angle_root/util/ios/ios_main.mm" ] 643 } 644 645 if (angle_has_build && is_win) { 646 data_deps += [ "//build/win:runtime_libs" ] 647 } 648 } 649 } 650} 651 652if (angle_enable_cl) { 653 # need the llvm build flags 654 import("$angle_clspv_dir/gn/build/llvm_buildflags.gni") 655} 656