BUILD 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. args = [
  78. "$(locations fuzzer_corpus_files)",
  79. ],
  80. data = [
  81. ":fuzzer_corpus_files",
  82. "//explorer:standard_libraries",
  83. ],
  84. deps = [
  85. ":fuzzer_util",
  86. "@com_google_googletest//:gtest",
  87. "@com_google_protobuf//:protobuf_headers",
  88. "@llvm-project//llvm:Support",
  89. ],
  90. )
  91. cc_test(
  92. name = "proto_to_carbon_test",
  93. srcs = ["proto_to_carbon_test.cpp"],
  94. args = [
  95. "$(locations //explorer:standard_libraries)",
  96. "$(locations //explorer/testdata:carbon_files)",
  97. ],
  98. data = [
  99. "//explorer:standard_libraries",
  100. "//explorer/testdata:carbon_files",
  101. ],
  102. deps = [
  103. ":ast_to_proto_lib",
  104. "//common/fuzzing:carbon_cc_proto",
  105. "//common/fuzzing:proto_to_carbon_lib",
  106. "//explorer/syntax",
  107. "@com_google_googletest//:gtest",
  108. "@com_google_protobuf//:protobuf_headers",
  109. "@llvm-project//llvm:Support",
  110. ],
  111. )
  112. # Needs `--config=proto-fuzzer` for `bazel build`.
  113. cc_binary(
  114. name = "explorer_fuzzer",
  115. testonly = 1,
  116. srcs = ["explorer_fuzzer.cpp"],
  117. features = ["fuzzer"],
  118. deps = [
  119. ":fuzzer_util",
  120. "@com_google_libprotobuf_mutator//:libprotobuf_mutator",
  121. "@llvm-project//llvm:Support",
  122. ],
  123. )