BUILD.gn 39.7 KB
Newer Older
1
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
2
3
4
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Antonio Caggiano's avatar
Antonio Caggiano committed
5
6
import("//build_overrides/wayland.gni")

7
# import the ozone_platform_x11 variable
Frank Henigman's avatar
Frank Henigman committed
8
import("gni/angle.gni")
9
10
11
if (angle_enable_vulkan) {
  import("//build_overrides//vulkan_headers.gni")
}
12
13
if (angle_has_build) {
  import("//build/config/linux/pkg_config.gni")
14
  import("//build/config/sanitizers/sanitizers.gni")
15
16
17
18
19
20
21
22
23
  import("//build/config/ui.gni")
  import("//testing/libfuzzer/fuzzer_test.gni")

  if (is_android) {
    # android/rules.gni can only be imported for Android targets
    import("//build/config/android/config.gni")
    import("//build/config/android/rules.gni")
    import("android/angle_apk.gni")
  }
24
25
} else {
  using_sanitizer = false
26
}
27

28
29
declare_args() {
  # Use the PCI lib to collect GPU information on Linux.
30
31
  use_libpci = (is_linux || is_chromeos) && (angle_use_x11 || use_ozone) &&
               angle_has_build
32

33
34
35
  # Enable using Vulkan to collect system info as a fallback.
  angle_enable_vulkan_system_info = false

36
37
  # Link in system libGL, to work with apitrace.  See doc/DebuggingTips.md.
  angle_link_glx = false
38

39
40
  # Don't build extra (test, samples etc) for Windows UWP. We don't have
  # infrastructure (e.g. windowing helper functions) in place to run them.
Jamie Madill's avatar
Jamie Madill committed
41
42
  angle_build_all = !build_with_chromium && !angle_is_winuwp &&
                    angle_has_build && angle_build_tests
43
44
45

  # Enable generating current commit information using git
  angle_enable_commit_id = true
46
47
48
49

  # Abseil has trouble supporting MSVC, particularly regarding component builds.
  # http://crbug.com/1126524
  angle_enable_abseil = angle_has_build && is_clang
50
51
52

  # Adds run-time checks to filter out EVENT() messages when the debug annotator is disabled.
  angle_enable_annotator_run_time_checks = false
53
54
55

  # Enables non-conformant extensions and features
  angle_expose_non_conformant_extensions_and_versions = false
56
57
58

  # Optional feature that forces dirty state whenever we use a new context regardless of thread.
  angle_force_context_check_every_call = false
59
60
61
62

  # Allow shared library custom name extensions for setting soname such as libEGL.so.1
  angle_egl_extension = ""
  angle_glesv2_extension = ""
63
64
}

Jamie Madill's avatar
Jamie Madill committed
65
if (angle_build_all) {
Frank Henigman's avatar
Frank Henigman committed
66
67
68
  group("all") {
    testonly = true
    deps = [
Jamie Madill's avatar
Jamie Madill committed
69
      ":angle",
Frank Henigman's avatar
Frank Henigman committed
70
71
      ":angle_shader_translator",
      ":translator_fuzzer",
Jamie Madill's avatar
Jamie Madill committed
72
      ":xxhash_fuzzer",
Jamie Madill's avatar
Jamie Madill committed
73
74
      "$angle_root/samples:angle_samples",
      "$angle_root/src/tests:angle_tests",
Frank Henigman's avatar
Frank Henigman committed
75
    ]
John Plate's avatar
John Plate committed
76
77
78
    if (angle_enable_cl) {
      deps += [ "$angle_root/src/libOpenCL:angle_cl" ]
    }
Frank Henigman's avatar
Frank Henigman committed
79
80
81
  }
}

82
import("src/compiler.gni")
83
import("src/libGLESv2.gni")
84

85
86
87
# This config is exported to dependent targets (and also applied to internal
# ones).
config("external_config") {
Jamie Madill's avatar
Jamie Madill committed
88
  include_dirs = [ "include" ]
89
90
}

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Prevent the GL headers from redeclaring ANGLE entry points.
config("no_gl_prototypes") {
  defines = [
    "GL_GLES_PROTOTYPES=0",
    "EGL_EGL_PROTOTYPES=0",
  ]
}

config("gl_prototypes") {
  defines = [
    "GL_GLES_PROTOTYPES=1",
    "EGL_EGL_PROTOTYPES=1",
    "GL_GLEXT_PROTOTYPES",
    "EGL_EGLEXT_PROTOTYPES",
  ]
}

108
109
110
111
112
113
# This config is applied to internal Angle targets (not pushed to dependents).
config("internal_config") {
  include_dirs = [
    "include",
    "src",
  ]
114

115
  defines = []
Jamie Madill's avatar
Jamie Madill committed
116

117
118
  if (is_win) {
    defines += [ "ANGLE_IS_WIN" ]
119
120
121
    if (angle_is_winuwp) {
      defines += [ "ANGLE_IS_WINUWP" ]
    }
122
  } else if (is_linux || is_chromeos) {
123
124
125
    defines += [ "ANGLE_IS_LINUX" ]
  }

126
127
128
  # Enables debug/trace-related functionality, including logging every GLES/EGL API command to the
  # "angle_debug.txt" file on desktop.  Enables debug markers for AGI, but must also set
  # angle_enable_annotator_run_time_checks to improve performance.
Tobin Ehlis's avatar
Tobin Ehlis committed
129
130
131
  if (angle_enable_trace) {
    defines += [ "ANGLE_ENABLE_DEBUG_TRACE=1" ]
  }
132

133
134
135
136
137
138
  # When used with angle_enable_trace, enables logging every GLES/EGL API command to Android logcat
  # Enables debug markers for AGI regardless of run-time checks.
  if (angle_enable_trace_android_logcat) {
    defines += [ "ANGLE_ENABLE_TRACE_ANDROID_LOGCAT=1" ]
  }

139
140
141
142
143
  # When used with angle_enable_trace, enables logging every GLES/EGL API command to the terminal
  if (angle_enable_trace_events) {
    defines += [ "ANGLE_ENABLE_TRACE_EVENTS=1" ]
  }

144
145
146
  if (is_chromeos) {
    defines += [ "ANGLE_PLATFORM_CHROMEOS" ]
  }
147
148
149
150

  if (is_ggp) {
    defines += [ "__ggp__" ]
  }
151

152
153
154
  if (angle_use_vulkan_null_display) {
    defines += [ "ANGLE_USE_VULKAN_NULL_DISPLAY" ]
  } else if (angle_use_vulkan_display) {
155
156
157
158
    defines += [ "ANGLE_USE_VULKAN_DISPLAY" ]
    if (!angle_use_x11) {
      defines += [ "EGL_NO_X11" ]
    }
159
160
161
162
163
164
165
166
167

    # These two are needed here to correctly select OSWindow::New
    if (angle_use_x11) {
      defines += [ "ANGLE_USE_X11" ]
    }
    if (angle_use_wayland) {
      defines += [ "ANGLE_USE_WAYLAND" ]
    }

168
169
170
171
172
173
    if (angle_vulkan_display_mode == "simple") {
      defines += [ "ANGLE_VULKAN_DISPLAY_MODE_SIMPLE" ]
    } else if (angle_vulkan_display_mode == "headless") {
      defines += [ "ANGLE_VULKAN_DISPLAY_MODE_HEADLESS" ]
    }
  }
174
175
176
177

  if (is_lsan) {
    defines += [ "ANGLE_WITH_LSAN" ]
  }
178
179
}

180
181
182
183
184
185
186
187
188
config("constructor_and_destructor_warnings") {
  if (is_clang) {
    cflags = [
      "-Wexit-time-destructors",
      "-Wglobal-constructors",
    ]
  }
}

Jamie Madill's avatar
Jamie Madill committed
189
config("extra_warnings") {
190
  cflags = []
Frank Henigman's avatar
Frank Henigman committed
191

192
193
  is_gcc = !is_clang && !is_win

194
195
196
197
198
  # Avoid failing builds for warnings enabled by Skia build.
  if (defined(is_skia_standalone)) {
    cflags += [ "-w" ]
  }

Jamie Madill's avatar
Jamie Madill committed
199
200
  # Enable more default warnings on Windows.
  if (is_win) {
201
    cflags += [
Jamie Madill's avatar
Jamie Madill committed
202
      "/we4244",  # Conversion: possible loss of data.
Jamie Madill's avatar
Jamie Madill committed
203
      "/we4312",  # Conversion: greater size.
Jamie Madill's avatar
Jamie Madill committed
204
      "/we4456",  # Variable shadowing.
205
      "/we4458",  # declaration hides class member.
206
      "/we4715",  # not all control paths return a value
207
208
      "/we4800",  # forcing value to bool.
      "/we4838",  # narrowing conversion.
Jamie Madill's avatar
Jamie Madill committed
209
210
    ]
  }
211
  if (is_clang) {
212
    cflags += [
Jamie Madill's avatar
Jamie Madill committed
213
      "-Wbad-function-cast",
214
      "-Wconditional-uninitialized",
Jamie Madill's avatar
Jamie Madill committed
215
      "-Wextra-semi-stmt",
216
      "-Wfloat-conversion",
217
      "-Winconsistent-missing-destructor-override",
218
      "-Wmissing-field-initializers",
Stuart Morgan's avatar
Stuart Morgan committed
219
      "-Wnewline-eof",
220
      "-Wnon-virtual-dtor",
Jamie Madill's avatar
Jamie Madill committed
221
      "-Wredundant-parens",
222
      "-Wreturn-std-move",
Jamie Madill's avatar
Jamie Madill committed
223
      "-Wshadow",
Jamie Madill's avatar
Jamie Madill committed
224
      "-Wshadow-field",
225
      "-Wtautological-type-limit-compare",
226
      "-Wundefined-reinterpret-cast",
227
      "-Wunneeded-internal-declaration",
228
      "-Wunused-but-set-variable",
229
230
      "-Wsuggest-destructor-override",
      "-Wsuggest-override",
231
232
233
234
235
236

      # The below warnings are used by WebKit. We enable them to make rolling
      # ANGLE in WebKit easier.
      "-Wparentheses",
      "-Wrange-loop-analysis",
      "-Wstrict-prototypes",
237
      "-Wunreachable-code-aggressive",
James Darpinian's avatar
James Darpinian committed
238
      "-Wshorten-64-to-32",
239
    ]
240
  }
241

242
243
244
245
  if (is_gcc) {
    cflags_cc = [ "-Wdeprecated-copy" ]
  }

246
  if (angle_is_winuwp) {
angle-autoroll's avatar
angle-autoroll committed
247
248
249
250
    cflags += [
      "/wd4091",  # keyword ignored on left of type when no variable is declared
      "/wd4447",  # 'main' signature found without threading model.
    ]
251
  }
Jamie Madill's avatar
Jamie Madill committed
252
253
}

254
255
256
257
258
259
260
261
262
# This config adds build-ids to the associated library.
# -Wl is a special option that indicates that clang should pass the associated
# option --build-id to the linker. This will cause a build-id section to be added
# to the associated library. The build-id makes it possible for a debugger to
# find the right symbol file to use.
config("build_id_config") {
  ldflags = [ "-Wl,--build-id" ]
}

263
264
_use_copy_compiler_dll = angle_has_build && is_win && target_cpu != "arm64"

265
266
# Windows ARM64 is available since 10.0.16299 so no need to copy
# d3dcompiler_47.dll because this file is available as inbox.
267
if (_use_copy_compiler_dll) {
268
269
270
271
272
273
  # We also ship an older DLL for compatiblity with Windows 7 machines without
  # the UCRT. This DLL isn't available in the standard SDK distribution.
  _old_compiler = "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_old.dll"
  _has_old_compiler =
      exec_script("scripts/file_exists.py", [ _old_compiler ], "value")

274
  copy("copy_compiler_dll") {
275
    sources = [ "$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll" ]
276
277
278
279
280

    if (_has_old_compiler) {
      sources += [ _old_compiler ]
    }

281
    outputs = [ "$root_out_dir/{{source_file_part}}" ]
282
283
284
  }
}

Jamie Madill's avatar
Jamie Madill committed
285
# Holds the shared includes so we only need to list them once.
286
287
288
289
config("includes_config") {
  include_dirs = [ "include" ]
}

290
291
292
293
294
295
config("angle_uwp_env") {
  if (angle_is_winuwp) {
    defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ]
  }
}

John Plate's avatar
John Plate committed
296
297
angle_source_set("cl_includes") {
  sources = cl_includes
298
  public_configs = [ ":external_config" ]
John Plate's avatar
John Plate committed
299
300
}

301
angle_source_set("includes") {
302
  sources = libangle_includes
303
  public_configs = [ ":includes_config" ]
John Plate's avatar
John Plate committed
304
305
306
  if (angle_enable_cl) {
    public_deps = [ ":cl_includes" ]
  }
307
308
}

309
310
311
312
313
314
config("disable_unreachable_code_break_warning") {
  if (is_clang) {
    cflags = [ "-Wno-unreachable-code-break" ]
  }
}

315
angle_static_library("preprocessor") {
316
  sources = angle_preprocessor_sources
317

318
319
320
  # preprocessor_tab_autogen.cpp contains an instance of this.
  configs += [ ":disable_unreachable_code_break_warning" ]

321
322
  public_deps = [
    ":angle_common",
323
    ":angle_translator_headers",
324
  ]
325
326
}

327
328
config("angle_disable_pool_alloc") {
  defines = [ "ANGLE_DISABLE_POOL_ALLOC" ]
329
330
}

331
config("debug_annotations_config") {
332
  defines = []
333
  if (is_debug) {
334
    defines += [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
335
  }
336
  if (angle_enable_annotator_run_time_checks) {
337
338
    # When used with angle_enable_trace, enables debug markers for AGI with run-time checks to
    # filter out EVENT() messages when the debug annotator is disabled.
339
    defines += [ "ANGLE_ENABLE_ANNOTATOR_RUN_TIME_CHECKS" ]
340
  }
341
342
}

343
344
345
config("angle_asserts_config") {
  if (angle_assert_always_on) {
    defines = [ "ANGLE_ASSERT_ALWAYS_ON" ]
Jamie Madill's avatar
Jamie Madill committed
346
347
348
  }
}

349
config("angle_common_config") {
Jamie Madill's avatar
Jamie Madill committed
350
  include_dirs = [ "src/common/third_party/base" ]
Yuly Novikov's avatar
Yuly Novikov committed
351
352
353
  if (is_android) {
    libs = [ "log" ]
  }
354
355
}

356
357
358
359
360
361
362
363
364
365
366
367
368
369
# Silences the "indirect call of a function with wrong dynamic type" cfi error
config("angle_no_cfi_icall") {
  if (is_cfi && use_cfi_icall && current_toolchain == default_toolchain) {
    cflags = [ "-fno-sanitize=cfi-icall" ]
  }
}

# Silences the "cast from void* or another unrelated type to the wrong dynamic type" cfi error
config("angle_no_cfi_unrelated_cast") {
  if (is_cfi && use_cfi_cast && current_toolchain == default_toolchain) {
    cflags = [ "-fno-sanitize=cfi-unrelated-cast" ]
  }
}

370
371
angle_source_set("xxhash") {
  sources = xxhash_sources
372
373
374
  if (is_clang) {
    cflags_c = [ "-Wno-implicit-fallthrough" ]
  }
375
376
}

377
378
if (angle_has_build) {
  fuzzer_test("xxhash_fuzzer") {
379
380
    sources = [ "src/common/third_party/xxhash/xxhash_fuzzer.cpp" ]
    deps = [ ":xxhash" ]
381
  }
Jamie Madill's avatar
Jamie Madill committed
382
383
}

384
angle_static_library("angle_common") {
385
  sources = libangle_common_sources
John Plate's avatar
John Plate committed
386
387
388
  if (angle_enable_cl) {
    sources += libangle_common_cl_sources
  }
389

390
  configs += [
391
    ":angle_common_config",
392
    ":debug_annotations_config",
393
  ]
394

395
  deps = [ ":xxhash" ]
396

397
  public_deps = [
398
    ":angle_abseil",
399
    ":includes",
400
  ]
401
  public_configs += [ ":angle_common_config" ]
402
  if (angle_has_build && use_fuzzing_engine) {
403
    all_dependent_configs = [ ":angle_disable_pool_alloc" ]
404
  }
Tim Van Patten's avatar
Tim Van Patten committed
405

406
407
408
409
  if (is_linux || is_chromeos) {
    libs = [ "dl" ]
  }

Tim Van Patten's avatar
Tim Van Patten committed
410
411
412
413
414
415
416
417
418
  if (is_android && (angle_enable_gl || angle_enable_vulkan)) {
    # In API level 26 ANativeWindow APIs were moved from libandroid.so
    # into a separate library, libnativewindow.so
    if (ndk_api_level_at_least_26) {
      libs = [ "nativewindow" ]
    } else {
      libs = [ "android" ]
    }
  }
419
420
421
422

  if (angle_expose_non_conformant_extensions_and_versions) {
    defines = [ "ANGLE_EXPOSE_NON_CONFORMANT_EXTENSIONS_AND_VERSIONS" ]
  }
423

424
  if (using_sanitizer && !build_with_chromium) {
425
426
    data_deps = [ "//build/config/clang:llvm-symbolizer_data($host_toolchain)" ]
  }
427
428
}

429
430
431
432
433
434
435
config("angle_image_util_config") {
  include_dirs = [
    "include",
    "src",
  ]
}

436
437
angle_source_set("angle_image_util_headers") {
  sources = libangle_image_util_headers
438
  public_deps = [ ":angle_common" ]
439
440
}

441
angle_static_library("angle_image_util") {
442
  sources = libangle_image_util_sources
443
  public_configs += [ ":angle_image_util_config" ]
444
  public_deps = [ ":angle_image_util_headers" ]
445
446
}

447
448
449
450
451
452
453
454
455
456
457
config("angle_gl_visibility_config") {
  if (is_win) {
    defines = [
      "GL_APICALL=",
      "GL_API=",
    ]
  } else {
    defines = [
      "GL_APICALL=__attribute__((visibility(\"default\")))",
      "GL_API=__attribute__((visibility(\"default\")))",
    ]
458
  }
459
460
}

461
462
463
464
465
466
467
config("angle_vulkan_wayland_config") {
  if (angle_enable_vulkan && angle_use_wayland &&
      defined(vulkan_wayland_include_dirs)) {
    include_dirs = vulkan_wayland_include_dirs
  }
}

468
469
470
471
472
473
474
config("angle_gpu_info_util_config") {
  include_dirs = [
    "include",
    "src",
  ]
}

475
angle_static_library("angle_gpu_info_util") {
476
477
478
479
  public_configs += [
    ":angle_gpu_info_util_config",
    ":angle_backend_config",
  ]
480
  public_deps = [ ":angle_common" ]
481
  sources = libangle_gpu_info_util_sources
482
483
484
485
  deps = []
  libs = []
  defines = []

486
  if (angle_build_vulkan_system_info) {
487
    sources += libangle_gpu_info_util_vulkan_sources
488
489
    deps += [
      "$angle_vulkan_headers_dir:vulkan_headers",
490
491
      "src/common/vulkan:angle_libvulkan_loader",
      "src/common/vulkan:angle_vulkan_icd",
492
    ]
493
    if (angle_enable_vulkan_system_info) {
494
      defines += [ "ANGLE_USE_VULKAN_SYSTEM_INFO" ]
495
    }
496
497
  }

498
  if (is_android) {
499
500
501
502
503
    sources += libangle_gpu_info_util_android_sources
  }

  if (is_fuchsia) {
    sources += libangle_gpu_info_util_fuchsia_sources
504
    deps += [ "$angle_root/src/common/vulkan:angle_vulkan_entry_points" ]
505
506
  }

507
  if (is_win) {
508
    sources += libangle_gpu_info_util_win_sources
509
510
511
    if (!angle_is_winuwp) {
      libs += [ "setupapi.lib" ]
    }
512
    libs += [ "dxgi.lib" ]
513
514
  }

515
  if (is_linux || is_chromeos) {
516
    sources += libangle_gpu_info_util_linux_sources
517

Jamie Madill's avatar
Jamie Madill committed
518
    if (angle_use_x11 && angle_has_build) {
519
      sources += libangle_gpu_info_util_x11_sources
520
521
522
523
524
525
526
527
      deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
      defines += [ "GPU_INFO_USE_X11" ]
      libs += [
        "X11",
        "Xi",
        "Xext",
      ]
    }
528
529
530
531

    if (angle_use_wayland && angle_has_build) {
      public_deps += [ ":angle_wayland" ]
    }
532
533
534
  }

  if (use_libpci) {
535
    sources += libangle_gpu_info_util_libpci_sources
536
537
538
    defines += [ "GPU_INFO_USE_LIBPCI" ]
    libs += [ "pci" ]
  }
539

540
  if (is_apple) {
541
    frameworks = [
542
543
      "IOKit.framework",
      "CoreFoundation.framework",
544
      "CoreGraphics.framework",
545
    ]
James Darpinian's avatar
James Darpinian committed
546
547
548
549
550
551
552
553
554
555
556
    if (angle_enable_eagl) {
      frameworks += [ "OpenGLES.framework" ]
    } else if (angle_enable_cgl) {
      frameworks += [ "OpenGL.framework" ]
    }
    if (is_mac || angle_enable_cgl) {
      sources += libangle_gpu_info_util_mac_sources
    }
    if (is_ios && !angle_enable_cgl) {
      sources += libangle_gpu_info_util_ios_sources
    }
557
  }
558
559
}

560
561
angle_source_set("angle_translator_headers") {
  sources = angle_translator_exported_headers
562
  public_deps = [ ":includes" ]
563
564
}

565
566
567
568
569
570
571
572
573
template("translator_lib") {
  angle_static_library(target_name) {
    sources = angle_translator_sources
    defines = []

    _needs_glsl_base = false
    _needs_glsl_and_vulkan_base = false
    _uses_spirv = false

574
575
576
577
578
579
580
581
    # Frontend support:
    if (angle_enable_desktop_glsl) {
      sources += angle_translator_glsl_symbol_table_sources
    } else {
      sources += angle_translator_essl_symbol_table_sources
    }

    # Backend support:
582
583
584
585
586
    if (angle_enable_essl || use_fuzzing_engine) {
      _needs_glsl_base = true
      sources += angle_translator_essl_sources
      defines += [ "ANGLE_ENABLE_ESSL" ]
    }
587

588
589
590
591
592
593
    if (angle_enable_glsl || use_fuzzing_engine) {
      _needs_glsl_base = true
      _needs_glsl_and_vulkan_base = true
      sources += angle_translator_glsl_sources
      defines += [ "ANGLE_ENABLE_GLSL" ]
    }
594

595
596
597
598
599
    if (angle_enable_apple_translator_workarounds) {
      sources += angle_translator_apple_sources
      defines += [ "ANGLE_ENABLE_APPLE_WORKAROUNDS" ]
    }

600
601
602
    if (angle_enable_hlsl || use_fuzzing_engine) {
      sources += angle_translator_hlsl_sources
      defines += [ "ANGLE_ENABLE_HLSL" ]
603
    }
604

605
    if (!invoker.gl_d3d_only) {
606
607
      if (angle_enable_vulkan || use_fuzzing_engine ||
          angle_enable_msl_through_spirv) {
608
609
610
        _needs_glsl_base = true
        _needs_glsl_and_vulkan_base = true
        _uses_spirv = true
611

612
613
614
        # This translator is needed by metal backend also.
        sources += angle_translator_lib_vulkan_sources
      }
615

616
617
618
      if (angle_enable_vulkan || use_fuzzing_engine) {
        defines += [ "ANGLE_ENABLE_VULKAN" ]
      }
619

620
621
      if (angle_enable_metal) {
        sources += angle_translator_lib_metal_sources
622
623
624
625
        defines += [ "ANGLE_ENABLE_METAL" ]
        if (angle_enable_msl_through_spirv) {
          defines += [ "ANGLE_ENABLE_METAL_SPIRV" ]
        }
626
627
      }
    }
628

629
630
631
632
633
634
    if (_needs_glsl_base) {
      sources += angle_translator_glsl_base_sources
    }
    if (_needs_glsl_and_vulkan_base) {
      sources += angle_translator_glsl_and_vulkan_base_sources
    }
635

636
    public_configs += [ ":external_config" ]
637

638
639
640
    deps = [
      ":includes",
      ":preprocessor",
641
      "$angle_root/src/common/spirv:angle_spirv_headers",
642
    ]
643

644
645
646
    if (_uses_spirv) {
      deps += [
        "$angle_root/src/common/spirv:angle_spirv_base",
647
648
        "$angle_root/src/common/spirv:angle_spirv_builder",
        "${angle_spirv_headers_dir}:spv_headers",
649
650
651
        "${angle_spirv_tools_dir}:spvtools_headers",
        "${angle_spirv_tools_dir}:spvtools_val",
      ]
652
653
654
655
656
657
658
659
660

      if (angle_enable_spirv_gen_through_glslang) {
        defines += [ "ANGLE_ENABLE_SPIRV_GENERATION_THROUGH_GLSLANG" ]
        sources += [ "src/compiler/translator/glslang_wrapper.cpp" ]
        deps += [
          "${angle_glslang_dir}:glslang_default_resource_limits_sources",
          "${angle_glslang_dir}:glslang_lib_sources",
        ]
      }
661
    }
662

663
664
665
    public_deps = [
      ":angle_common",
      ":angle_translator_headers",
666
    ]
667
668
669
670
671
672

    if (is_win) {
      # Necessary to suppress some system header xtree warnings in Release.
      # For some reason this warning doesn't get triggered in Chromium
      cflags = [ "/wd4718" ]
    }
673
  }
674
}
675

676
677
678
translator_lib("translator") {
  gl_d3d_only = false
}
679

Shahbaz Youssefi's avatar
Shahbaz Youssefi committed
680
681
682
683
if (angle_enable_essl || angle_enable_glsl || angle_enable_hlsl) {
  translator_lib("translator_gl_d3d_only") {
    gl_d3d_only = true
  }
684
685
}

686
angle_source_set("translator_fuzzer") {
687
  sources = [ "src/compiler/fuzz/translator_fuzzer.cpp" ]
688
689
690
691
692
693

  include_dirs = [
    "include",
    "src",
  ]

694
  deps = [ ":translator" ]
695
696
}

Jamie Madill's avatar
Jamie Madill committed
697
config("angle_commit_id_config") {
698
  include_dirs = [ "$root_gen_dir/angle" ]
Jamie Madill's avatar
Jamie Madill committed
699
  visibility = [ ":angle_commit_id" ]
700
701
}

Jamie Madill's avatar
Jamie Madill committed
702
action("angle_commit_id") {
703
  _commit_id_header = "$root_gen_dir/angle/angle_commit.h"
704
  script = "src/commit_id.py"
705
706
707
  outputs = [ _commit_id_header ]

  visibility = [ ":angle_version" ]
708

709
  # Add git as a dependency if it is available.
710
711
  if (angle_enable_commit_id &&
      exec_script("src/commit_id.py", [ "check" ], "value") == 1) {
712
713
    # commit id should depend on angle's HEAD revision
    inputs = [ ".git/HEAD" ]
714
715
716
    branch = read_file(".git/HEAD", "string")
    result = string_split(branch)
    if (result[0] == "ref:") {
717
718
719
720
721
722
723
724
725
726
727
      _ref_file = result[1]

      # If git has packed the contents of .git/refs/heads/ in .git/packed-refs,
      # unpack the head before depending on it.
      exec_script("src/commit_id.py",
                  [
                    "unpack",
                    _ref_file,
                  ],
                  "")
      inputs += [ ".git/" + _ref_file ]
728
    }
729
  }
730
731
732

  args = [
    "gen",
733
    rebase_path(_commit_id_header, root_build_dir),
734
735
  ]

Jamie Madill's avatar
Jamie Madill committed
736
737
738
  public_configs = [ ":angle_commit_id_config" ]
}

739
angle_source_set("angle_version") {
740
  sources = [ "src/common/angle_version.h" ]
Jamie Madill's avatar
Jamie Madill committed
741
  public_deps = [ ":angle_commit_id" ]
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
  visibility = [ ":angle_version_info" ]

  # The version headers are used directly in Windows .RC files.
  if (is_win) {
    visibility += [
      ":libEGL",
      ":libGL",
      ":libGLESv1_CM",
      ":libGLESv2",
      ":libGLESv2_capture_complement",
    ]
  }
}

angle_source_set("angle_version_info") {
  sources = [
    "src/common/angle_version_info.cpp",
    "src/common/angle_version_info.h",
  ]
  deps = [ ":angle_version" ]
762
763
}

764
config("angle_backend_config") {
765
  defines = []
766

767
768
769
  if (angle_delegate_workers) {
    defines += [ "ANGLE_DELEGATE_WORKERS" ]
  }
770

771
772
773
774
  if (angle_force_context_check_every_call) {
    defines += [ "ANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL=1" ]
  }

775
776
777
778
  if (angle_expose_non_conformant_extensions_and_versions) {
    defines += [ "ANGLE_EXPOSE_NON_CONFORMANT_EXTENSIONS_AND_VERSIONS" ]
  }

779
780
781
782
  if (angle_use_spirv_gen_through_glslang) {
    defines += [ "ANGLE_USE_SPIRV_GENERATION_THROUGH_GLSLANG" ]
  }

783
784
  configs = []

Jamie Madill's avatar
Jamie Madill committed
785
786
787
788
789
790
791
792
  if (angle_enable_d3d11) {
    configs += [ "src/libANGLE/renderer/d3d:angle_d3d11_backend_config" ]
  }

  if (angle_enable_d3d9) {
    configs += [ "src/libANGLE/renderer/d3d:angle_d3d9_backend_config" ]
  }

Jamie Madill's avatar
Jamie Madill committed
793
794
795
796
  if (angle_enable_gl) {
    configs += [ "src/libANGLE/renderer/gl:angle_gl_backend_config" ]
  }

797
798
799
800
  if (angle_enable_null) {
    configs += [ "src/libANGLE/renderer/null:angle_null_backend_config" ]
  }

801
  if (angle_enable_metal) {
802
    configs += [ "src/libANGLE/renderer/metal:angle_metal_backend_config" ]
803
804
  }

805
  if (angle_enable_vulkan) {
806
    configs += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ]
807
  }
808

809
810
811
812
  if (angle_enable_cl_passthrough) {
    configs += [ "src/libANGLE/renderer/cl:angle_cl_backend_config" ]
  }

813
814
815
  if (angle_is_winuwp) {
    configs += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp_config" ]
  }
816
817
818
819
820
821
822
}

config("libANGLE_config") {
  cflags = []
  defines = []
  libs = []
  ldflags = []
823
  defines += [ "LIBANGLE_IMPLEMENTATION" ]
824

825
  if (is_win) {
826
827
    cflags += [ "/wd4530" ]  # C++ exception handler used, but unwind semantics
                             # are not enabled.
828
  }
Yuly Novikov's avatar
Yuly Novikov committed
829
830

  if (is_android && (angle_enable_gl || angle_enable_vulkan)) {
831
832
833
    # In API level 26 ANativeWindow APIs were moved from libandroid.so
    # into a separate library, libnativewindow.so
    if (ndk_api_level_at_least_26) {
Yuly Novikov's avatar
Yuly Novikov committed
834
835
836
837
838
      libs += [ "nativewindow" ]
    } else {
      libs += [ "android" ]
    }
  }
839

840
  if (angle_use_x11) {
841
842
    defines += [ "ANGLE_USE_X11" ]
  }
Jamie Madill's avatar
Jamie Madill committed
843

844
845
846
847
  if (angle_use_wayland) {
    defines += [ "ANGLE_USE_WAYLAND" ]
  }

Jamie Madill's avatar
Jamie Madill committed
848
849
850
  if (angle_enable_overlay) {
    defines += [ "ANGLE_ENABLE_OVERLAY=1" ]
  }
851
852
853
  if (angle_enable_perf_counter_output) {
    defines += [ "ANGLE_ENABLE_PERF_COUNTER_OUTPUT=1" ]
  }
854
}
855

856
857
angle_source_set("libANGLE_headers") {
  sources = libangle_headers
John Plate's avatar
John Plate committed
858
859
860
  if (angle_enable_cl) {
    sources += libangle_cl_headers
  }
861
862
863
864
  public_deps = [
    ":angle_common",
    ":angle_translator_headers",
  ]
Jamie Madill's avatar
Jamie Madill committed
865
  public_configs += [ ":libANGLE_config" ]
866
867
}

868
869
870
871
# Don't even try to build glslang if Metal and Vulkan are disabled.
if (angle_enable_vulkan || angle_enable_metal) {
  angle_source_set("angle_glslang_wrapper") {
    sources = [
872
873
      "src/libANGLE/renderer/ShaderInterfaceVariableInfoMap.cpp",
      "src/libANGLE/renderer/ShaderInterfaceVariableInfoMap.h",
874
875
876
877
878
      "src/libANGLE/renderer/glslang_wrapper_utils.cpp",
      "src/libANGLE/renderer/glslang_wrapper_utils.h",
    ]
    deps = [
      ":libANGLE_headers",
879
      "$angle_root/src/common/spirv:angle_spirv_base",
880
      "$angle_root/src/common/spirv:angle_spirv_builder",
881
      "$angle_root/src/common/spirv:angle_spirv_headers",
882
      "$angle_root/src/common/spirv:angle_spirv_parser",
883
      "${angle_spirv_headers_dir}:spv_headers",
884
885
    ]
  }
886
887
}

888
if ((is_win && angle_enable_gl) || angle_enable_d3d11 || angle_enable_d3d9) {
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
  angle_source_set("angle_d3d_format_tables") {
    sources = [
      "src/libANGLE/renderer/dxgi_format_map.h",
      "src/libANGLE/renderer/dxgi_format_map_autogen.cpp",
      "src/libANGLE/renderer/dxgi_support_table.h",
      "src/libANGLE/renderer/dxgi_support_table_autogen.cpp",
    ]

    if (!angle_is_winuwp) {
      sources += [
        "src/libANGLE/renderer/d3d_format.cpp",
        "src/libANGLE/renderer/d3d_format.h",
      ]
    }

    public_deps = [ ":libANGLE_headers" ]
    configs += [ ":angle_backend_config" ]
  }
}

909
angle_source_set("libANGLE_base") {
910
  sources = libangle_sources
John Plate's avatar
John Plate committed
911
912
913
  if (angle_enable_cl) {
    sources += libangle_cl_sources
  }
914

Jamie Madill's avatar
Jamie Madill committed
915
  include_dirs = []
916
  libs = []
917
  defines = []
918
919
920
921
  if (angle_link_glx) {
    libs += [ "GL" ]
    defines += [ "ANGLE_LINK_GLX" ]
  }
922
  public_deps = [
923
    ":angle_common",
924
    ":angle_gpu_info_util",
925
    ":angle_version_info",
926
    ":libANGLE_headers",
927
    ":translator",
928
929
  ]
  deps = [
930
    ":angle_compression",
931
    ":angle_image_util",
932
933
934
    ":includes",
  ]

935
  if (is_win && !angle_is_winuwp) {
936
937
938
939
940
941
    libs += [
      "gdi32.lib",
      "user32.lib",
    ]
  }

Jamie Madill's avatar
Jamie Madill committed
942
943
944
945
946
947
948
949
  if (angle_enable_d3d11) {
    public_deps += [ "src/libANGLE/renderer/d3d:angle_d3d11_backend" ]
  }

  if (angle_enable_d3d9) {
    public_deps += [ "src/libANGLE/renderer/d3d:angle_d3d9_backend" ]
  }

Jamie Madill's avatar
Jamie Madill committed
950
951
952
953
  if (angle_enable_gl) {
    public_deps += [ "src/libANGLE/renderer/gl:angle_gl_backend" ]
  }

954
955
956
957
  if (angle_enable_null) {
    public_deps += [ "src/libANGLE/renderer/null:angle_null_backend" ]
  }

958
959
960
961
  if (angle_enable_vulkan) {
    public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ]
  }

962
963
964
965
966
967
968
969
  if (angle_is_winuwp) {
    public_deps += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp" ]
  }

  if (angle_enable_d3d11) {
    libs += [ "dxguid.lib" ]
  }

970
971
972
973
  if (angle_enable_metal) {
    public_deps += [ "src/libANGLE/renderer/metal:angle_metal_backend" ]
  }

974
975
976
977
  if (angle_enable_cl_passthrough) {
    public_deps += [ "src/libANGLE/renderer/cl:angle_cl_backend" ]
  }

978
  # Enable extra Chromium style warnings for libANGLE.
979
  if (is_clang && angle_has_build) {
980
981
982
    suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ]
  }

983
  if (is_apple) {
984
985
986
    sources += libangle_mac_sources
  }

987
988
989
990
  if (is_ios) {
    sources += [ "src/libANGLE/renderer/driver_utils_ios.mm" ]
  }

991
  if (is_debug) {
Jamie Madill's avatar
Jamie Madill committed
992
    defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
993
  }
994

995
  configs += [ ":debug_annotations_config" ]
996
997
998
999
  public_configs += [
    ":libANGLE_config",
    ":angle_backend_config",
  ]
1000

For faster browsing, not all history is shown. View entire blame