• 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  is_ggp = false
9
10  # Extract native libs in ANGLE apk. Useful for flamegraph generation.
11  angle_extract_native_libs = false
12}
13
14if (angle_has_build) {
15  import("//build/config/dcheck_always_on.gni")
16  import("//build/config/sanitizers/sanitizers.gni")
17  import("//build/config/ui.gni")  # import the use_x11 variable
18  import("//build_overrides/build.gni")
19  import("//testing/test.gni")
20  if (is_android) {
21    import("//build/config/android/config.gni")
22  }
23
24  if (is_win) {
25    import("//build/config/win/visual_studio_version.gni")
26  }
27
28  angle_use_x11 = use_x11 && !is_ggp
29} else {
30  declare_args() {
31    is_ubsan = false
32    is_tsan = false
33    is_asan = false
34    build_with_chromium = false
35    dcheck_always_on = false
36    angle_use_x11 = is_linux && !is_ggp
37    use_ozone = false
38    use_fuzzing_engine = false
39  }
40}
41
42if (build_with_chromium) {
43  import("//ui/ozone/ozone.gni")
44} else {
45  declare_args() {
46    ozone_platform_gbm = false
47  }
48}
49
50# Subdirectory to place data files (e.g. layer JSON files).
51angle_data_dir = "angledata"
52
53declare_args() {
54  if (current_cpu == "arm64" || current_cpu == "x64" ||
55      current_cpu == "mips64el" || current_cpu == "s390x" ||
56      current_cpu == "ppc64") {
57    angle_64bit_current_cpu = true
58  } else if (current_cpu == "arm" || current_cpu == "x86" ||
59             current_cpu == "mipsel" || current_cpu == "s390" ||
60             current_cpu == "ppc") {
61    angle_64bit_current_cpu = false
62  } else {
63    assert(false, "Unknown current CPU: $current_cpu")
64  }
65}
66
67declare_args() {
68  if (!is_android) {
69    ndk_api_level_at_least_26 = false
70  } else {
71    ndk_api_level_at_least_26 =
72        (!angle_64bit_current_cpu && android32_ndk_api_level >= 26) ||
73        (angle_64bit_current_cpu && android64_ndk_api_level >= 26)
74  }
75
76  # Vulkan loader is statically linked on Mac. http://anglebug.com/4477
77  angle_shared_libvulkan = !is_mac
78
79  # There's no "is_winuwp" helper in BUILDCONFIG.gn, so we define one ourselves
80  angle_is_winuwp = is_win && current_os == "winuwp"
81
82  # Default to using "_angle" suffix on Android
83  if (is_android) {
84    angle_libs_suffix = "_angle"
85  } else {
86    angle_libs_suffix = ""
87  }
88
89  # Currently Windows on Arm doesn't support OpenGL or Vulkan.
90  is_win_arm64 = is_win && target_cpu == "arm64"
91}
92
93declare_args() {
94  angle_enable_d3d9 = is_win && !angle_is_winuwp
95  angle_enable_d3d11 = is_win
96  angle_enable_gl =
97      (ozone_platform_gbm || !is_linux || (angle_use_x11 && !is_chromeos)) &&
98      !is_fuchsia && !angle_is_winuwp && !is_ggp && !is_win_arm64
99
100  # ANGLE Vulkan backend on Android requires API level 26, i.e. Oreo, due to
101  # Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714.
102  # Otherwise, API level 24 would have been enough.
103  angle_enable_vulkan =
104      angle_has_build && ((is_win && !angle_is_winuwp) ||
105                          (is_linux && angle_use_x11 && !is_chromeos) ||
106                          (is_android && ndk_api_level_at_least_26) ||
107                          is_fuchsia || is_ggp || is_mac)
108  angle_enable_null = true
109  angle_enable_essl = true
110  angle_enable_glsl = true
111
112  # http://anglebug.com/2634
113  angle_enable_metal = is_mac
114}
115
116declare_args() {
117  # Currently SwiftShader's Vulkan front-end doesn't build on Android.
118  # SwiftShader is not needed on Fuchsia because Vulkan is supported on all
119  # devices that run Fuchsia.
120  angle_enable_swiftshader =
121      angle_enable_vulkan && !is_android && !is_fuchsia && !is_ggp
122
123  angle_enable_gl_null = angle_enable_gl
124  angle_enable_hlsl = angle_enable_d3d9 || angle_enable_d3d11
125  angle_enable_trace = false
126
127  # Disable the layers in ubsan builds because of really slow builds.
128  # TODO(anglebug.com/4082) enable validation layers on mac for swiftshader
129  angle_enable_vulkan_validation_layers =
130      angle_enable_vulkan && !is_ubsan && !is_tsan && !is_asan &&
131      (is_debug || dcheck_always_on) && !is_mac
132
133  # Disable overlay by default
134  angle_enable_overlay = false
135}
136
137angle_common_configs = [
138  angle_root + ":angle_release_asserts_config",
139  angle_root + ":better_linux_stack_traces",
140  angle_root + ":constructor_and_destructor_warnings",
141  angle_root + ":extra_warnings",
142  angle_root + ":internal_config",
143]
144
145angle_remove_configs = []
146
147if (angle_has_build) {
148  angle_remove_configs += [ "//build/config/compiler:default_include_dirs" ]
149}
150angle_better_stack_traces =
151    (is_debug || dcheck_always_on) && is_linux && !is_asan && !is_cfi
152
153if (angle_has_build && is_clang) {
154  angle_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
155
156  # Disabled to enable better stack traces.
157  if (angle_better_stack_traces) {
158    # This line causes in-class-inline-functions in glslang to be weak symbols.  The KHR dEQP tests
159    # link against glslang as well as libGLESv2.so, resulting in angle_deqp_khr_gles*_tests to link
160    # those weak symbols.  Due to glslang's usage of a global variable in InitializeDll.cpp, a bug
161    # is created where ANGLE sometimes calls into its own copy of glslang and sometimes the KHR
162    # dEQP's version, with the two copies of the global variable being inconsistent.
163    # Commented out until the underlying issue is resolved.  http://anglebug.com/4123
164    # angle_remove_configs += [ "//build/config/gcc:symbol_visibility_hidden" ]
165  }
166}
167
168set_defaults("angle_executable") {
169  configs = angle_common_configs
170  public_configs = []
171  suppressed_configs = angle_remove_configs
172}
173
174set_defaults("angle_shared_library") {
175  configs = angle_common_configs
176  public_configs = []
177  suppressed_configs = angle_remove_configs
178}
179
180set_defaults("angle_source_set") {
181  configs = angle_common_configs
182  public_configs = []
183  suppressed_configs = angle_remove_configs
184}
185
186set_defaults("angle_static_library") {
187  configs = angle_common_configs
188  public_configs = []
189  suppressed_configs = angle_remove_configs
190}
191
192set_defaults("angle_test") {
193  configs = []
194
195  # Gtest itself can't pass all the strict warning filters.
196  public_configs = angle_common_configs - [
197                     "$angle_root:constructor_and_destructor_warnings",
198                     "$angle_root:extra_warnings",
199                   ]
200
201  public_deps = []
202  sources = []
203  data = []
204  defines = []
205  data_deps = []
206  main = ""
207  suppressed_configs = angle_remove_configs
208
209  # By default use the Chromium harness in Chromium. Can be overriden in a target.
210  standalone_harness = !build_with_chromium
211
212  if (!standalone_harness) {
213    suppressed_configs -= [ "//build/config/compiler:default_include_dirs" ]
214  }
215}
216
217template("angle_executable") {
218  executable(target_name) {
219    forward_variables_from(invoker,
220                           "*",
221                           [
222                             "configs",
223                             "suppressed_configs",
224                             "visibility",
225                           ])
226
227    # Needed because visibility is global.
228    forward_variables_from(invoker, [ "visibility" ])
229
230    configs += invoker.configs
231    configs -= invoker.suppressed_configs
232  }
233}
234
235template("angle_shared_library") {
236  shared_library(target_name) {
237    forward_variables_from(invoker,
238                           "*",
239                           [
240                             "configs",
241                             "suppressed_configs",
242                             "visibility",
243                           ])
244
245    # Needed because visibility is global.
246    forward_variables_from(invoker, [ "visibility" ])
247
248    configs += invoker.configs
249    configs -= invoker.suppressed_configs
250
251    public_configs += [ angle_root + ":shared_library_public_config" ]
252
253    if (is_android) {
254      configs += [ angle_root + ":build_id_config" ]
255      configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
256    }
257  }
258}
259
260template("angle_source_set") {
261  source_set(target_name) {
262    forward_variables_from(invoker,
263                           "*",
264                           [
265                             "configs",
266                             "suppressed_configs",
267                             "visibility",
268                           ])
269
270    # Needed because visibility is global.
271    forward_variables_from(invoker, [ "visibility" ])
272
273    configs += invoker.configs
274    configs -= invoker.suppressed_configs
275  }
276}
277
278template("angle_static_library") {
279  static_library(target_name) {
280    forward_variables_from(invoker,
281                           "*",
282                           [
283                             "configs",
284                             "suppressed_configs",
285                             "visibility",
286                           ])
287
288    # Needed because visibility is global.
289    forward_variables_from(invoker, [ "visibility" ])
290
291    configs += invoker.configs
292    configs -= invoker.suppressed_configs
293  }
294}
295
296template("angle_test") {
297  _lib = target_name + "_lib"
298  angle_source_set(_lib) {
299    testonly = true
300    forward_variables_from(invoker,
301                           "*",
302                           [
303                             "deps",
304                             "manifest",
305                           ])
306
307    if (is_android) {
308      public_configs += [ "$angle_root:build_id_config" ]
309    }
310
311    public_deps += invoker.deps + [
312                     "$angle_root:angle_common",
313                     "$angle_root:includes",
314                     "$angle_root/third_party/rapidjson:rapidjson",
315                     "$angle_root/util:angle_test_utils",
316                     "//testing/gmock",
317                     "//testing/gtest",
318                     "//third_party/googletest:gmock",
319                     "//third_party/googletest:gtest",
320                   ]
321
322    sources += [
323      "$angle_root/src/tests/test_utils/runner/TestSuite.cpp",
324      "$angle_root/src/tests/test_utils/runner/TestSuite.h",
325    ]
326  }
327
328  # To use the Chromium test infrastructure we must currently use the //base test launcher.
329  # Eventually we could switch to using standalone testing. See http://crbug.com/837741
330  # TODO(jmadill): Clean up duplication as part of http://anglebug.com/3152
331
332  _standalone_harness_test_name = target_name
333
334  if (build_with_chromium) {
335    _standalone_harness_test_name = "standalone_" + target_name
336    test(target_name) {
337      public_deps = [ ":${_lib}" ]
338      if (invoker.main != "") {
339        sources = [ "//gpu/${invoker.main}.cc" ]
340      }
341      deps = [ "//base/test:test_support" ]
342      if (is_android) {
343        configs -= [ "//build/config/android:hide_all_but_jni" ]
344      }
345
346      if (is_linux && !is_component_build) {
347        # Set rpath to find shared libs in a non-component build.
348        configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
349      }
350
351      if (defined(invoker.manifest)) {
352        manifest = invoker.manifest
353      }
354
355      if (is_android) {
356        use_native_activity = true
357      }
358    }
359  }
360
361  test(_standalone_harness_test_name) {
362    public_deps = [ ":${_lib}" ]
363    if (invoker.main != "") {
364      sources = [ "${invoker.main}.cpp" ]
365    }
366    data = invoker.data + [ "//testing/xvfb.py" ]
367
368    if (is_linux && !is_component_build) {
369      # Set rpath to find shared libs in a non-component build.
370      configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
371    }
372
373    if (defined(invoker.manifest)) {
374      manifest = invoker.manifest
375    }
376
377    if (is_android) {
378      if (build_with_chromium) {
379        use_native_activity = true
380      } else {
381        use_raw_android_executable = true
382      }
383    }
384  }
385}
386