BUILD 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. package(default_visibility = ["//visibility:public"])
  7. filegroup(
  8. name = "testdata",
  9. data = glob(["testdata/**/*.carbon"]),
  10. )
  11. cc_library(
  12. name = "token_kind",
  13. srcs = ["token_kind.cpp"],
  14. hdrs = ["token_kind.h"],
  15. textual_hdrs = ["token_kind.def"],
  16. deps = [
  17. "//common:check",
  18. "//common:enum_base",
  19. "@llvm-project//llvm:Support",
  20. ],
  21. )
  22. cc_test(
  23. name = "token_kind_test",
  24. size = "small",
  25. srcs = ["token_kind_test.cpp"],
  26. deps = [
  27. ":token_kind",
  28. "//testing/base:gtest_main",
  29. "@googletest//:gtest",
  30. "@llvm-project//llvm:Support",
  31. ],
  32. )
  33. cc_library(
  34. name = "character_set",
  35. hdrs = ["character_set.h"],
  36. deps = ["@llvm-project//llvm:Support"],
  37. )
  38. cc_library(
  39. name = "helpers",
  40. srcs = ["helpers.cpp"],
  41. hdrs = ["helpers.h"],
  42. deps = [
  43. "//toolchain/diagnostics:diagnostic_emitter",
  44. "@llvm-project//llvm:Support",
  45. ],
  46. )
  47. cc_library(
  48. name = "test_helpers",
  49. testonly = 1,
  50. hdrs = ["test_helpers.h"],
  51. deps = [
  52. "//common:check",
  53. "//common:string_helpers",
  54. "//toolchain/diagnostics:diagnostic_emitter",
  55. "@googletest//:gtest",
  56. "@llvm-project//llvm:Support",
  57. ],
  58. )
  59. cc_library(
  60. name = "numeric_literal",
  61. srcs = ["numeric_literal.cpp"],
  62. hdrs = ["numeric_literal.h"],
  63. deps = [
  64. ":character_set",
  65. ":helpers",
  66. "//common:check",
  67. "//toolchain/diagnostics:diagnostic_emitter",
  68. "//toolchain/diagnostics:format_providers",
  69. "@llvm-project//llvm:Support",
  70. ],
  71. )
  72. cc_binary(
  73. name = "numeric_literal_benchmark",
  74. testonly = 1,
  75. srcs = ["numeric_literal_benchmark.cpp"],
  76. deps = [
  77. ":numeric_literal",
  78. "//common:check",
  79. "//testing/base:benchmark_main",
  80. "//toolchain/diagnostics:null_diagnostics",
  81. "@google_benchmark//:benchmark",
  82. ],
  83. )
  84. cc_test(
  85. name = "numeric_literal_test",
  86. size = "small",
  87. srcs = ["numeric_literal_test.cpp"],
  88. deps = [
  89. ":numeric_literal",
  90. ":test_helpers",
  91. "//common:check",
  92. "//common:ostream",
  93. "//testing/base:gtest_main",
  94. "//toolchain/diagnostics:diagnostic_emitter",
  95. "@googletest//:gtest",
  96. "@llvm-project//llvm:Support",
  97. ],
  98. )
  99. cc_fuzz_test(
  100. name = "numeric_literal_fuzzer",
  101. size = "small",
  102. srcs = ["numeric_literal_fuzzer.cpp"],
  103. corpus = glob(["fuzzer_corpus/numeric_literal/*"]),
  104. deps = [
  105. ":numeric_literal",
  106. "//testing/fuzzing:libfuzzer_header",
  107. "//toolchain/diagnostics:diagnostic_emitter",
  108. "//toolchain/diagnostics:null_diagnostics",
  109. "@llvm-project//llvm:Support",
  110. ],
  111. )
  112. cc_library(
  113. name = "string_literal",
  114. srcs = ["string_literal.cpp"],
  115. hdrs = ["string_literal.h"],
  116. deps = [
  117. ":character_set",
  118. ":helpers",
  119. "//common:check",
  120. "//toolchain/diagnostics:diagnostic_emitter",
  121. "@llvm-project//llvm:Support",
  122. ],
  123. )
  124. cc_binary(
  125. name = "string_literal_benchmark",
  126. testonly = 1,
  127. srcs = ["string_literal_benchmark.cpp"],
  128. deps = [
  129. ":string_literal",
  130. "//testing/base:benchmark_main",
  131. "//toolchain/diagnostics:null_diagnostics",
  132. "@google_benchmark//:benchmark",
  133. ],
  134. )
  135. cc_test(
  136. name = "string_literal_test",
  137. size = "small",
  138. srcs = ["string_literal_test.cpp"],
  139. deps = [
  140. ":string_literal",
  141. ":test_helpers",
  142. "//common:check",
  143. "//common:ostream",
  144. "//testing/base:gtest_main",
  145. "//toolchain/diagnostics:diagnostic_emitter",
  146. "@googletest//:gtest",
  147. "@llvm-project//llvm:Support",
  148. ],
  149. )
  150. cc_fuzz_test(
  151. name = "string_literal_fuzzer",
  152. size = "small",
  153. srcs = ["string_literal_fuzzer.cpp"],
  154. corpus = glob(["fuzzer_corpus/string_literal/*"]),
  155. deps = [
  156. ":string_literal",
  157. "//common:check",
  158. "//testing/fuzzing:libfuzzer_header",
  159. "//toolchain/diagnostics:diagnostic_emitter",
  160. "//toolchain/diagnostics:null_diagnostics",
  161. "@llvm-project//llvm:Support",
  162. ],
  163. )
  164. cc_library(
  165. name = "lex",
  166. srcs = ["lex.cpp"],
  167. hdrs = ["lex.h"],
  168. deps = [
  169. ":character_set",
  170. ":helpers",
  171. ":numeric_literal",
  172. ":string_literal",
  173. ":token_kind",
  174. ":tokenized_buffer",
  175. "//common:check",
  176. "//common:variant_helpers",
  177. "//toolchain/base:shared_value_stores",
  178. "//toolchain/diagnostics:diagnostic_emitter",
  179. "//toolchain/source:source_buffer",
  180. "@llvm-project//llvm:Support",
  181. ],
  182. )
  183. cc_library(
  184. name = "token_index",
  185. hdrs = ["token_index.h"],
  186. deps = [
  187. ":token_kind",
  188. "//toolchain/base:index_base",
  189. ],
  190. )
  191. cc_library(
  192. name = "tokenized_buffer",
  193. srcs = ["tokenized_buffer.cpp"],
  194. hdrs = ["tokenized_buffer.h"],
  195. deps = [
  196. ":character_set",
  197. ":helpers",
  198. ":numeric_literal",
  199. ":string_literal",
  200. ":token_index",
  201. ":token_kind",
  202. "//common:check",
  203. "//common:ostream",
  204. "//common:string_helpers",
  205. "//toolchain/base:index_base",
  206. "//toolchain/base:mem_usage",
  207. "//toolchain/base:shared_value_stores",
  208. "//toolchain/diagnostics:diagnostic_emitter",
  209. "//toolchain/source:source_buffer",
  210. "@llvm-project//llvm:Support",
  211. ],
  212. )
  213. cc_library(
  214. name = "tokenized_buffer_test_helpers",
  215. testonly = 1,
  216. hdrs = ["tokenized_buffer_test_helpers.h"],
  217. deps = [
  218. ":lex",
  219. ":tokenized_buffer",
  220. "//common:check",
  221. "//toolchain/base:shared_value_stores",
  222. "@googletest//:gtest",
  223. "@llvm-project//llvm:Support",
  224. ],
  225. )
  226. cc_test(
  227. name = "tokenized_buffer_test",
  228. size = "small",
  229. srcs = ["tokenized_buffer_test.cpp"],
  230. deps = [
  231. ":lex",
  232. ":token_kind",
  233. ":tokenized_buffer",
  234. ":tokenized_buffer_test_helpers",
  235. "//testing/base:gtest_main",
  236. "//testing/base:test_raw_ostream",
  237. "//toolchain/base:shared_value_stores",
  238. "//toolchain/diagnostics:diagnostic_emitter",
  239. "//toolchain/diagnostics:mocks",
  240. "//toolchain/testing:compile_helper",
  241. "//toolchain/testing:yaml_test_helpers",
  242. "@googletest//:gtest",
  243. "@llvm-project//llvm:Support",
  244. ],
  245. )
  246. cc_fuzz_test(
  247. name = "tokenized_buffer_fuzzer",
  248. size = "small",
  249. srcs = ["tokenized_buffer_fuzzer.cpp"],
  250. corpus = glob(["fuzzer_corpus/tokenized_buffer/*"]),
  251. deps = [
  252. ":lex",
  253. "//common:check",
  254. "//testing/fuzzing:libfuzzer_header",
  255. "//toolchain/base:shared_value_stores",
  256. "//toolchain/diagnostics:diagnostic_emitter",
  257. "//toolchain/diagnostics:null_diagnostics",
  258. "@llvm-project//llvm:Support",
  259. ],
  260. )
  261. cc_binary(
  262. name = "tokenized_buffer_benchmark",
  263. testonly = 1,
  264. srcs = ["tokenized_buffer_benchmark.cpp"],
  265. deps = [
  266. ":lex",
  267. ":token_kind",
  268. ":tokenized_buffer",
  269. "//common:check",
  270. "//testing/base:benchmark_main",
  271. "//testing/base:source_gen_lib",
  272. "//toolchain/base:shared_value_stores",
  273. "//toolchain/diagnostics:diagnostic_emitter",
  274. "//toolchain/diagnostics:null_diagnostics",
  275. "@abseil-cpp//absl/random",
  276. "@google_benchmark//:benchmark",
  277. "@llvm-project//llvm:Support",
  278. ],
  279. )