BUILD 3.6 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. "//executable_semantics/ast",
  13. "//executable_semantics/ast:declaration",
  14. "//executable_semantics/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/fuzzing:carbon_cc_proto",
  26. "//common/fuzzing:proto_to_carbon_lib",
  27. "//executable_semantics/interpreter:exec_program",
  28. "//executable_semantics/syntax",
  29. "//executable_semantics/syntax:prelude",
  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 //executable_semantics:standard_libraries)",
  39. "$(locations //executable_semantics/testdata:carbon_files)",
  40. ],
  41. data = [
  42. "//executable_semantics:standard_libraries",
  43. "//executable_semantics/testdata:carbon_files",
  44. ],
  45. deps = [
  46. ":ast_to_proto_lib",
  47. "//common/fuzzing:carbon_cc_proto",
  48. "//executable_semantics/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. "//executable_semantics/common:error_builders",
  64. "//executable_semantics/common:nonnull",
  65. "//executable_semantics/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. ],
  83. deps = [
  84. ":fuzzer_util",
  85. "@com_google_googletest//:gtest",
  86. "@com_google_protobuf//:protobuf_headers",
  87. "@llvm-project//llvm:Support",
  88. ],
  89. )
  90. cc_test(
  91. name = "proto_to_carbon_test",
  92. srcs = ["proto_to_carbon_test.cpp"],
  93. args = [
  94. "$(locations //executable_semantics:standard_libraries)",
  95. "$(locations //executable_semantics/testdata:carbon_files)",
  96. ],
  97. data = [
  98. "//executable_semantics:standard_libraries",
  99. "//executable_semantics/testdata:carbon_files",
  100. ],
  101. deps = [
  102. ":ast_to_proto_lib",
  103. "//common/fuzzing:carbon_cc_proto",
  104. "//common/fuzzing:proto_to_carbon_lib",
  105. "//executable_semantics/syntax",
  106. "@com_google_googletest//:gtest",
  107. "@com_google_protobuf//:protobuf_headers",
  108. "@llvm-project//llvm:Support",
  109. ],
  110. )
  111. # Needs `--config=proto-fuzzer` for `bazel build`.
  112. cc_binary(
  113. name = "executable_semantics_fuzzer",
  114. testonly = 1,
  115. srcs = ["executable_semantics_fuzzer.cpp"],
  116. features = ["fuzzer"],
  117. deps = [
  118. ":fuzzer_util",
  119. "@com_google_libprotobuf_mutator//:libprotobuf_mutator",
  120. "@llvm-project//llvm:Support",
  121. ],
  122. )