BUILD 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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_library", "cc_test")
  5. load("//bazel/manifest:defs.bzl", "manifest")
  6. load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  7. package(default_visibility = ["//visibility:public"])
  8. filegroup(
  9. name = "testdata",
  10. data = glob(["testdata/**/*.carbon"]),
  11. )
  12. manifest(
  13. name = "testdata.txt",
  14. srcs = [":testdata"],
  15. )
  16. cc_library(
  17. name = "node_kind",
  18. srcs = ["node_kind.cpp"],
  19. hdrs = [
  20. "node_ids.h",
  21. "node_kind.h",
  22. "typed_nodes.h",
  23. ],
  24. textual_hdrs = ["node_kind.def"],
  25. deps = [
  26. "//common:check",
  27. "//common:enum_base",
  28. "//common:ostream",
  29. "//toolchain/base:index_base",
  30. "//toolchain/lex:token_index",
  31. "//toolchain/lex:token_kind",
  32. "@llvm-project//llvm:Support",
  33. ],
  34. )
  35. cc_test(
  36. name = "typed_nodes_test",
  37. size = "small",
  38. srcs = ["typed_nodes_test.cpp"],
  39. deps = [
  40. ":node_kind",
  41. ":parse",
  42. ":tree",
  43. "//testing/base:gtest_main",
  44. "//toolchain/diagnostics:diagnostic_emitter",
  45. "//toolchain/diagnostics:mocks",
  46. "//toolchain/lex",
  47. "//toolchain/lex:tokenized_buffer",
  48. "//toolchain/testing:compile_helper",
  49. "@googletest//:gtest",
  50. ],
  51. )
  52. cc_library(
  53. name = "context",
  54. srcs = ["context.cpp"],
  55. hdrs = ["context.h"],
  56. deps = [
  57. ":node_kind",
  58. ":precedence",
  59. ":state",
  60. ":tree",
  61. "//common:check",
  62. "//common:ostream",
  63. "//common:vlog",
  64. "//toolchain/diagnostics:diagnostic_emitter",
  65. "//toolchain/diagnostics:format_providers",
  66. "//toolchain/lex:token_kind",
  67. "//toolchain/lex:tokenized_buffer",
  68. "@llvm-project//llvm:Support",
  69. ],
  70. )
  71. cc_library(
  72. name = "parse",
  73. srcs = ["parse.cpp"] +
  74. # Glob handler files to avoid missing any.
  75. glob([
  76. "handle_*.cpp",
  77. ]),
  78. hdrs = [
  79. "handle.h",
  80. "parse.h",
  81. ],
  82. deps = [
  83. ":context",
  84. ":dump",
  85. ":node_kind",
  86. ":state",
  87. ":tree",
  88. "//common:check",
  89. "//common:ostream",
  90. "//toolchain/base:pretty_stack_trace_function",
  91. "//toolchain/base:shared_value_stores",
  92. "//toolchain/diagnostics:diagnostic_emitter",
  93. "//toolchain/diagnostics:format_providers",
  94. "//toolchain/lex:token_kind",
  95. "//toolchain/lex:tokenized_buffer",
  96. ],
  97. )
  98. cc_library(
  99. name = "dump",
  100. srcs = ["dump.cpp"],
  101. hdrs = ["dump.h"],
  102. deps = [
  103. ":tree",
  104. "//common:ostream",
  105. "//toolchain/lex:dump",
  106. ],
  107. # Always link dump methods.
  108. alwayslink = 1,
  109. )
  110. cc_library(
  111. name = "state",
  112. srcs = ["state.cpp"],
  113. hdrs = ["state.h"],
  114. textual_hdrs = ["state.def"],
  115. deps = ["//common:enum_base"],
  116. )
  117. cc_library(
  118. name = "tree",
  119. srcs = [
  120. "extract.cpp",
  121. "tree.cpp",
  122. "tree_and_subtrees.cpp",
  123. ],
  124. hdrs = [
  125. "tree.h",
  126. "tree_and_subtrees.h",
  127. ],
  128. deps = [
  129. ":node_kind",
  130. "//common:check",
  131. "//common:error",
  132. "//common:ostream",
  133. "//common:struct_reflection",
  134. "//toolchain/base:value_store",
  135. "//toolchain/lex:token_index",
  136. "//toolchain/lex:tokenized_buffer",
  137. "@llvm-project//llvm:Support",
  138. ],
  139. )
  140. cc_test(
  141. name = "tree_test",
  142. size = "small",
  143. srcs = ["tree_test.cpp"],
  144. deps = [
  145. ":node_kind",
  146. ":parse",
  147. ":tree",
  148. "//common:ostream",
  149. "//common:raw_string_ostream",
  150. "//testing/base:gtest_main",
  151. "//toolchain/base:shared_value_stores",
  152. "//toolchain/diagnostics:diagnostic_emitter",
  153. "//toolchain/diagnostics:mocks",
  154. "//toolchain/lex",
  155. "//toolchain/lex:tokenized_buffer",
  156. "//toolchain/testing:compile_helper",
  157. "//toolchain/testing:yaml_test_helpers",
  158. "@googletest//:gtest",
  159. "@llvm-project//llvm:Support",
  160. ],
  161. )
  162. cc_fuzz_test(
  163. name = "parse_fuzzer",
  164. size = "small",
  165. srcs = ["parse_fuzzer.cpp"],
  166. corpus = glob(["fuzzer_corpus/*"]),
  167. deps = [
  168. ":parse",
  169. "//common:check",
  170. "//testing/fuzzing:libfuzzer_header",
  171. "//toolchain/base:shared_value_stores",
  172. "//toolchain/diagnostics:diagnostic_emitter",
  173. "//toolchain/diagnostics:null_diagnostics",
  174. "//toolchain/lex",
  175. "@llvm-project//llvm:Support",
  176. ],
  177. )
  178. cc_library(
  179. name = "precedence",
  180. srcs = ["precedence.cpp"],
  181. hdrs = ["precedence.h"],
  182. deps = [
  183. "//common:check",
  184. "//toolchain/lex:token_kind",
  185. "@llvm-project//llvm:Support",
  186. ],
  187. )
  188. cc_test(
  189. name = "precedence_test",
  190. size = "small",
  191. srcs = ["precedence_test.cpp"],
  192. deps = [
  193. ":precedence",
  194. "//testing/base:gtest_main",
  195. "//toolchain/lex:token_kind",
  196. "@googletest//:gtest",
  197. ],
  198. )
  199. cc_test(
  200. name = "coverage_test",
  201. size = "small",
  202. srcs = ["coverage_test.cpp"],
  203. args = ["--testdata_manifest=$(location :testdata.txt)"],
  204. data = [
  205. ":testdata",
  206. ":testdata.txt",
  207. ],
  208. deps = [
  209. ":node_kind",
  210. "//testing/base:gtest_main",
  211. "//toolchain/testing:coverage_helper",
  212. "@abseil-cpp//absl/flags:flag",
  213. "@googletest//:gtest",
  214. ],
  215. )