BUILD 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
  5. load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  6. cc_library(
  7. name = "ast_to_proto_lib",
  8. testonly = 1,
  9. srcs = ["ast_to_proto.cpp"],
  10. hdrs = ["ast_to_proto.h"],
  11. deps = [
  12. "//explorer/ast",
  13. "//testing/fuzzing:carbon_cc_proto",
  14. "@llvm-project//llvm:Support",
  15. ],
  16. )
  17. cc_binary(
  18. name = "ast_to_proto",
  19. testonly = 1,
  20. srcs = ["ast_to_proto_main.cpp"],
  21. deps = [
  22. ":ast_to_proto_lib",
  23. "//common:bazel_working_dir",
  24. "//common:error",
  25. "//explorer/ast",
  26. "//explorer/base:arena",
  27. "//explorer/syntax",
  28. "//testing/fuzzing:carbon_cc_proto",
  29. "@com_google_protobuf//:protobuf_headers",
  30. ],
  31. )
  32. cc_test(
  33. name = "ast_to_proto_test",
  34. srcs = ["ast_to_proto_test.cpp"],
  35. args = [
  36. "$(locations //explorer:standard_libraries)",
  37. "$(locations //explorer:carbon_files)",
  38. ],
  39. data = [
  40. "//explorer:carbon_files",
  41. "//explorer:standard_libraries",
  42. ],
  43. deps = [
  44. ":ast_to_proto_lib",
  45. "//explorer/syntax",
  46. "//testing/base:test_raw_ostream",
  47. "//testing/fuzzing:carbon_cc_proto",
  48. "//testing/fuzzing:proto_to_carbon_lib",
  49. "@com_google_googletest//:gtest",
  50. "@com_google_protobuf//:protobuf_headers",
  51. ],
  52. )
  53. cc_library(
  54. name = "fuzzer_util",
  55. testonly = 1,
  56. srcs = ["fuzzer_util.cpp"],
  57. hdrs = ["fuzzer_util.h"],
  58. deps = [
  59. "//common:check",
  60. "//common:error",
  61. "//explorer/ast",
  62. "//explorer/parse_and_execute",
  63. "//testing/fuzzing:carbon_cc_proto",
  64. "//testing/fuzzing:proto_to_carbon_lib",
  65. "@bazel_tools//tools/cpp/runfiles",
  66. "@com_google_protobuf//:protobuf_headers",
  67. "@llvm-project//llvm:Support",
  68. ],
  69. )
  70. cc_test(
  71. name = "fuzzer_util_test",
  72. srcs = ["fuzzer_util_test.cpp"],
  73. data = [
  74. "//explorer:standard_libraries",
  75. ],
  76. deps = [
  77. ":fuzzer_util",
  78. "//testing/base:gtest_main",
  79. "//testing/fuzzing:proto_to_carbon_lib",
  80. "@com_google_googletest//:gtest",
  81. "@com_google_protobuf//:protobuf_headers",
  82. "@llvm-project//llvm:Support",
  83. ],
  84. )
  85. cc_fuzz_test(
  86. name = "explorer_fuzzer",
  87. size = "small",
  88. srcs = ["explorer_fuzzer.cpp"],
  89. corpus = glob(["fuzzer_corpus/*"]),
  90. shard_count = 8,
  91. tags = ["proto-fuzzer"],
  92. deps = [
  93. ":fuzzer_util",
  94. "//common:error",
  95. "@com_google_libprotobuf_mutator//:libprotobuf_mutator",
  96. "@llvm-project//llvm:Support",
  97. ],
  98. )