BUILD 3.4 KB

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