BUILD.gn 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # Copyright 2019 The Chromium 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. import("//build/config/arm.gni")
  5. import("//testing/libfuzzer/fuzzer_test.gni")
  6. import("//testing/test.gni")
  7. config("common_config") {
  8. cflags = [ "-Wno-shadow" ]
  9. if (is_win) {
  10. defines = [
  11. # Required to use math constants from math.h.
  12. "_USE_MATH_DEFINES",
  13. ]
  14. }
  15. # PFFFT doesn't support SIMD on some cpus, so build a scalar version.
  16. if ((current_cpu == "arm" && !arm_use_neon) || current_cpu == "mipsel" ||
  17. current_cpu == "mips64el" || current_cpu == "ppc64" ||
  18. current_cpu == "riscv64" || current_cpu == "s390x") {
  19. defines = [ "PFFFT_SIMD_DISABLE" ]
  20. }
  21. }
  22. static_library("pffft") {
  23. configs += [ ":common_config" ]
  24. sources = [
  25. "src/pffft.c",
  26. "src/pffft.h",
  27. ]
  28. }
  29. # Fuzzing.
  30. group("fuzzers") {
  31. testonly = true
  32. deps = [
  33. ":pffft_complex_fuzzer",
  34. ":pffft_real_fuzzer",
  35. ]
  36. }
  37. fuzzer_testdata_dir = "$target_gen_dir/testdata"
  38. action("generate_pffft_fuzzer_corpus") {
  39. script = "generate_seed_corpus.py"
  40. sources = [ "generate_seed_corpus.py" ]
  41. args = [ rebase_path(fuzzer_testdata_dir, root_build_dir) ]
  42. outputs = [ fuzzer_testdata_dir ]
  43. }
  44. fuzzer_test("pffft_complex_fuzzer") {
  45. sources = [ "pffft_fuzzer.cc" ]
  46. cflags = [ "-DTRANSFORM_COMPLEX" ]
  47. deps = [ ":pffft" ]
  48. seed_corpus = fuzzer_testdata_dir
  49. seed_corpus_deps = [ ":generate_pffft_fuzzer_corpus" ]
  50. }
  51. fuzzer_test("pffft_real_fuzzer") {
  52. sources = [ "pffft_fuzzer.cc" ]
  53. cflags = [ "-DTRANSFORM_REAL" ]
  54. deps = [ ":pffft" ]
  55. seed_corpus = fuzzer_testdata_dir
  56. seed_corpus_deps = [ ":generate_pffft_fuzzer_corpus" ]
  57. }
  58. # Unit tests and benchmark.
  59. # This target must be used only for testing and benchmark purposes.
  60. static_library("fftpack") {
  61. testonly = true
  62. configs += [ ":common_config" ]
  63. sources = [
  64. "src/fftpack.c",
  65. "src/fftpack.h",
  66. ]
  67. visibility = [ ":*" ]
  68. }
  69. config("pffft_benchmark_internal_config") {
  70. cflags = [
  71. # test_pffft.c contains an `exit(1)` following a `break` statement.
  72. "-Wno-unreachable-code",
  73. ]
  74. }
  75. executable("pffft_benchmark") {
  76. testonly = true
  77. configs += [
  78. ":common_config",
  79. ":pffft_benchmark_internal_config",
  80. ]
  81. sources = [ "src/test_pffft.c" ]
  82. deps = [
  83. ":fftpack",
  84. ":pffft",
  85. ]
  86. }
  87. test("pffft_unittest") {
  88. testonly = true
  89. sources = [ "pffft_unittest.cc" ]
  90. deps = [
  91. ":fftpack",
  92. ":pffft",
  93. "//testing/gtest",
  94. "//testing/gtest:gtest_main",
  95. ]
  96. }