BUILD.gn 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright 2017 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/sanitizers/sanitizers.gni")
  5. import("//testing/libfuzzer/fuzzer_test.gni")
  6. import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni")
  7. config("main_config") {
  8. cflags = [ "-Wno-shadow" ]
  9. include_dirs = [ "src/" ]
  10. }
  11. source_set("libprotobuf-mutator") {
  12. testonly = true
  13. # Remove *San and coverage for a performance boost.
  14. configs -= not_fuzzed_remove_configs
  15. configs += [ "//build/config/sanitizers:not_fuzzed" ]
  16. public_configs = [ ":main_config" ]
  17. sources = [
  18. "src/src/binary_format.cc",
  19. "src/src/libfuzzer/libfuzzer_macro.cc",
  20. "src/src/libfuzzer/libfuzzer_mutator.cc",
  21. "src/src/mutator.cc",
  22. "src/src/text_format.cc",
  23. "src/src/utf8_fix.cc",
  24. ]
  25. # Allow users of LPM to use protobuf reflection and other features from
  26. # protobuf_full.
  27. public_deps = [ "//third_party/protobuf:protobuf_full" ]
  28. # Let ClusterFuzz builders know to not build targets that depend on
  29. # libprotobuf-mutator for AFL or Chrome OS.
  30. if (use_afl || current_toolchain == "//build/toolchain/cros:target") {
  31. all_dependent_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
  32. }
  33. }
  34. # The CQ will try building this target without "use_libfuzzer" if it is defined.
  35. # That will cause the build to fail, so don't define it when "use_libfuzzer" is
  36. # is false.
  37. if (use_libfuzzer) {
  38. # Test that fuzzable_proto_library works. This target contains files that are
  39. # optimized for LITE_RUNTIME and which import other files that are also
  40. # optimized for LITE_RUNTIME.
  41. fuzzer_test("lpm_test_fuzzer") {
  42. sources = [ "test_fuzzer/test_fuzzer.cc" ]
  43. deps = [
  44. ":libprotobuf-mutator",
  45. ":lpm_test_fuzzer_proto",
  46. ]
  47. # Don't actually run this on CF. It's only a test to ensure builds work.
  48. additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
  49. }
  50. }
  51. # Proto library for lpm_test_fuzzer
  52. fuzzable_proto_library("lpm_test_fuzzer_proto") {
  53. sources = [
  54. "test_fuzzer/imported.proto",
  55. "test_fuzzer/imported_publicly.proto",
  56. "test_fuzzer/test_fuzzer_input.proto",
  57. ]
  58. }
  59. # Avoid CQ complaints on platforms we don't care about (ie: iOS).
  60. # Also prevent people from using this to include protobuf_full into a production
  61. # build of Chrome.
  62. if (use_libfuzzer) {
  63. # Component that can provide protobuf_full to non-testonly targets
  64. static_library("protobuf_full") {
  65. public_deps = [ "//third_party/protobuf:protobuf_full" ]
  66. sources = [ "dummy.cc" ]
  67. }
  68. }