BUILD 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
  5. load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  6. cc_library(
  7. name = "ast_to_proto_lib",
  8. testonly = 1,
  9. srcs = ["ast_to_proto.cpp"],
  10. hdrs = ["ast_to_proto.h"],
  11. deps = [
  12. "//explorer/ast",
  13. "//testing/fuzzing:carbon_cc_proto",
  14. "@llvm-project//llvm:Support",
  15. ],
  16. )
  17. cc_binary(
  18. name = "ast_to_proto",
  19. testonly = 1,
  20. srcs = ["ast_to_proto_main.cpp"],
  21. deps = [
  22. ":ast_to_proto_lib",
  23. "//common:bazel_working_dir",
  24. "//common:error",
  25. "//explorer/ast",
  26. "//explorer/base:arena",
  27. "//explorer/syntax",
  28. "//testing/fuzzing:carbon_cc_proto",
  29. "@com_google_protobuf//:protobuf_headers",
  30. ],
  31. )
  32. cc_test(
  33. name = "ast_to_proto_test",
  34. size = "small",
  35. srcs = ["ast_to_proto_test.cpp"],
  36. args = [
  37. "$(locations //explorer:standard_libraries)",
  38. "$(locations //explorer:carbon_files)",
  39. ],
  40. data = [
  41. "//explorer:carbon_files",
  42. "//explorer:standard_libraries",
  43. ],
  44. deps = [
  45. ":ast_to_proto_lib",
  46. "//explorer/syntax",
  47. "//testing/base:test_raw_ostream",
  48. "//testing/fuzzing:carbon_cc_proto",
  49. "//testing/fuzzing:proto_to_carbon_lib",
  50. "@com_google_googletest//:gtest",
  51. "@com_google_protobuf//:protobuf_headers",
  52. ],
  53. )
  54. cc_library(
  55. name = "fuzzer_util",
  56. testonly = 1,
  57. srcs = ["fuzzer_util.cpp"],
  58. hdrs = ["fuzzer_util.h"],
  59. deps = [
  60. "//common:check",
  61. "//common:error",
  62. "//explorer/ast",
  63. "//explorer/parse_and_execute",
  64. "//testing/fuzzing:carbon_cc_proto",
  65. "//testing/fuzzing:proto_to_carbon_lib",
  66. "@bazel_tools//tools/cpp/runfiles",
  67. "@com_google_protobuf//:protobuf_headers",
  68. "@llvm-project//llvm:Support",
  69. ],
  70. )
  71. cc_test(
  72. name = "fuzzer_util_test",
  73. size = "small",
  74. srcs = ["fuzzer_util_test.cpp"],
  75. data = [
  76. "//explorer:standard_libraries",
  77. ],
  78. deps = [
  79. ":fuzzer_util",
  80. "//testing/base:gtest_main",
  81. "//testing/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. size = "small",
  90. srcs = ["explorer_fuzzer.cpp"],
  91. corpus = glob(["fuzzer_corpus/*"]),
  92. shard_count = 8,
  93. tags = ["proto-fuzzer"],
  94. deps = [
  95. ":fuzzer_util",
  96. "//common:error",
  97. "@com_google_libprotobuf_mutator//:libprotobuf_mutator",
  98. "@llvm-project//llvm:Support",
  99. ],
  100. )