• 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("${skia_root_dir}/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
24if (angle_has_build) {
25  import("${skia_root_dir}/build/config/dcheck_always_on.gni")
26  import("${skia_root_dir}/build/config/ozone.gni")  # import the ozone_platform_x11 variable
27  import("${skia_root_dir}/build/config/sanitizers/sanitizers.gni")
28  import("${skia_root_dir}/build_overrides/build.gni")
29  import("${skia_root_dir}/testing/test.gni")
30  if (is_android) {
31    import("${skia_root_dir}/build/config/android/config.gni")
32  }
33
34  if (is_win) {
35    import("${skia_root_dir}/build/config/win/visual_studio_version.gni")
36  }
37
38  if (is_chromecast || ozone_platform_headless) {
39    angle_vulkan_display_mode = "headless"
40  }
41
42  angle_use_x11 = ozone_platform_x11 && !is_ggp && is_linux && !is_chromecast
43  angle_use_vulkan_display = is_linux && !is_ggp
44} else {
45  declare_args() {
46    is_ubsan = false
47    is_tsan = false
48    is_asan = false
49    is_lsan = false
50    build_with_chromium = false
51    dcheck_always_on = false
52    angle_use_x11 = (is_linux || is_chromeos) && !is_ggp
53    use_ozone = false
54    ozone_platform_gbm = false
55    ozone_platform_wayland = false
56    ozone_platform_headless = false
57    use_fuzzing_engine = false
58    is_apple = is_mac || is_ios
59  }
60
61  declare_args() {
62    angle_use_vulkan_display = is_linux && !is_ggp
63  }
64}
65
66# Subdirectory to place data files (e.g. layer JSON files).
67angle_data_dir = "angledata"
68
69declare_args() {
70  angle_assert_always_on = dcheck_always_on
71
72  if (current_cpu == "arm64" || current_cpu == "x64" ||
73      current_cpu == "mips64el" || current_cpu == "s390x" ||
74      current_cpu == "ppc64") {
75    angle_64bit_current_cpu = true
76  } else if (current_cpu == "arm" || current_cpu == "x86" ||
77             current_cpu == "mipsel" || current_cpu == "s390" ||
78             current_cpu == "ppc") {
79    angle_64bit_current_cpu = false
80  } else {
81    assert(false, "Unknown current CPU: $current_cpu")
82  }
83
84  # Indicate if the rapidJSON library is available to build with in third_party/.
85  angle_has_rapidjson = angle_has_build
86}
87
88declare_args() {
89  # By default we enable debug layers when asserts are turned on.
90  angle_debug_layers_enabled = is_debug || angle_assert_always_on
91
92  if (!is_android) {
93    ndk_api_level_at_least_26 = false
94  } else {
95    ndk_api_level_at_least_26 =
96        (!angle_64bit_current_cpu && android32_ndk_api_level >= 26) ||
97        (angle_64bit_current_cpu && android64_ndk_api_level >= 26)
98  }
99
100  # Vulkan loader is statically linked on Mac. http://anglebug.com/4477
101  angle_shared_libvulkan = !is_mac
102
103  # There's no "is_winuwp" helper in BUILDCONFIG.gn, so we define one ourselves
104  angle_is_winuwp = is_win && target_os == "winuwp"
105
106  # Default to using "_angle" suffix on Android
107  if (is_android) {
108    angle_libs_suffix = "_angle"
109  } else {
110    angle_libs_suffix = ""
111  }
112
113  # Currently Windows on Arm doesn't support OpenGL or Vulkan.
114  is_win_arm64 = is_win && target_cpu == "arm64"
115
116  # Frame capture code is enabled by default if rapidjson is available.
117  angle_has_frame_capture = angle_has_rapidjson
118}
119
120declare_args() {
121  # By default, ANGLE is using a thread pool for parallel compilation.
122  # Activating the delegate worker results in posting the tasks using the
123  # embedder API. In Chromium code base, it results in sending tasks to the
124  # worker thread pool.
125  angle_delegate_workers = build_with_chromium
126
127  # True if we are building inside an ANGLE checkout.
128  angle_standalone = !build_with_chromium
129
130  angle_enable_d3d9 = is_win && !angle_is_winuwp
131  angle_enable_d3d11 = is_win
132  angle_enable_gl = (ozone_platform_gbm || ozone_platform_wayland ||
133                     !is_linux || (angle_use_x11 && !is_chromeos)) &&
134                    !is_fuchsia && !angle_is_winuwp && !is_ggp && !is_win_arm64
135
136  angle_enable_vulkan =
137      angle_has_build &&
138      !(is_android && build_with_chromium && is_official_build) &&
139      ((is_win && !angle_is_winuwp) ||
140       (is_linux && (angle_use_x11 || angle_use_vulkan_display) &&
141        !is_chromeos) || is_android || is_fuchsia || is_ggp || is_mac)
142
143  # When set to true, ANGLE will not use VK_KHR_surface and VK_KHR_swapchain
144  # extensions. Content can be rendered only off-screen.
145  angle_use_vulkan_null_display = build_with_chromium && is_fuchsia
146
147  # Disable null backend to save space for official build.
148  angle_enable_null = !is_official_build
149  angle_enable_gl_desktop = !is_android && !is_ios
150
151  # http://anglebug.com/2634
152  angle_enable_metal = is_mac
153
154  # Enables the OpenCL pass-through back end
155  angle_enable_cl_passthrough = angle_enable_cl
156}
157
158# OpenCL is not supported on Windows UWP, because the CL headers include DX9, which is not
159# supported by UWP. A workaround might be possible if CL support on UWP is required.
160assert(!angle_is_winuwp || !angle_enable_cl,
161       "OpenCL is not supported on Windows UWP")
162
163if (!angle_enable_cl) {
164  angle_enable_cl_passthrough = false
165}
166
167declare_args() {
168  # Currently SwiftShader's Vulkan front-end doesn't build on Android.
169  # Disabled by default on MSVC because of compiler warnings/errors.
170  angle_enable_swiftshader =
171      angle_enable_vulkan && !is_android && !is_ggp && is_clang
172
173  # Translator frontend support:
174  angle_enable_desktop_glsl = angle_enable_gl_desktop
175
176  # Translator backend support:
177  angle_enable_hlsl = angle_enable_d3d9 || angle_enable_d3d11
178  angle_enable_essl = angle_enable_gl || use_ozone
179  angle_enable_glsl = angle_enable_gl || use_ozone
180  angle_enable_trace = false
181  angle_enable_trace_android_logcat = false
182
183  # Disable the layers in ubsan builds because of really slow builds.
184  # Vulkan Validation Layers require Android NDK API level 26, i.e. Oreo, due to
185  # Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714.
186  angle_enable_vulkan_validation_layers =
187      angle_enable_vulkan && !is_ubsan && !is_tsan && !is_asan &&
188      angle_debug_layers_enabled && (!is_android || ndk_api_level_at_least_26)
189
190  # Support using glslang to generate SPIR-V for the time being for the purpose of debugging
191  # the SPIR-V generation path, but leave it disabled on release.  It's still used by the metal
192  # backend nevertheless.
193  angle_enable_spirv_gen_through_glslang =
194      is_debug || angle_assert_always_on || angle_enable_metal
195
196  # ISpriteVisual windows cannot be validated and can lead to crashes if an invalid window is
197  # provided to ANGLE. Disable them for non-standalone ANGLE builds. crbug.com/1176118
198  angle_enable_d3d11_compositor_native_window =
199      angle_enable_d3d11 && angle_standalone
200
201  # Disable overlay by default
202  angle_enable_overlay = false
203
204  # Disable performance counter output by default
205  angle_enable_perf_counter_output = false
206
207  # We should use EAGL (ES) on iOS except on Mac Catalyst on Intel CPUs, which uses CGL (desktop GL).
208  angle_enable_eagl = angle_enable_gl && is_ios &&
209                      !(target_environment == "catalyst" &&
210                        (target_cpu == "x86" || target_cpu == "x64"))
211
212  angle_vulkan_headers_dir =
213      "$angle_root/third_party/vulkan-deps/vulkan-headers/src"
214  angle_vulkan_loader_dir =
215      "$angle_root/third_party/vulkan-deps/vulkan-loader/src"
216  angle_vulkan_tools_dir =
217      "$angle_root/third_party/vulkan-deps/vulkan-tools/src"
218  angle_vulkan_validation_layers_dir =
219      "$angle_root/third_party/vulkan-deps/vulkan-validation-layers/src"
220
221  angle_build_vulkan_system_info =
222      !is_chromeos && angle_has_build && !angle_is_winuwp
223}
224
225declare_args() {
226  # TODO(jdarpinian): Support enabling CGL and EAGL at the same time using the soft linking code. Also support disabling both for Metal-only builds.
227  angle_enable_cgl = angle_enable_gl && !angle_enable_eagl && is_apple
228
229  angle_enable_apple_translator_workarounds =
230      is_apple &&
231      (angle_enable_glsl || angle_enable_metal || use_fuzzing_engine)
232
233  angle_has_histograms = angle_has_build
234}
235
236if (!defined(angle_zlib_compression_utils_dir)) {
237  angle_zlib_compression_utils_dir = "${skia_third_party_dir}/zlib/google"
238}
239
240angle_common_configs = [
241  angle_root + ":angle_asserts_config",
242  angle_root + ":constructor_and_destructor_warnings",
243  angle_root + ":extra_warnings",
244  angle_root + ":internal_config",
245  angle_root + ":angle_uwp_env",
246]
247
248angle_remove_configs = []
249
250if (angle_has_build) {
251  angle_remove_configs += [ "${skia_root_dir}/build/config/compiler:default_include_dirs" ]
252}
253
254if (angle_has_build && is_clang) {
255  angle_remove_configs += [ "${skia_root_dir}/build/config/clang:find_bad_constructs" ]
256}
257
258set_defaults("angle_executable") {
259  configs = angle_common_configs
260  public_configs = []
261  suppressed_configs = angle_remove_configs
262  data_deps = []
263}
264
265set_defaults("angle_shared_library") {
266  configs = angle_common_configs
267  public_configs = []
268  suppressed_configs = angle_remove_configs
269}
270
271set_defaults("angle_source_set") {
272  configs = angle_common_configs
273  public_configs = []
274  suppressed_configs = angle_remove_configs
275}
276
277set_defaults("angle_static_library") {
278  configs = angle_common_configs
279  public_configs = []
280  suppressed_configs = angle_remove_configs
281}
282
283set_defaults("angle_test") {
284  # Gtest itself can't pass all the strict warning filters.
285  configs = angle_common_configs - [
286              "$angle_root:constructor_and_destructor_warnings",
287              "$angle_root:extra_warnings",
288            ] + [ "$angle_root/src/tests:angle_maybe_has_histograms" ]
289
290  public_configs = []
291  public_deps = []
292  sources = []
293  data = []
294  defines = []
295  deps = []
296  data_deps = []
297  suppressed_configs = angle_remove_configs
298}
299
300template("angle_executable") {
301  executable(target_name) {
302    forward_variables_from(invoker,
303                           "*",
304                           [
305                             "configs",
306                             "suppressed_configs",
307                             "visibility",
308                           ])
309
310    # Needed because visibility is global.
311    forward_variables_from(invoker, [ "visibility" ])
312
313    configs += invoker.configs
314    configs -= invoker.suppressed_configs
315
316    if (angle_has_build && is_win) {
317      data_deps += [ "${skia_root_dir}/build/win:runtime_libs" ]
318    }
319  }
320}
321
322template("angle_shared_library") {
323  # On ios, define an ios_framework_bundle instead of a shared library.
324  # ios_framework_bundle doesn't automatically link, so we have to create
325  # a group that links and bundles the framework as well.
326  target_type = "shared_library"
327  internal_target_name = target_name
328  if (is_ios) {
329    target_type = "ios_framework_bundle"
330    internal_target_name = target_name + "_framework"
331  }
332  target(target_type, internal_target_name) {
333    forward_variables_from(invoker,
334                           "*",
335                           [
336                             "configs",
337                             "suppressed_configs",
338                             "visibility",
339                           ])
340
341    # Needed because visibility is global.
342    forward_variables_from(invoker, [ "visibility" ])
343
344    configs += invoker.configs
345    configs -= invoker.suppressed_configs
346
347    public_configs += [ angle_root + ":shared_library_public_config" ]
348
349    if (is_android) {
350      configs += [ angle_root + ":build_id_config" ]
351      configs -= [ "${skia_root_dir}/build/config/android:hide_all_but_jni_onload" ]
352    }
353    if (is_ios) {
354      info_plist = "$angle_root/util/ios/Info.plist"
355
356      # shared libraries are hidden inside ios_framework_bundle, but we include headers from them
357      # Specifically, libGLESv1_CM includes headers from libGLESv2
358      check_includes = false
359    }
360  }
361  if (is_ios) {
362    group(target_name) {
363      forward_variables_from(invoker,
364                             [
365                               "testonly",
366                               "visibility",
367                             ])
368      public_deps = [
369        ":${internal_target_name}+bundle",
370        ":${internal_target_name}+link",
371      ]
372    }
373  }
374}
375
376template("angle_source_set") {
377  source_set(target_name) {
378    forward_variables_from(invoker,
379                           "*",
380                           [
381                             "configs",
382                             "suppressed_configs",
383                             "visibility",
384                           ])
385
386    # Needed because visibility is global.
387    forward_variables_from(invoker, [ "visibility" ])
388
389    configs += invoker.configs
390    configs -= invoker.suppressed_configs
391  }
392}
393
394template("angle_static_library") {
395  static_library(target_name) {
396    forward_variables_from(invoker,
397                           "*",
398                           [
399                             "configs",
400                             "suppressed_configs",
401                             "visibility",
402                           ])
403
404    # Needed because visibility is global.
405    forward_variables_from(invoker, [ "visibility" ])
406
407    configs += invoker.configs
408    configs -= invoker.suppressed_configs
409  }
410}
411
412if (angle_standalone || build_with_chromium) {
413  template("angle_test") {
414    test(target_name) {
415      forward_variables_from(invoker,
416                             "*",
417                             [
418                               "configs",
419                               "data",
420                               "public_deps",
421                             ])
422
423      configs += invoker.configs
424      configs -= invoker.suppressed_configs
425
426      if (is_ios) {
427        # shared libraries are hidden inside ios_framework_bundle, but we include headers from them
428        check_includes = false
429      }
430
431      public_deps = invoker.public_deps + [
432                      "$angle_root:angle_common",
433                      "$angle_root:includes",
434                      "$angle_root/src/tests:angle_test_expectations",
435                      "$angle_root/third_party/rapidjson:rapidjson",
436                      "$angle_root/util:angle_test_utils",
437                      "${skia_root_dir}/testing/gmock",
438                      "${skia_root_dir}/testing/gtest",
439                      "${skia_third_party_dir}/googletest:gmock",
440                      "${skia_third_party_dir}/googletest:gtest",
441                    ]
442
443      data = invoker.data + [
444               "$angle_root/scripts/run_gtest_angle_test.py",
445               "${skia_root_dir}/testing/scripts/common.py",
446               "${skia_root_dir}/testing/xvfb.py",
447             ]
448
449      sources += [
450        "$angle_root/src/tests/test_utils/runner/HistogramWriter.h",
451        "$angle_root/src/tests/test_utils/runner/TestSuite.cpp",
452        "$angle_root/src/tests/test_utils/runner/TestSuite.h",
453      ]
454
455      if (angle_has_histograms) {
456        sources +=
457            [ "$angle_root/src/tests/test_utils/runner/HistogramWriter.cpp" ]
458        deps += [
459          "${skia_third_party_dir}/catapult/tracing/tracing:histogram",
460          "${skia_third_party_dir}/catapult/tracing/tracing:reserved_infos",
461        ]
462      }
463
464      if (is_mac && angle_enable_metal) {
465        # On macOS, compiling Metal shader sometimes takes very long time due to internal caching
466        # mechanism. This hooking library is a way to bypass this caching mechanism.
467        data_deps += [ "$angle_root/src/libANGLE/renderer/metal/file_hooking:metal_shader_cache_file_hooking" ]
468      }
469
470      if ((is_linux && !is_chromeos) ||
471          (build_with_chromium && is_chromeos_lacros && !is_chromeos_device)) {
472        use_xvfb = true
473      }
474
475      if ((is_linux || is_chromeos) && !is_component_build) {
476        # Set rpath to find shared libs in a non-component build.
477        configs += [ "${skia_root_dir}/build/config/gcc:rpath_for_built_shared_libraries" ]
478      }
479
480      if (is_android) {
481        public_configs += [ "$angle_root:build_id_config" ]
482        configs -= [ "${skia_root_dir}/build/config/android:hide_all_but_jni" ]
483        use_default_launcher = false
484        generate_final_jni = false
485        android_manifest_template = "$angle_root/src/tests/test_utils/runner/android/java/AndroidManifest.xml.jinja2"
486        deps += [
487          "$angle_root/src/tests:native_test_java",
488          "$angle_root/src/tests:native_test_support_android",
489        ]
490      }
491      if (is_ios) {
492        # We use a special main function on iOS to initialize UIKit before the normal main runs.
493        ldflags = [
494          "-e",
495          "_ios_main",
496        ]
497        sources += [ "$angle_root/util/ios/ios_main.mm" ]
498      }
499
500      if (angle_has_build && is_win) {
501        data_deps += [ "${skia_root_dir}/build/win:runtime_libs" ]
502      }
503    }
504  }
505}
506
507# Used by a few targets that compile traces.
508template("angle_trace_fixture") {
509  _config_name = target_name + "_config"
510  config(_config_name) {
511    include_dirs = [ "$angle_root/src/libANGLE/capture" ]
512  }
513  angle_source_set(target_name) {
514    testonly = true
515    defines = [ "ANGLE_REPLAY_IMPLEMENTATION" ]
516    suppressed_configs += [ "$angle_root:constructor_and_destructor_warnings" ]
517    sources = [
518      "$angle_root/src/libANGLE/capture/trace_fixture.cpp",
519      "$angle_root/src/libANGLE/capture/trace_fixture.h",
520      invoker.gl_header,
521    ]
522    public_deps = [ "$angle_root:includes" ]
523    if (defined(invoker.public_deps)) {
524      public_deps += invoker.public_deps
525    }
526    include_dirs = [ "." ]
527    public_configs = [ ":${_config_name}" ]
528    if (defined(invoker.public_configs)) {
529      public_configs += invoker.public_configs
530    }
531    if (is_ios) {
532      # shared libraries are hidden inside ios_framework_bundle, but we include headers from them
533      check_includes = false
534    }
535  }
536}
537
538template("angle_trace") {
539  _trace_prefix = invoker.trace_prefix
540  angle_shared_library(target_name) {
541    testonly = true
542
543    # Similar to capture replay sample, use the file index for sources
544    sources = [
545                "${_trace_prefix}.cpp",
546                "${_trace_prefix}.h",
547              ] + invoker.sources
548
549    # TODO(http://anglebug.com/5133): Revert back to non-autogen'ed data.
550    data = invoker.data
551    defines = [ "ANGLE_REPLAY_IMPLEMENTATION" ]
552    suppressed_configs += [ "$angle_root:constructor_and_destructor_warnings" ]
553
554    deps = [
555      "$angle_root:includes",
556      invoker.fixture,
557    ]
558
559    if (is_android) {
560      libs = [ "log" ]
561    }
562
563    # Disable optimization in the trace perf tests to avoid optimizing huge files.
564    if (!is_debug && !is_ubsan) {
565      suppressed_configs += [
566        "${skia_root_dir}/build/config/compiler:afdo",
567        "${skia_root_dir}/build/config/compiler:afdo_optimize_size",
568        "${skia_root_dir}/build/config/compiler:default_optimization",
569        "${skia_root_dir}/build/config/compiler/pgo:default_pgo_flags",
570      ]
571      configs += [ "${skia_root_dir}/build/config/compiler:no_optimize" ]
572    }
573
574    include_dirs = [ "." ]
575
576    if (defined(invoker.output_name)) {
577      output_name = invoker.output_name
578    }
579  }
580
581  angle_source_set(target_name + "_headers") {
582    sources = [ "${_trace_prefix}.h" ]
583  }
584}
585