BUILD 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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("//bazel/fuzzing:rules.bzl", "cc_fuzz_test")
  5. cc_library(
  6. name = "ast_to_proto_lib",
  7. testonly = 1,
  8. srcs = ["ast_to_proto.cpp"],
  9. hdrs = ["ast_to_proto.h"],
  10. deps = [
  11. "//common/fuzzing:carbon_cc_proto",
  12. "//explorer/ast",
  13. "@llvm-project//llvm:Support",
  14. ],
  15. )
  16. cc_binary(
  17. name = "ast_to_proto",
  18. testonly = 1,
  19. srcs = ["ast_to_proto_main.cpp"],
  20. deps = [
  21. ":ast_to_proto_lib",
  22. "//common:bazel_working_dir",
  23. "//common:error",
  24. "//common/fuzzing:carbon_cc_proto",
  25. "//explorer/ast",
  26. "//explorer/common:arena",
  27. "//explorer/syntax",
  28. "@com_google_protobuf//:protobuf_headers",
  29. "@llvm-project//llvm:Support",
  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/testdata:carbon_files)",
  38. ],
  39. data = [
  40. "//explorer:standard_libraries",
  41. "//explorer/testdata:carbon_files",
  42. ],
  43. deps = [
  44. ":ast_to_proto_lib",
  45. "//common/fuzzing:carbon_cc_proto",
  46. "//common/fuzzing:proto_to_carbon_lib",
  47. "//explorer/syntax",
  48. "@com_google_googletest//:gtest",
  49. "@com_google_protobuf//:protobuf_headers",
  50. ],
  51. )
  52. cc_library(
  53. name = "fuzzer_util",
  54. testonly = 1,
  55. srcs = ["fuzzer_util.cpp"],
  56. hdrs = ["fuzzer_util.h"],
  57. deps = [
  58. "//common:check",
  59. "//common:error",
  60. "//common/fuzzing:carbon_cc_proto",
  61. "//common/fuzzing:proto_to_carbon_lib",
  62. "//explorer/ast",
  63. "//explorer/interpreter:exec_program",
  64. "//explorer/interpreter:trace_stream",
  65. "//explorer/syntax",
  66. "//explorer/syntax:prelude",
  67. "@bazel_tools//tools/cpp/runfiles",
  68. "@com_google_protobuf//:protobuf_headers",
  69. "@llvm-project//llvm:Support",
  70. ],
  71. )
  72. cc_test(
  73. name = "fuzzer_util_test",
  74. srcs = ["fuzzer_util_test.cpp"],
  75. data = [
  76. "//explorer:standard_libraries",
  77. ],
  78. deps = [
  79. ":fuzzer_util",
  80. "//common:gtest_main",
  81. "//common/fuzzing:proto_to_carbon_lib",
  82. "@com_google_googletest//:gtest",
  83. "@com_google_protobuf//:protobuf_headers",
  84. "@llvm-project//llvm:Support",
  85. ],
  86. )
  87. cc_fuzz_test(
  88. name = "explorer_fuzzer",
  89. testonly = 1,
  90. srcs = ["explorer_fuzzer.cpp"],
  91. corpus = glob(["fuzzer_corpus/*"]),
  92. shard_count = 8,
  93. deps = [
  94. ":fuzzer_util",
  95. "//common:error",
  96. "@com_google_libprotobuf_mutator//:libprotobuf_mutator",
  97. "@llvm-project//llvm:Support",
  98. ],
  99. )