BUILD 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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:format_providers",
  65. "//toolchain/lex:token_kind",
  66. "//toolchain/lex:tokenized_buffer",
  67. "@llvm-project//llvm:Support",
  68. ],
  69. )
  70. cc_library(
  71. name = "parse",
  72. srcs = ["parse.cpp"] +
  73. # Glob handler files to avoid missing any.
  74. glob([
  75. "handle_*.cpp",
  76. ]),
  77. hdrs = [
  78. "handle.h",
  79. "parse.h",
  80. ],
  81. deps = [
  82. ":context",
  83. ":dump",
  84. ":node_kind",
  85. ":state",
  86. ":tree",
  87. "//common:check",
  88. "//common:ostream",
  89. "//toolchain/base:pretty_stack_trace_function",
  90. "//toolchain/base:shared_value_stores",
  91. "//toolchain/diagnostics:diagnostic_emitter",
  92. "//toolchain/diagnostics:format_providers",
  93. "//toolchain/lex:token_kind",
  94. "//toolchain/lex:tokenized_buffer",
  95. ],
  96. )
  97. cc_library(
  98. name = "dump",
  99. srcs = ["dump.cpp"],
  100. hdrs = ["dump.h"],
  101. deps = [
  102. ":tree",
  103. "//common:ostream",
  104. "//toolchain/lex:dump",
  105. ],
  106. # Always link dump methods.
  107. alwayslink = 1,
  108. )
  109. cc_library(
  110. name = "state",
  111. srcs = ["state.cpp"],
  112. hdrs = ["state.h"],
  113. textual_hdrs = ["state.def"],
  114. deps = ["//common:enum_base"],
  115. )
  116. cc_library(
  117. name = "tree",
  118. srcs = [
  119. "extract.cpp",
  120. "tree.cpp",
  121. "tree_and_subtrees.cpp",
  122. ],
  123. hdrs = [
  124. "tree.h",
  125. "tree_and_subtrees.h",
  126. ],
  127. deps = [
  128. ":node_kind",
  129. "//common:check",
  130. "//common:error",
  131. "//common:ostream",
  132. "//common:struct_reflection",
  133. "//toolchain/base:value_store",
  134. "//toolchain/lex:tokenized_buffer",
  135. "@llvm-project//llvm:Support",
  136. ],
  137. )
  138. cc_test(
  139. name = "tree_test",
  140. size = "small",
  141. srcs = ["tree_test.cpp"],
  142. deps = [
  143. ":node_kind",
  144. ":parse",
  145. ":tree",
  146. "//common:ostream",
  147. "//testing/base:gtest_main",
  148. "//testing/base:test_raw_ostream",
  149. "//toolchain/base:shared_value_stores",
  150. "//toolchain/diagnostics:diagnostic_emitter",
  151. "//toolchain/diagnostics:mocks",
  152. "//toolchain/lex",
  153. "//toolchain/lex:tokenized_buffer",
  154. "//toolchain/testing:compile_helper",
  155. "//toolchain/testing:yaml_test_helpers",
  156. "@googletest//:gtest",
  157. "@llvm-project//llvm:Support",
  158. ],
  159. )
  160. cc_fuzz_test(
  161. name = "parse_fuzzer",
  162. size = "small",
  163. srcs = ["parse_fuzzer.cpp"],
  164. corpus = glob(["fuzzer_corpus/*"]),
  165. deps = [
  166. ":parse",
  167. "//common:check",
  168. "//testing/fuzzing:libfuzzer_header",
  169. "//toolchain/base:shared_value_stores",
  170. "//toolchain/diagnostics:diagnostic_emitter",
  171. "//toolchain/diagnostics:null_diagnostics",
  172. "//toolchain/lex",
  173. "@llvm-project//llvm:Support",
  174. ],
  175. )
  176. cc_library(
  177. name = "tree_node_diagnostic_converter",
  178. hdrs = ["tree_node_diagnostic_converter.h"],
  179. deps = [
  180. ":tree",
  181. "//toolchain/diagnostics:diagnostic_emitter",
  182. "//toolchain/lex:tokenized_buffer",
  183. ],
  184. )
  185. cc_library(
  186. name = "precedence",
  187. srcs = ["precedence.cpp"],
  188. hdrs = ["precedence.h"],
  189. deps = [
  190. "//common:check",
  191. "//toolchain/lex:token_kind",
  192. "@llvm-project//llvm:Support",
  193. ],
  194. )
  195. cc_test(
  196. name = "precedence_test",
  197. size = "small",
  198. srcs = ["precedence_test.cpp"],
  199. deps = [
  200. ":precedence",
  201. "//testing/base:gtest_main",
  202. "//toolchain/lex:token_kind",
  203. "@googletest//:gtest",
  204. ],
  205. )
  206. cc_test(
  207. name = "coverage_test",
  208. size = "small",
  209. srcs = ["coverage_test.cpp"],
  210. args = ["--testdata_manifest=$(location :testdata.txt)"],
  211. data = [
  212. ":testdata",
  213. ":testdata.txt",
  214. ],
  215. deps = [
  216. ":node_kind",
  217. "//testing/base:gtest_main",
  218. "//toolchain/testing:coverage_helper",
  219. "@abseil-cpp//absl/flags:flag",
  220. "@googletest//:gtest",
  221. ],
  222. )