• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  # Extract native libs in ANGLE apk. Useful for flamegraph generation.
9  angle_extract_native_libs = false
10
11  # Display mode for ANGLE vulkan display, could be 'simple' or 'headless', default is 'simple'.
12  angle_vulkan_display_mode = "simple"
13
14  # Defaults to capture building to $root_out_dir/angle_libs/with_capture.
15  # Switch on to build capture to $root_out_dir.
16  angle_with_capture_by_default = false
17
18  # Enables OpenCL support, off by default.
19  angle_enable_cl = false
20
21  angle_restricted_traces = []
22
23  # Don't build dEQP by default.
24  build_angle_deqp_tests = false
25
26  build_angle_end2end_tests_aosp = false
27
28  # List of traces for benchmark mode
29  angle_standalone_benchmark_traces = []
30
31  # Benchmark mode golden default directory
32  angle_standalone_benchmark_goldens_dir = ""
33}
34
35declare_args() {
36  # Enable angle standalone benchmark mode if list of traces is provided
37  angle_standalone_benchmark =
38      is_android && angle_standalone_benchmark_traces != []
39
40  # Only bundle traces in the APK if we're building a subset or if standalone benchmark is selected
41  restricted_traces_outside_of_apk =
42      is_android && angle_restricted_traces == [] &&
43      angle_standalone_benchmark_traces == []
44
45  # Enables OpenCL testing support
46  angle_enable_cl_testing = angle_enable_cl && (is_linux || is_android)
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_linux || is_chromeos)
72    angle_use_wayland = ozone_platform_wayland && is_linux && !is_castos
73    angle_use_vulkan_display = is_linux || is_chromeos
74  }
75} else {
76  declare_args() {
77    is_ubsan = false
78    is_tsan = false
79    is_asan = false
80    is_lsan = false
81    build_with_chromium = false
82    dcheck_always_on = false
83    angle_use_x11 = is_linux || is_chromeos
84    angle_use_wayland = is_linux
85    use_ozone = false
86    ozone_platform_gbm = false
87    ozone_platform_wayland = false
88    ozone_platform_headless = false
89    use_fuzzing_engine = false
90    is_apple = is_mac || is_ios
91    is_desktop_android = false
92  }
93
94  declare_args() {
95    angle_use_vulkan_display = is_linux || is_chromeos
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/40096682
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_win_arm64 && !is_ios
187
188  angle_enable_vulkan =
189      angle_has_build &&
190      ((is_win && !angle_is_winuwp) ||
191       ((is_linux || is_chromeos) &&
192        (angle_use_x11 || angle_use_wayland || angle_use_vulkan_display)) ||
193       is_android || is_fuchsia || is_mac)
194
195  # When set to true, ANGLE will not use VK_KHR_surface and VK_KHR_swapchain
196  # extensions. Content can be rendered only off-screen.
197  angle_use_vulkan_null_display = build_with_chromium && is_fuchsia
198
199  # Disable null backend to save space for official build.
200  angle_enable_null = !is_official_build
201  angle_enable_gl_desktop_backend = !is_android && !is_ios
202
203  # http://anglebug.com/40096506
204  angle_enable_metal = is_apple
205
206  # Enables the OpenCL pass-through back end
207  angle_enable_cl_passthrough = angle_enable_cl
208
209  # Disable WGPU backend.
210  # Currently disabled on Android, Fuschia, WinUWP, and Win MSVC. X11 required on Linux.
211  # anglebug.com/42266968
212  angle_enable_wgpu =
213      !is_official_build && !(is_android || is_fuchsia || angle_is_winuwp) &&
214      (!is_win || is_clang) && (!is_linux || angle_use_x11) &&
215      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 = angle_enable_vulkan && !is_android && is_clang
247
248  # Translator backend support:
249  angle_enable_hlsl = angle_enable_d3d9 || angle_enable_d3d11
250  angle_enable_essl = angle_enable_gl || use_ozone
251  angle_enable_glsl = angle_enable_gl || use_ozone
252  angle_enable_trace = false
253  angle_enable_trace_android_logcat = false
254  angle_enable_trace_events = false
255  angle_dump_pipeline_cache_graph = false
256
257  angle_always_log_info = false
258
259  # Unwind backtrace support. This feature is currently only implemented
260  # on Android for debugging purposes. Disabled by default.
261  angle_enable_unwind_backtrace_support = false
262
263  # Memory allocation logging support. This feature is for debugging only.
264  # Disabled by default.
265  angle_enable_memory_alloc_logging = false
266
267  # Disable the layers in ubsan builds because of really slow builds.
268  # Vulkan Validation Layers require Android NDK API level 26, i.e. Oreo, due to
269  # Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714.
270  # This is disabled in the Chromium build because the current build toolchain
271  # for APKs and bundles expect a single .so file in trichrome builds. See
272  # https://bugs.chromium.org/p/angleproject/issues/detail?id=8398 for details.
273  angle_enable_vulkan_validation_layers =
274      angle_enable_vulkan && !is_ubsan && !is_tsan && !is_asan &&
275      angle_debug_layers_enabled &&
276      (!is_android || (ndk_api_level_at_least_26 && !build_with_chromium))
277  angle_enable_vulkan_api_dump_layer =
278      angle_enable_vulkan && angle_debug_layers_enabled && angle_standalone &&
279      !is_apple && (is_linux || is_android)
280
281  # ISpriteVisual windows cannot be validated and can lead to crashes if an invalid window is
282  # provided to ANGLE. Disable them for non-standalone ANGLE builds. crbug.com/1176118
283  angle_enable_d3d11_compositor_native_window =
284      angle_enable_d3d11 && angle_standalone
285
286  # Disable performance counter output by default
287  angle_enable_perf_counter_output = false
288
289  # Directory where to find wayland source files
290  angle_wayland_dir = "$angle_root/third_party/wayland"
291
292  angle_vulkan_headers_dir = "$angle_root/third_party/vulkan-headers/src"
293  angle_vulkan_loader_dir = "$angle_root/third_party/vulkan-loader/src"
294  angle_vulkan_tools_dir = "$angle_root/third_party/vulkan-tools/src"
295  angle_vulkan_validation_layers_dir =
296      "$angle_root/third_party/vulkan-validation-layers/src"
297  angle_lunarg_vulkantools_dir =
298      "$angle_root/third_party/lunarg-vulkantools/src"
299
300  angle_build_vulkan_system_info = angle_has_build && !angle_is_winuwp
301
302  # Enable overlay by default when debug layers are enabled.  This is currently only implemented on
303  # Vulkan.
304  angle_enable_overlay = angle_enable_vulkan && angle_debug_layers_enabled
305
306  angle_build_mesa = false
307
308  # Android platform's addTraceEvent ignores the timestamp and time() is a relatively heavy call.
309  angle_trace_events_ignore_timestamp = is_android && angle_standalone
310}
311
312declare_args() {
313  angle_enable_cgl = angle_enable_gl && is_mac
314
315  angle_enable_apple_translator_workarounds =
316      is_apple && (angle_enable_glsl || use_fuzzing_engine)
317
318  angle_has_histograms = angle_has_build
319
320  # True if we want to build the ANGLE test suites. On by default in most configs.
321  angle_build_tests = angle_has_build
322}
323
324declare_args() {
325  angle_enable_renderdoc = angle_enable_vulkan_validation_layers
326}
327
328if (!defined(angle_zlib_compression_utils_dir)) {
329  angle_zlib_compression_utils_dir = "//third_party/zlib/google"
330}
331
332angle_common_configs = [
333  angle_root + ":angle_asserts_config",
334  angle_root + ":constructor_and_destructor_warnings",
335  angle_root + ":extra_warnings",
336  angle_root + ":internal_config",
337  angle_root + ":angle_uwp_env",
338]
339
340angle_remove_configs = []
341
342if (angle_has_build) {
343  angle_remove_configs += [ "//build/config/compiler:default_include_dirs" ]
344
345  if (is_clang && !is_nacl) {
346    angle_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
347  }
348
349  if (!is_debug && !is_fuchsia) {
350    # default->optimize_max (e.g. Android defaults to -Oz, optimize_max is -O2)
351    angle_remove_configs += [ "//build/config/compiler:default_optimization" ]
352    angle_common_configs += [ "//build/config/compiler:optimize_max" ]
353  }
354}
355
356set_defaults("angle_executable") {
357  configs = angle_common_configs
358  public_configs = []
359  suppressed_configs = angle_remove_configs
360  data_deps = []
361}
362
363set_defaults("angle_shared_library") {
364  configs = angle_common_configs
365  public_configs = []
366  suppressed_configs = angle_remove_configs
367}
368
369set_defaults("angle_source_set") {
370  configs = angle_common_configs
371  public_configs = []
372  suppressed_configs = angle_remove_configs
373}
374
375set_defaults("angle_static_library") {
376  configs = angle_common_configs
377  public_configs = []
378  suppressed_configs = angle_remove_configs
379}
380
381set_defaults("angle_test") {
382  # Gtest itself can't pass all the strict warning filters.
383  configs = angle_common_configs - [
384              "$angle_root:constructor_and_destructor_warnings",
385              "$angle_root:extra_warnings",
386            ] + [ "$angle_root/src/tests:angle_maybe_has_histograms" ] +
387            [ "$angle_root/src/tests:angle_enable_renderdoc" ]
388
389  public_configs = []
390  public_deps = []
391  sources = []
392  data = []
393  defines = []
394  deps = []
395  data_deps = []
396  suppressed_configs = angle_remove_configs
397}
398
399template("angle_executable") {
400  executable(target_name) {
401    forward_variables_from(invoker,
402                           "*",
403                           [
404                             "configs",
405                             "suppressed_configs",
406                             "visibility",
407                           ])
408
409    # Needed because visibility is global.
410    forward_variables_from(invoker, [ "visibility" ])
411
412    configs += invoker.configs
413    configs -= invoker.suppressed_configs
414
415    if (angle_has_build && is_win) {
416      data_deps += [ "//build/win:runtime_libs" ]
417    }
418
419    if (is_ios) {
420      check_includes = false
421    }
422  }
423}
424
425template("angle_shared_library") {
426  # On ios, define an ios_framework_bundle instead of a shared library.
427  # ios_framework_bundle doesn't automatically link, so we have to create
428  # a group that links and bundles the framework as well.
429  target_type = "shared_library"
430  internal_target_name = target_name
431  if (is_ios) {
432    target_type = "ios_framework_bundle"
433    internal_target_name = target_name + "_framework"
434  }
435  target(target_type, internal_target_name) {
436    forward_variables_from(invoker,
437                           "*",
438                           [
439                             "configs",
440                             "suppressed_configs",
441                             "visibility",
442                           ])
443
444    # Needed because visibility is global.
445    forward_variables_from(invoker, [ "visibility" ])
446
447    configs += invoker.configs
448    configs -= invoker.suppressed_configs
449
450    if (is_apple) {
451      # If a "build with ARC" config is present, remove it.
452      if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) !=
453          []) {
454        configs -= [ "//build/config/compiler:enable_arc" ]
455      }
456    }
457
458    public_configs += [ angle_root + ":shared_library_public_config" ]
459
460    if (is_android) {
461      configs += [ angle_root + ":build_id_config" ]
462      configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
463    }
464    if (is_ios) {
465      info_plist = "$angle_root/util/ios/Info.plist"
466
467      # shared libraries are hidden inside ios_framework_bundle, but we include headers from them
468      # Specifically, libGLESv1_CM includes headers from libGLESv2
469      check_includes = false
470    }
471  }
472  if (is_ios) {
473    group(target_name) {
474      forward_variables_from(invoker,
475                             [
476                               "testonly",
477                               "visibility",
478                             ])
479      public_deps = [
480        ":${internal_target_name}+bundle",
481        ":${internal_target_name}+link",
482      ]
483    }
484  }
485}
486
487template("angle_source_set") {
488  source_set(target_name) {
489    forward_variables_from(invoker,
490                           "*",
491                           [
492                             "configs",
493                             "suppressed_configs",
494                             "visibility",
495                           ])
496
497    # Needed because visibility is global.
498    forward_variables_from(invoker, [ "visibility" ])
499
500    configs += invoker.configs
501    configs -= invoker.suppressed_configs
502
503    if (is_apple) {
504      # If a "build with ARC" config is present, remove it.
505      if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) !=
506          []) {
507        configs -= [ "//build/config/compiler:enable_arc" ]
508      }
509    }
510  }
511}
512
513template("angle_static_library") {
514  static_library(target_name) {
515    forward_variables_from(invoker,
516                           "*",
517                           [
518                             "configs",
519                             "suppressed_configs",
520                             "visibility",
521                           ])
522
523    # Needed because visibility is global.
524    forward_variables_from(invoker, [ "visibility" ])
525
526    configs += invoker.configs
527    configs -= invoker.suppressed_configs
528
529    if (is_apple) {
530      # If a "build with ARC" config is present, remove it.
531      if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) !=
532          []) {
533        configs -= [ "//build/config/compiler:enable_arc" ]
534      }
535    }
536  }
537}
538
539if (angle_standalone || build_with_chromium || build_angle_end2end_tests_aosp) {
540  template("angle_test") {
541    test(target_name) {
542      forward_variables_from(invoker,
543                             "*",
544                             [
545                               "configs",
546                               "data",
547                               "public_deps",
548                             ])
549
550      configs += invoker.configs
551      configs -= invoker.suppressed_configs
552
553      if (is_apple) {
554        # If a "build with ARC" config is present, remove it.
555        if (filter_include(configs, [ "//build/config/compiler:enable_arc" ]) !=
556            []) {
557          configs -= [ "//build/config/compiler:enable_arc" ]
558        }
559      }
560
561      if (is_ios) {
562        # shared libraries are hidden inside ios_framework_bundle, but we include headers from them
563        check_includes = false
564      }
565
566      public_deps = invoker.public_deps + [
567                      "$angle_root:angle_common",
568                      "$angle_root:includes",
569                      "$angle_root/src/tests:angle_test_expectations",
570                      "$angle_root/util:angle_test_utils",
571                      "//testing/gmock",
572                      "//testing/gtest",
573                      "//third_party/googletest:gmock",
574                      "//third_party/googletest:gtest",
575                    ]
576      if (angle_has_rapidjson) {
577        public_deps += [ "$angle_root/third_party/rapidjson:rapidjson" ]
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      if (angle_has_rapidjson) {
589        sources += [
590          "$angle_root/src/tests/test_utils/runner/HistogramWriter.h",
591          "$angle_root/src/tests/test_utils/runner/TestSuite.cpp",
592          "$angle_root/src/tests/test_utils/runner/TestSuite.h",
593        ]
594      }
595
596      if (angle_has_histograms) {
597        sources +=
598            [ "$angle_root/src/tests/test_utils/runner/HistogramWriter.cpp" ]
599        deps += [
600          "//third_party/catapult/tracing/tracing:histogram",
601          "//third_party/catapult/tracing/tracing:reserved_infos",
602        ]
603      }
604
605      if (is_mac) {
606        if (angle_enable_metal) {
607          # On macOS, compiling Metal shader sometimes takes very long time due to internal caching
608          # mechanism. This hooking library is a way to bypass this caching mechanism.
609          data_deps += [ "$angle_root/src/libANGLE/renderer/metal/file_hooking:metal_shader_cache_file_hooking" ]
610        }
611        if (angle_enable_cgl) {
612          configs += [ "$angle_root:supports_automatic_graphics_switching" ]
613        }
614      }
615
616      if (is_linux && !is_chromeos) {
617        use_xvfb = true
618      }
619
620      if ((is_linux || is_chromeos) && !is_component_build) {
621        # Set rpath to find shared libs in a non-component build.
622        configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
623      }
624
625      if (is_android) {
626        public_configs += [ "$angle_root:build_id_config" ]
627        configs -= [ "//build/config/android:hide_all_but_jni" ]
628        use_default_launcher = false
629        generate_final_jni = false
630        if (angle_standalone_benchmark) {
631          android_manifest_template = "$angle_root/src/tests/test_utils/runner/android/java/StandaloneBenchmarkAndroidManifest.xml.jinja2"
632        } else {
633          android_manifest_template = "$angle_root/src/tests/test_utils/runner/android/java/AndroidManifest.xml.jinja2"
634        }
635
636        deps += [
637          "$angle_root/src/tests:native_test_java",
638          "$angle_root/src/tests:native_test_support_android",
639        ]
640      }
641      if (is_ios) {
642        # We use a special main function on iOS to initialize UIKit before the normal main runs.
643        ldflags = [
644          "-e",
645          "_ios_main",
646        ]
647        sources += [ "$angle_root/util/ios/ios_main.mm" ]
648      }
649
650      if (angle_has_build && is_win) {
651        data_deps += [ "//build/win:runtime_libs" ]
652      }
653    }
654  }
655}
656
657if (angle_enable_cl) {
658  # need the llvm build flags
659  import("$angle_clspv_dir/gn/build/llvm_buildflags.gni")
660}
661