BUILD 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  5. load("//bazel/sh_run:rules.bzl", "glob_sh_run")
  6. load("//testing/file_test:rules.bzl", "file_test")
  7. package(default_visibility = ["//visibility:public"])
  8. cc_library(
  9. name = "token_kind",
  10. srcs = ["token_kind.cpp"],
  11. hdrs = ["token_kind.h"],
  12. textual_hdrs = ["token_kind.def"],
  13. deps = [
  14. "//common:check",
  15. "//common:enum_base",
  16. "@llvm-project//llvm:Support",
  17. ],
  18. )
  19. cc_test(
  20. name = "token_kind_test",
  21. size = "small",
  22. srcs = ["token_kind_test.cpp"],
  23. deps = [
  24. ":token_kind",
  25. "//testing/base:gtest_main",
  26. "@com_google_googletest//:gtest",
  27. "@llvm-project//llvm:Support",
  28. ],
  29. )
  30. cc_library(
  31. name = "character_set",
  32. hdrs = ["character_set.h"],
  33. deps = ["@llvm-project//llvm:Support"],
  34. )
  35. cc_library(
  36. name = "lex_helpers",
  37. srcs = ["lex_helpers.cpp"],
  38. hdrs = ["lex_helpers.h"],
  39. deps = [
  40. "//toolchain/diagnostics:diagnostic_emitter",
  41. "@llvm-project//llvm:Support",
  42. ],
  43. )
  44. cc_library(
  45. name = "test_helpers",
  46. testonly = 1,
  47. hdrs = ["test_helpers.h"],
  48. deps = [
  49. "//common:check",
  50. "//common:string_helpers",
  51. "//toolchain/diagnostics:diagnostic_emitter",
  52. "@com_google_googletest//:gtest",
  53. "@llvm-project//llvm:Support",
  54. ],
  55. )
  56. cc_library(
  57. name = "numeric_literal",
  58. srcs = ["numeric_literal.cpp"],
  59. hdrs = ["numeric_literal.h"],
  60. deps = [
  61. ":character_set",
  62. ":lex_helpers",
  63. "//common:check",
  64. "//toolchain/diagnostics:diagnostic_emitter",
  65. "@llvm-project//llvm:Support",
  66. ],
  67. )
  68. cc_binary(
  69. name = "numeric_literal_benchmark",
  70. testonly = 1,
  71. srcs = ["numeric_literal_benchmark.cpp"],
  72. deps = [
  73. ":numeric_literal",
  74. "//common:check",
  75. "//toolchain/diagnostics:null_diagnostics",
  76. "@com_github_google_benchmark//:benchmark_main",
  77. ],
  78. )
  79. cc_test(
  80. name = "numeric_literal_test",
  81. size = "small",
  82. srcs = ["numeric_literal_test.cpp"],
  83. deps = [
  84. ":numeric_literal",
  85. ":test_helpers",
  86. "//common:check",
  87. "//common:ostream",
  88. "//testing/base:gtest_main",
  89. "//toolchain/diagnostics:diagnostic_emitter",
  90. "@com_google_googletest//:gtest",
  91. "@llvm-project//llvm:Support",
  92. ],
  93. )
  94. cc_fuzz_test(
  95. name = "numeric_literal_fuzzer",
  96. size = "small",
  97. srcs = ["numeric_literal_fuzzer.cpp"],
  98. corpus = glob(["fuzzer_corpus/numeric_literal/*"]),
  99. deps = [
  100. ":numeric_literal",
  101. "//toolchain/diagnostics:diagnostic_emitter",
  102. "//toolchain/diagnostics:null_diagnostics",
  103. "@llvm-project//llvm:Support",
  104. ],
  105. )
  106. cc_library(
  107. name = "string_literal",
  108. srcs = ["string_literal.cpp"],
  109. hdrs = ["string_literal.h"],
  110. deps = [
  111. ":character_set",
  112. ":lex_helpers",
  113. "//common:check",
  114. "//toolchain/diagnostics:diagnostic_emitter",
  115. "@llvm-project//llvm:Support",
  116. ],
  117. )
  118. cc_binary(
  119. name = "string_literal_benchmark",
  120. testonly = 1,
  121. srcs = ["string_literal_benchmark.cpp"],
  122. deps = [
  123. ":string_literal",
  124. "//toolchain/diagnostics:null_diagnostics",
  125. "@com_github_google_benchmark//:benchmark_main",
  126. ],
  127. )
  128. cc_test(
  129. name = "string_literal_test",
  130. size = "small",
  131. srcs = ["string_literal_test.cpp"],
  132. deps = [
  133. ":string_literal",
  134. ":test_helpers",
  135. "//common:check",
  136. "//common:ostream",
  137. "//testing/base:gtest_main",
  138. "//toolchain/diagnostics:diagnostic_emitter",
  139. "@com_google_googletest//:gtest",
  140. "@llvm-project//llvm:Support",
  141. ],
  142. )
  143. cc_fuzz_test(
  144. name = "string_literal_fuzzer",
  145. size = "small",
  146. srcs = ["string_literal_fuzzer.cpp"],
  147. corpus = glob(["fuzzer_corpus/string_literal/*"]),
  148. deps = [
  149. ":string_literal",
  150. "//common:check",
  151. "//toolchain/diagnostics:diagnostic_emitter",
  152. "//toolchain/diagnostics:null_diagnostics",
  153. "@llvm-project//llvm:Support",
  154. ],
  155. )
  156. cc_library(
  157. name = "tokenized_buffer",
  158. srcs = ["tokenized_buffer.cpp"],
  159. hdrs = ["tokenized_buffer.h"],
  160. deps = [
  161. ":character_set",
  162. ":lex_helpers",
  163. ":numeric_literal",
  164. ":string_literal",
  165. ":token_kind",
  166. "//common:check",
  167. "//common:ostream",
  168. "//common:string_helpers",
  169. "//toolchain/base:index_base",
  170. "//toolchain/diagnostics:diagnostic_emitter",
  171. "//toolchain/source:source_buffer",
  172. "@llvm-project//llvm:Support",
  173. ],
  174. )
  175. cc_library(
  176. name = "tokenized_buffer_test_helpers",
  177. testonly = 1,
  178. hdrs = ["tokenized_buffer_test_helpers.h"],
  179. deps = [
  180. ":tokenized_buffer",
  181. "//common:check",
  182. "@com_google_googletest//:gtest",
  183. "@llvm-project//llvm:Support",
  184. ],
  185. )
  186. cc_test(
  187. name = "tokenized_buffer_test",
  188. size = "small",
  189. srcs = ["tokenized_buffer_test.cpp"],
  190. deps = [
  191. ":tokenized_buffer",
  192. ":tokenized_buffer_test_helpers",
  193. "//testing/base:gtest_main",
  194. "//testing/base:test_raw_ostream",
  195. "//toolchain/base:yaml_test_helpers",
  196. "//toolchain/diagnostics:diagnostic_emitter",
  197. "//toolchain/diagnostics:mocks",
  198. "@com_google_googletest//:gtest",
  199. "@llvm-project//llvm:Support",
  200. ],
  201. )
  202. cc_fuzz_test(
  203. name = "tokenized_buffer_fuzzer",
  204. size = "small",
  205. srcs = ["tokenized_buffer_fuzzer.cpp"],
  206. corpus = glob(["fuzzer_corpus/tokenized_buffer/*"]),
  207. deps = [
  208. ":tokenized_buffer",
  209. "//common:check",
  210. "//toolchain/diagnostics:diagnostic_emitter",
  211. "//toolchain/diagnostics:null_diagnostics",
  212. "@llvm-project//llvm:Support",
  213. ],
  214. )
  215. file_test(
  216. name = "lexer_file_test",
  217. srcs = ["lexer_file_test.cpp"],
  218. tests = glob(["testdata/**/*.carbon"]),
  219. deps = [
  220. "//toolchain/driver:driver_file_test_base",
  221. "@com_googlesource_code_re2//:re2",
  222. "@llvm-project//llvm:Support",
  223. ],
  224. )
  225. glob_sh_run(
  226. args = [
  227. "$(location //toolchain/driver:carbon)",
  228. "dump",
  229. "tokens",
  230. ],
  231. data = ["//toolchain/driver:carbon"],
  232. file_exts = ["carbon"],
  233. )