File: BUILD.gn

package info (click to toggle)
chromium 138.0.7204.157-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,864 kB
  • sloc: cpp: 34,936,859; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,967; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (711 lines) | stat: -rw-r--r-- 22,375 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/config.gni")
import("//build/config/arm.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//testing/test.gni")
import("//third_party/libvpx/libvpx_srcs.gni")
import("//third_party/libvpx/libvpx_test_srcs.gni")
import("//third_party/nasm/nasm_assemble.gni")

# Sets the architecture name for building libvpx.
if (current_cpu == "x86") {
  cpu_arch_full = "ia32"
} else if (current_cpu == "x64") {
  if (is_msan) {
    cpu_arch_full = "generic"
  } else {
    cpu_arch_full = "x64"
  }
} else if (current_cpu == "arm") {
  if (is_chromeos) {
    # ChromeOS gets highbd vp9 but other arm targets do not.
    cpu_arch_full = "arm-neon-highbd"
  } else if (arm_use_neon) {
    cpu_arch_full = "arm-neon"
  } else if (is_android) {
    cpu_arch_full = "arm-neon-cpu-detect"
  } else {
    cpu_arch_full = "arm"
  }
} else if (current_cpu == "arm64" || current_cpu == "arm64e") {
  if (is_win || is_chromeos || is_mac || is_ios) {
    # This is necessary for CrOS and macOS as they reuse the Linux
    # configuration, of which there are two (see the later definition of
    # os_category).
    cpu_arch_full = "arm64-highbd"
  } else {
    cpu_arch_full = "arm64"
  }
} else if (current_cpu == "riscv64") {
  cpu_arch_full = "generic"
} else if (current_cpu == "loong64") {
  cpu_arch_full = "loongarch"
} else {
  cpu_arch_full = current_cpu
}

if (is_nacl) {
  platform_include_dir = "source/config/nacl"
} else {
  # The mac configurations are currently a relic. They were useful when
  # x86inc.asm did not work for MACH_O but now the build is identical to the
  # linux config. iOS for arm on the other hand needs an apple-specific twist in
  # vpx_config.asm
  if (is_ios && current_cpu == "arm") {
    os_category = current_os
  } else if (is_posix || is_fuchsia) {
    # Should cover linux, fuchsia, mac, and the ios simulator.
    os_category = "linux"
  } else {  # This should only match windows.
    os_category = current_os
  }
  platform_include_dir = "source/config/$os_category/$cpu_arch_full"
}

libvpx_include_dirs = [
  "source/config",
  "source/libvpx",
  platform_include_dir,
]

# Private configuration used in building libvpx.
config("libvpx_config") {
  include_dirs = libvpx_include_dirs
  defines = [
    "CHROMIUM",

    # Maximum allowed for a direct mapping,
    # see partition_alloc::internal::MaxDirectMapped()
    "VPX_MAX_ALLOCABLE_MEMORY=((1ULL << 31) - (1 << 21))",
  ]

  # gn orders flags on a target before flags from configs. The default config
  # adds -Wall, and these flags have to be after -Wall -- so they need to come
  # from a config and can't be on the target directly.
  if (is_clang) {
    cflags = [
      # libvpx heavily relies on implicit enum casting.
      "-Wno-conversion",

      # libvpx does `if ((a == b))` in some places.
      "-Wno-parentheses-equality",

      # libvpx has many static functions in header, which trigger this warning.
      "-Wno-unused-function",
    ]
  } else if (!is_win) {
    cflags = [
      "-Wno-unused-function",
      "-Wno-sign-compare",
    ]
  }

  if (current_cpu == "ppc64") {
    cflags += [
      "-mcpu=power8",
      "-maltivec",
      "-mvsx",
    ]
  }
}

# This config is applied to targets that depend on libvpx.
config("libvpx_public_config") {
  include_dirs = [
    # libvpx_public_config does not have "source/config" (which gives access to
    # the private header vpx_version.h) because code outside the libvpx library
    # should use the vpx_codec_version*() functions and macros declared in the
    # public header vpx_codec.h.
    "source/libvpx",
    platform_include_dir,
  ]
}

source_set("libvpx_test_generic_headers") {
  deps = [ ":libvpx" ]
  sources = libvpx_test_srcs_generic_headers
}

executable("decode_encode_profile_test") {
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  include_dirs = [ "source/libvpx/third_party/libwebm/" ]

  testonly = true
  sources = [
    "source/libvpx/test/decode_test_driver.cc",
    "source/libvpx/test/encode_test_driver.cc",
    "source/libvpx/test/init_vpx_test.cc",
    "source/libvpx/test/test_libvpx.cc",
    "source/libvpx/test/test_vectors.cc",
    "source/libvpx/test/test_vectors.h",
    "source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc",
    "source/libvpx/third_party/libwebm/mkvparser/mkvreader.cc",
    "source/libvpx/tools_common.h",
    "source/libvpx/webmdec.cc",
    "source/libvpx/y4minput.c",
    "tests/pgo/decode_encode_profile_test.cc",
  ]
  deps = [
    ":libvpx",
    ":libvpx_test_generic_headers",
    "//testing/gtest",
  ]
}

if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) {
  nasm_assemble("libvpx_asm") {
    if (current_cpu == "x86") {
      sources = libvpx_srcs_x86_assembly
    } else if (current_cpu == "x64") {
      sources = libvpx_srcs_x86_64_assembly
    }
    inputs = [
      "$platform_include_dir/vpx_config.asm",
      "source/libvpx/third_party/x86inc/x86inc.asm",
      "source/libvpx/vpx_dsp/x86/bitdepth_conversion_sse2.asm",
      "source/libvpx/vpx_ports/x86_abi_support.asm",
    ]
    defines = [ "CHROMIUM" ]
    if (is_android) {
      # On Android, define __ANDROID__ to use alternative standard library
      # functions.
      defines += [ "__ANDROID__" ]
    }
    include_dirs = libvpx_include_dirs
  }
}

if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) {
  # The following targets are deliberately source_set rather than
  # static_library. The :libvpx target exposes these intrinsic implementations
  # via global function pointer symbols, which hides the object dependency at
  # link time. On Mac, this results in undefined references to the intrinsic
  # symbols.

  source_set("libvpx_intrinsics_mmx") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (!is_win) {
      cflags = [ "-mmmx" ]
    }
    if (current_cpu == "x86") {
      sources = libvpx_srcs_x86_mmx
      deps = [ ":libvpx_x86_headers" ]
    } else if (current_cpu == "x64") {
      sources = libvpx_srcs_x86_64_mmx
      deps = [ ":libvpx_x86_64_headers" ]
    }
  }

  source_set("libvpx_intrinsics_sse2") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (!is_win || is_clang) {
      cflags = [ "-msse2" ]
    }
    if (current_cpu == "x86") {
      sources = libvpx_srcs_x86_sse2
      deps = [ ":libvpx_x86_headers" ]
    } else if (current_cpu == "x64") {
      sources = libvpx_srcs_x86_64_sse2
      deps = [ ":libvpx_x86_64_headers" ]
    }
  }

  source_set("libvpx_intrinsics_ssse3") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (!is_win || is_clang) {
      cflags = [ "-mssse3" ]
    }
    if (current_cpu == "x86") {
      sources = libvpx_srcs_x86_ssse3
      deps = [ ":libvpx_x86_headers" ]
    } else if (current_cpu == "x64") {
      sources = libvpx_srcs_x86_64_ssse3
      deps = [ ":libvpx_x86_64_headers" ]
    }
  }

  source_set("libvpx_intrinsics_sse4_1") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (!is_win || is_clang) {
      cflags = [ "-msse4.1" ]
    }
    if (current_cpu == "x86") {
      deps = [ ":libvpx_x86_headers" ]
      sources = libvpx_srcs_x86_sse4_1
    } else if (current_cpu == "x64") {
      deps = [ ":libvpx_x86_64_headers" ]
      sources = libvpx_srcs_x86_64_sse4_1
    }
  }

  source_set("libvpx_intrinsics_avx") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (is_win) {
      cflags = [ "/arch:AVX" ]
    } else {
      cflags = [ "-mavx" ]
    }
    if (current_cpu == "x86") {
      deps = [ ":libvpx_x86_headers" ]
      sources = libvpx_srcs_x86_avx
    } else if (current_cpu == "x64") {
      deps = [ ":libvpx_x86_64_headers" ]
      sources = libvpx_srcs_x86_64_avx
    }
  }

  source_set("libvpx_intrinsics_avx2") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (is_win) {
      cflags = [ "/arch:AVX2" ]
    } else {
      cflags = [ "-mavx2" ]
    }
    if (current_cpu == "x86") {
      deps = [ ":libvpx_x86_headers" ]
      sources = libvpx_srcs_x86_avx2
    } else if (current_cpu == "x64") {
      deps = [ ":libvpx_x86_64_headers" ]
      sources = libvpx_srcs_x86_64_avx2
    }
  }

  source_set("libvpx_intrinsics_avx512") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (is_win) {
      # clang-cl does not accept this flag.
      # https://bugs.chromium.org/p/chromium/issues/detail?id=783370
      cflags = [ "/arch:AVX512" ]
    } else {
      cflags = [
        "-mavx512f",
        "-mavx512cd",
        "-mavx512bw",
        "-mavx512dq",
        "-mavx512vl",
      ]
    }
    if (current_cpu == "x86") {
      deps = [ ":libvpx_x86_headers" ]
      sources = libvpx_srcs_x86_avx512
    } else if (current_cpu == "x64") {
      deps = [ ":libvpx_x86_64_headers" ]
      sources = libvpx_srcs_x86_64_avx512
    } else if (current_cpu == "ppc64") {
      sources = libvpx_srcs_ppc64
    }
  }
}

if (current_cpu == "loong64") {
  source_set("libvpx_loongarch_lsx") {
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    cflags = [ "-mlsx" ]
    sources = libvpx_srcs_loongarch_lsx
  }
}

if (current_cpu == "arm" || current_cpu == "arm64" || current_cpu == "arm64e") {
  source_set("libvpx_intrinsics_neon") {
    check_includes = false
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (current_cpu == "arm") {
      configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
      cflags = [ "-mfpu=neon" ]
    }
    if (cpu_arch_full == "arm-neon") {
      sources = libvpx_srcs_arm_neon_neon
      deps = [ ":libvpx_arm_neon_headers" ]
    } else if (cpu_arch_full == "arm-neon-highbd") {
      sources = libvpx_srcs_arm_neon_highbd_neon
      deps = [ ":libvpx_arm_neon_highbd_headers" ]
    } else if (cpu_arch_full == "arm-neon-cpu-detect") {
      sources = libvpx_srcs_arm_neon_cpu_detect_neon
      deps = [ ":libvpx_arm_neon_cpu_detect_headers" ]
    } else if (cpu_arch_full == "arm64") {
      sources = libvpx_srcs_arm64_neon
      deps = [ ":libvpx_arm64_headers" ]
    } else if (cpu_arch_full == "arm64-highbd") {
      sources = libvpx_srcs_arm64_highbd_neon
      deps = [ ":libvpx_arm64_highbd_headers" ]
    }
  }
}

if (current_cpu == "arm64" || current_cpu == "arm64e") {
  source_set("libvpx_intrinsics_neon_dotprod") {
    check_includes = false
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (!is_win || is_clang) {
      cflags = [ "-march=armv8.2-a+dotprod" ]
    }
    if (cpu_arch_full == "arm64") {
      sources = libvpx_srcs_arm64_neon_dotprod
      deps = [ ":libvpx_arm64_headers" ]
    } else if (cpu_arch_full == "arm64-highbd") {
      sources = libvpx_srcs_arm64_highbd_neon_dotprod
      deps = [ ":libvpx_arm64_highbd_headers" ]
    }
  }

  source_set("libvpx_intrinsics_neon_i8mm") {
    check_includes = false
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    configs += [ ":libvpx_config" ]
    if (!is_win || is_clang) {
      cflags = [ "-march=armv8.2-a+i8mm" ]
    }
    if (cpu_arch_full == "arm64") {
      sources = libvpx_srcs_arm64_neon_i8mm
      deps = [ ":libvpx_arm64_headers" ]
    } else if (cpu_arch_full == "arm64-highbd") {
      sources = libvpx_srcs_arm64_highbd_neon_i8mm
      deps = [ ":libvpx_arm64_highbd_headers" ]
    }
  }

  # SVE is disabled for Windows due to a limitation with clang-cl-18:
  # third_party\llvm-build\Release+Asserts\lib\clang\18\include\arm_sve.h(271,1):
  # error: cannot mangle this built-in __SVInt8_t type yet
  if (!is_win) {
    source_set("libvpx_intrinsics_sve") {
      check_includes = false
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [ "//build/config/compiler:no_chromium_code" ]
      configs += [ ":libvpx_config" ]
      cflags = [ "-march=armv8.2-a+dotprod+i8mm+sve" ]
      if (cpu_arch_full == "arm64") {
        sources = libvpx_srcs_arm64_sve
        deps = [ ":libvpx_arm64_headers" ]
      } else if (cpu_arch_full == "arm64-highbd") {
        sources = libvpx_srcs_arm64_highbd_sve
        deps = [ ":libvpx_arm64_highbd_headers" ]
      }
    }

    source_set("libvpx_intrinsics_sve2") {
      check_includes = false
      configs -= [ "//build/config/compiler:chromium_code" ]
      configs += [ "//build/config/compiler:no_chromium_code" ]
      configs += [ ":libvpx_config" ]
      cflags = [ "-march=armv9-a+sve2" ]
      if (cpu_arch_full == "arm64") {
        sources = libvpx_srcs_arm64_sve2
        deps = [ ":libvpx_arm64_headers" ]
      } else if (cpu_arch_full == "arm64-highbd") {
        sources = libvpx_srcs_arm64_highbd_sve2
        deps = [ ":libvpx_arm64_highbd_headers" ]
      }
    }
  }
}

if (current_cpu == "arm") {
  if (cpu_arch_full == "arm-neon") {
    arm_assembly_sources = libvpx_srcs_arm_neon_assembly
  } else if (cpu_arch_full == "arm-neon-highbd") {
    arm_assembly_sources = libvpx_srcs_arm_neon_highbd_assembly
  } else if (cpu_arch_full == "arm-neon-cpu-detect") {
    arm_assembly_sources = libvpx_srcs_arm_neon_cpu_detect_assembly
  } else {
    arm_assembly_sources = libvpx_srcs_arm_assembly
  }
}

# Converts ARM assembly files to GAS style.
if (current_cpu == "arm" && arm_assembly_sources != []) {
  action_foreach("convert_arm_assembly") {
    script = "//third_party/libvpx/run_perl.py"
    sources = arm_assembly_sources
    gen_file =
        get_label_info("//third_party/libvpx/source/libvpx", "root_gen_dir") +
        "/{{source_root_relative_dir}}/{{source_file_part}}.S"
    outputs = [ gen_file ]
    if (is_ios) {
      ads2gas_script =
          "//third_party/libvpx/source/libvpx/build/make/ads2gas_apple.pl"
    } else {
      ads2gas_script =
          "//third_party/libvpx/source/libvpx/build/make/ads2gas.pl"
    }
    args = [
      "-s",
      rebase_path(ads2gas_script, root_build_dir),
      "-i",
      "{{source}}",
      "-o",
      rebase_path(gen_file, root_build_dir),
    ]
  }

  static_library("libvpx_assembly_arm") {
    sources = get_target_outputs(":convert_arm_assembly")
    configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
    configs += [ ":libvpx_config" ]
    if (cpu_arch_full == "arm-neon" || cpu_arch_full == "arm-neon-cpu-detect" ||
        cpu_arch_full == "arm-neon-highbd") {
      asmflags = [ "-mfpu=neon" ]

      # allow asm files to include generated sources which match the source
      # tree layout, e.g., vpx_dsp/arm/...
      include_dirs = [ get_label_info("//third_party/libvpx/source/libvpx",
                                      "target_gen_dir") ]
    }
    deps = [ ":convert_arm_assembly" ]
  }
}

source_set("libvpx_x86_headers") {
  sources = libvpx_srcs_x86_headers
}

source_set("libvpx_x86_64_headers") {
  sources = libvpx_srcs_x86_64_headers
}

source_set("libvpx_arm_headers") {
  sources = libvpx_srcs_arm_headers
}

source_set("libvpx_arm_neon_headers") {
  sources = libvpx_srcs_arm_neon_headers
}

source_set("libvpx_arm_neon_cpu_detect_headers") {
  sources = libvpx_srcs_arm_neon_cpu_detect_headers
}

source_set("libvpx_arm64_headers") {
  sources = libvpx_srcs_arm64_headers
}

source_set("libvpx_arm_neon_highbd_headers") {
  sources = libvpx_srcs_arm_neon_highbd_headers
}

source_set("libvpx_arm64_highbd_headers") {
  sources = libvpx_srcs_arm64_highbd_headers
}

source_set("libvpx_mips_headers") {
  sources = libvpx_srcs_mips_headers
}

source_set("libvpx_loongarch_headers") {
  sources = libvpx_srcs_loongarch_headers
}

source_set("libvpx_ppc64_headers") {
  sources = libvpx_srcs_ppc64_headers
}

source_set("libvpx_nacl_headers") {
  sources = libvpx_srcs_nacl_headers
}

source_set("libvpx_generic_headers") {
  sources = libvpx_srcs_generic_headers
}

static_library("libvpx") {
  if (!is_debug && (is_win || is_chromeos)) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  if (is_nacl) {
    sources = libvpx_srcs_generic
    public_deps = [ ":libvpx_generic_headers" ]
  } else if (current_cpu == "x86") {
    sources = libvpx_srcs_x86
    public_deps = [ ":libvpx_x86_headers" ]
  } else if (current_cpu == "x64") {
    if (is_msan) {
      sources = libvpx_srcs_generic
      public_deps = [ ":libvpx_generic_headers" ]
    } else {
      sources = libvpx_srcs_x86_64
      public_deps = [ ":libvpx_x86_64_headers" ]
    }
  } else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
    sources = libvpx_srcs_mips
    public_deps = [ ":libvpx_mips_headers" ]
  } else if (current_cpu == "arm") {
    if (is_chromeos) {
      sources = libvpx_srcs_arm_neon_highbd
      public_deps = [ ":libvpx_arm_neon_highbd_headers" ]
    } else if (arm_use_neon) {
      sources = libvpx_srcs_arm_neon
      public_deps = [ ":libvpx_arm_neon_headers" ]
    } else if (is_android) {
      sources = libvpx_srcs_arm_neon_cpu_detect
      public_deps = [ ":libvpx_arm_neon_cpu_detect_headers" ]
    } else {
      sources = libvpx_srcs_arm
      public_deps = [ ":libvpx_arm_headers" ]
    }
  } else if (current_cpu == "arm64" || current_cpu == "arm64e") {
    if (is_chromeos || is_win || is_mac || is_ios) {
      sources = libvpx_srcs_arm64_highbd
      public_deps = [ ":libvpx_arm64_highbd_headers" ]
    } else {
      sources = libvpx_srcs_arm64
      public_deps = [ ":libvpx_arm64_headers" ]
    }
  } else if (current_cpu == "ppc64") {
    sources = libvpx_srcs_ppc64
    public_deps = [ ":libvpx_ppc64_headers" ]
  } else if (current_cpu == "riscv64") {
    sources = libvpx_srcs_generic
    public_deps = [ ":libvpx_generic_headers" ]
  } else if (current_cpu == "loong64") {
    sources = libvpx_srcs_loongarch
    public_deps = [ ":libvpx_loongarch_headers" ]
  }

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_config" ]
  deps = []
  if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) {
    deps += [
      ":libvpx_asm",
      ":libvpx_intrinsics_avx",
      ":libvpx_intrinsics_avx2",
      ":libvpx_intrinsics_avx512",
      ":libvpx_intrinsics_mmx",
      ":libvpx_intrinsics_sse2",
      ":libvpx_intrinsics_sse4_1",
      ":libvpx_intrinsics_ssse3",
    ]
  }
  if (cpu_arch_full == "arm-neon-highbd" || cpu_arch_full == "arm-neon" ||
      cpu_arch_full == "arm-neon-cpu-detect" || current_cpu == "arm64" ||
      current_cpu == "arm64e") {
    deps += [ ":libvpx_intrinsics_neon" ]
  }
  if (current_cpu == "arm64" || current_cpu == "arm64e") {
    deps += [ ":libvpx_intrinsics_neon_dotprod" ]
    deps += [ ":libvpx_intrinsics_neon_i8mm" ]
    if (!is_win) {
      deps += [
        ":libvpx_intrinsics_sve",
        ":libvpx_intrinsics_sve2",
      ]
    }
  }
  if (is_android) {
    deps += [ "//third_party/cpu_features:ndk_compat" ]
  }
  if (current_cpu == "arm" && arm_assembly_sources != []) {
    deps += [ ":libvpx_assembly_arm" ]
  }
  if (current_cpu == "loong64") {
    deps += [ ":libvpx_loongarch_lsx" ]
  }

  public_configs = [ ":libvpx_public_config" ]
}

static_library("libvpxrc") {
  if (!is_debug && is_win) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  sources = [
    "//third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.cc",
    "//third_party/libvpx/source/libvpx/vp8/vp8_ratectrl_rtc.h",
    "//third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.cc",
    "//third_party/libvpx/source/libvpx/vp9/ratectrl_rtc.h",
    "//third_party/libvpx/source/libvpx/vpx/internal/vpx_ratectrl_rtc.h",
  ]

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_config" ]
  public_deps = [ ":libvpx" ]

  public_configs = [ ":libvpx_public_config" ]
}

test("vp8_encoder_fuzz_test") {
  sources = [ "tests/fuzzer/vp8_encoder_fuzz_test.cc" ]

  fuzztests = [
    "VP8EncodeFuzzTest.VP8EncodeArbitraryCallSequenceSucceeds",
    "VP8EncodeFuzzTest.VP8EncodeSucceeds",
  ]

  deps = [
    ":libvpx",
    "//third_party/fuzztest:fuzztest_gtest_main",
  ]
}

test("vp9_encoder_fuzz_test") {
  sources = [ "tests/fuzzer/vp9_encoder_fuzz_test.cc" ]

  fuzztests = [
    "VP9EncodeFuzzTest.VP9EncodeArbitraryCallSequenceSucceeds",
    "VP9EncodeFuzzTest.VP9EncodeSucceeds",
  ]

  deps = [
    ":libvpx",
    "//third_party/fuzztest:fuzztest_gtest_main",
  ]
}

test("test_libvpx") {
  sources = libvpx_test_srcs_generic
  sources += libvpx_test_srcs_generic_cc

  include_dirs = [ "source/libvpx/third_party/libwebm/" ]

  deps = [
    ":libvpx",
    ":libvpx_test_generic_headers",
    "//testing/gtest",
  ]

  if (is_android) {
    use_raw_android_executable = true
    defines = [ "LIBVPX_TEST_DATA_PATH=/data/local/tmp/chromium_tests_root/third_party/libvpx/testdata" ]
    data = [ "testdata/" ]
  } else {
    defines = [ string_join("",
                            [
                              "LIBVPX_TEST_DATA_PATH=",
                              rebase_path("testdata", root_build_dir),
                            ]) ]
  }

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}