BUILD 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_library(
  17. name = "fuzzer_util",
  18. testonly = 1,
  19. srcs = ["fuzzer_util.cpp"],
  20. hdrs = ["fuzzer_util.h"],
  21. deps = [
  22. "//common:check",
  23. "//common:error",
  24. "//common/fuzzing:carbon_cc_proto",
  25. "//common/fuzzing:proto_to_carbon_lib",
  26. "//explorer/interpreter:exec_program",
  27. "//explorer/interpreter:trace_stream",
  28. "//explorer/syntax",
  29. "//explorer/syntax:prelude",
  30. "@bazel_tools//tools/cpp/runfiles",
  31. "@com_google_protobuf//:protobuf_headers",
  32. "@llvm-project//llvm:Support",
  33. ],
  34. )
  35. cc_test(
  36. name = "ast_to_proto_test",
  37. srcs = ["ast_to_proto_test.cpp"],
  38. args = [
  39. "$(locations //explorer:standard_libraries)",
  40. "$(locations //explorer/testdata:carbon_files)",
  41. ],
  42. data = [
  43. "//explorer:standard_libraries",
  44. "//explorer/testdata:carbon_files",
  45. ],
  46. deps = [
  47. ":ast_to_proto_lib",
  48. "//common/fuzzing:carbon_cc_proto",
  49. "//explorer/syntax",
  50. "@com_google_googletest//:gtest",
  51. "@com_google_protobuf//:protobuf_headers",
  52. "@llvm-project//llvm:Support",
  53. ],
  54. )
  55. cc_binary(
  56. name = "fuzzverter",
  57. testonly = 1,
  58. srcs = ["fuzzverter.cpp"],
  59. deps = [
  60. ":ast_to_proto_lib",
  61. ":fuzzer_util",
  62. "//common:error",
  63. "//common/fuzzing:carbon_cc_proto",
  64. "//explorer/common:error_builders",
  65. "//explorer/common:nonnull",
  66. "//explorer/syntax",
  67. "@com_google_protobuf//:protobuf_headers",
  68. "@llvm-project//llvm:Support",
  69. ],
  70. )
  71. filegroup(
  72. name = "fuzzer_corpus_files",
  73. srcs = glob(["fuzzer_corpus/**"]),
  74. )
  75. cc_test(
  76. name = "fuzzer_util_test",
  77. srcs = ["fuzzer_util_test.cpp"],
  78. data = [
  79. "//explorer:standard_libraries",
  80. ],
  81. deps = [
  82. ":fuzzer_util",
  83. "//common:gtest_main",
  84. "@com_google_googletest//:gtest",
  85. "@com_google_protobuf//:protobuf_headers",
  86. "@llvm-project//llvm:Support",
  87. ],
  88. )
  89. cc_test(
  90. name = "proto_to_carbon_test",
  91. srcs = ["proto_to_carbon_test.cpp"],
  92. args = [
  93. "$(locations //explorer:standard_libraries)",
  94. "$(locations //explorer/testdata:carbon_files)",
  95. ],
  96. data = [
  97. "//explorer:standard_libraries",
  98. "//explorer/testdata:carbon_files",
  99. ],
  100. deps = [
  101. ":ast_to_proto_lib",
  102. "//common/fuzzing:carbon_cc_proto",
  103. "//common/fuzzing:proto_to_carbon_lib",
  104. "//explorer/syntax",
  105. "@com_google_googletest//:gtest",
  106. "@com_google_protobuf//:protobuf_headers",
  107. "@llvm-project//llvm:Support",
  108. ],
  109. )
  110. cc_fuzz_test(
  111. name = "explorer_fuzzer",
  112. testonly = 1,
  113. srcs = ["explorer_fuzzer.cpp"],
  114. corpus = glob(["fuzzer_corpus/*"]),
  115. shard_count = 8,
  116. deps = [
  117. ":fuzzer_util",
  118. "//common:error",
  119. "@com_google_libprotobuf_mutator//:libprotobuf_mutator",
  120. "@llvm-project//llvm:Support",
  121. ],
  122. )