BUILD 3.3 KB

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