BUILD 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
  5. load("llvm_tools.bzl", "LLVM_MAIN_TOOLS", "generate_llvm_tools_def")
  6. load("runtime_sources.bzl", "generate_runtime_sources_cc_library")
  7. package(default_visibility = ["//visibility:public"])
  8. cc_library(
  9. name = "block_value_store",
  10. hdrs = ["block_value_store.h"],
  11. deps = [
  12. ":id_tag",
  13. ":mem_usage",
  14. ":value_store",
  15. ":yaml",
  16. "//common:check",
  17. "//common:hashing",
  18. "//common:set",
  19. "@llvm-project//llvm:Support",
  20. ],
  21. )
  22. cc_library(
  23. name = "canonical_value_store",
  24. hdrs = ["canonical_value_store.h"],
  25. deps = [
  26. ":mem_usage",
  27. ":value_store",
  28. ":value_store_types",
  29. ":yaml",
  30. "//common:hashtable_key_context",
  31. "//common:set",
  32. ],
  33. )
  34. cc_test(
  35. name = "canonical_value_store_test",
  36. size = "small",
  37. srcs = ["canonical_value_store_test.cpp"],
  38. deps = [
  39. ":canonical_value_store",
  40. ":value_ids",
  41. "//testing/base:gtest_main",
  42. "@googletest//:gtest",
  43. "@llvm-project//llvm:Support",
  44. ],
  45. )
  46. cc_library(
  47. name = "clang_invocation",
  48. srcs = ["clang_invocation.cpp"],
  49. hdrs = ["clang_invocation.h"],
  50. deps = [
  51. ":install_paths",
  52. "//common:check",
  53. "//common:string_helpers",
  54. "//toolchain/diagnostics:diagnostic_emitter",
  55. "@llvm-project//clang:basic",
  56. "@llvm-project//clang:frontend",
  57. "@llvm-project//llvm:Support",
  58. ],
  59. )
  60. cc_library(
  61. name = "fixed_size_value_store",
  62. hdrs = ["fixed_size_value_store.h"],
  63. deps = [
  64. ":mem_usage",
  65. ":value_store",
  66. ":value_store_types",
  67. "//common:check",
  68. "@llvm-project//llvm:Support",
  69. ],
  70. )
  71. cc_library(
  72. name = "for_each_macro",
  73. hdrs = ["for_each_macro.h"],
  74. deps = [
  75. "@llvm-project//llvm:Support",
  76. ],
  77. )
  78. cc_library(
  79. name = "id_tag",
  80. hdrs = ["id_tag.h"],
  81. deps = [
  82. "//common:check",
  83. "//common:ostream",
  84. "@llvm-project//llvm:Support",
  85. ],
  86. )
  87. cc_library(
  88. name = "index_base",
  89. hdrs = ["index_base.h"],
  90. deps = [
  91. "//common:ostream",
  92. "@llvm-project//llvm:Support",
  93. ],
  94. )
  95. # A library for computing install paths for the toolchain. Note that this
  96. # library does *not* include the data itself, as that would form a dependency
  97. # cycle. Each part of the toolchain should add the narrow data file groups to
  98. # their data dependencies, and then use this library to locate them.
  99. cc_library(
  100. name = "install_paths",
  101. srcs = ["install_paths.cpp"],
  102. hdrs = ["install_paths.h"],
  103. deps = [
  104. ":llvm_tools",
  105. "//common:check",
  106. "//common:error",
  107. "//common:filesystem",
  108. "@bazel_tools//tools/cpp/runfiles",
  109. "@llvm-project//clang:basic",
  110. "@llvm-project//llvm:Support",
  111. ],
  112. )
  113. cc_binary(
  114. name = "test_binary",
  115. testonly = 1,
  116. srcs = ["test_binary.cpp"],
  117. data = ["//toolchain/install:install_data"],
  118. )
  119. cc_test(
  120. name = "install_paths_test",
  121. size = "small",
  122. srcs = ["install_paths_test.cpp"],
  123. data = [
  124. ":test_binary",
  125. "//toolchain/install:install_data",
  126. ],
  127. deps = [
  128. ":install_paths",
  129. "//common:check",
  130. "//common:error_test_helpers",
  131. "//common:filesystem",
  132. "//common:ostream",
  133. "//testing/base:global_exe_path",
  134. "//testing/base:gtest_main",
  135. "@bazel_tools//tools/cpp/runfiles",
  136. "@googletest//:gtest",
  137. "@llvm-project//llvm:Support",
  138. ],
  139. )
  140. cc_library(
  141. name = "install_paths_test_helpers",
  142. testonly = 1,
  143. srcs = ["install_paths_test_helpers.cpp"],
  144. hdrs = ["install_paths_test_helpers.h"],
  145. deps = [
  146. ":install_paths",
  147. "//testing/base:global_exe_path",
  148. "@llvm-project//llvm:Support",
  149. ],
  150. )
  151. cc_library(
  152. name = "kind_switch",
  153. hdrs = ["kind_switch.h"],
  154. deps = [
  155. ":for_each_macro",
  156. "@llvm-project//llvm:Support",
  157. ],
  158. )
  159. cc_test(
  160. name = "kind_switch_test",
  161. size = "small",
  162. srcs = ["kind_switch_test.cpp"],
  163. deps = [
  164. ":kind_switch",
  165. "//common:raw_string_ostream",
  166. "//testing/base:gtest_main",
  167. "@googletest//:gtest",
  168. ],
  169. )
  170. cc_library(
  171. name = "mem_usage",
  172. hdrs = ["mem_usage.h"],
  173. deps = [
  174. ":yaml",
  175. "//common:map",
  176. "//common:set",
  177. "@llvm-project//llvm:Support",
  178. ],
  179. )
  180. cc_library(
  181. name = "relational_value_store",
  182. hdrs = ["relational_value_store.h"],
  183. deps = [
  184. ":value_store",
  185. ":value_store_types",
  186. "//common:check",
  187. "@llvm-project//llvm:Support",
  188. ],
  189. )
  190. cc_library(
  191. name = "timings",
  192. hdrs = ["timings.h"],
  193. deps = [
  194. ":yaml",
  195. "@llvm-project//llvm:Support",
  196. ],
  197. )
  198. cc_library(
  199. name = "value_ids",
  200. hdrs = ["value_ids.h"],
  201. deps = [
  202. ":index_base",
  203. "//common:check",
  204. "//common:ostream",
  205. "@llvm-project//llvm:Support",
  206. ],
  207. )
  208. cc_library(
  209. name = "value_store",
  210. hdrs = ["value_store.h"],
  211. deps = [
  212. ":id_tag",
  213. ":mem_usage",
  214. ":value_store_types",
  215. ":yaml",
  216. "//common:check",
  217. "//common:hashtable_key_context",
  218. "//common:ostream",
  219. "//common:set",
  220. "@llvm-project//llvm:Support",
  221. ],
  222. )
  223. cc_test(
  224. name = "value_store_test",
  225. size = "small",
  226. srcs = ["value_store_test.cpp"],
  227. deps = [
  228. ":value_ids",
  229. ":value_store",
  230. "//common:raw_string_ostream",
  231. "//testing/base:gtest_main",
  232. "@googletest//:gtest",
  233. ],
  234. )
  235. cc_library(
  236. name = "value_store_types",
  237. hdrs = ["value_store_types.h"],
  238. deps = [
  239. "@llvm-project//llvm:Support",
  240. ],
  241. )
  242. cc_library(
  243. name = "int",
  244. srcs = ["int.cpp"],
  245. hdrs = ["int.h"],
  246. deps = [
  247. ":canonical_value_store",
  248. ":index_base",
  249. ":mem_usage",
  250. ":value_store",
  251. ":yaml",
  252. "//common:check",
  253. "//common:hashtable_key_context",
  254. "//common:ostream",
  255. "//common:set",
  256. "@llvm-project//llvm:Support",
  257. ],
  258. )
  259. cc_test(
  260. name = "int_test",
  261. size = "small",
  262. srcs = ["int_test.cpp"],
  263. deps = [
  264. ":int",
  265. "//common:raw_string_ostream",
  266. "//testing/base:gtest_main",
  267. "//toolchain/testing:yaml_test_helpers",
  268. "@googletest//:gtest",
  269. ],
  270. )
  271. generate_llvm_tools_def(
  272. name = "llvm_tools_def",
  273. out = "llvm_tools.def",
  274. )
  275. config_setting(
  276. name = "is_macos",
  277. constraint_values = ["@platforms//os:macos"],
  278. )
  279. cc_library(
  280. name = "llvm_tools",
  281. srcs = ["llvm_tools.cpp"],
  282. hdrs = ["llvm_tools.h"],
  283. linkopts = select({
  284. # TODO: This should be moved upstream to LLVM's tool libraries that
  285. # require it.
  286. ":is_macos": [
  287. "-framework",
  288. "CoreFoundation",
  289. ],
  290. "//conditions:default": [],
  291. }),
  292. deps = [
  293. ":llvm_tools_def",
  294. "//common:command_line",
  295. "//common:enum_base",
  296. "@llvm-project//llvm:Support",
  297. ] + [info.lib for info in LLVM_MAIN_TOOLS.values()],
  298. )
  299. generate_runtime_sources_cc_library(name = "runtime_sources")
  300. cc_library(
  301. name = "shared_value_stores",
  302. hdrs = ["shared_value_stores.h"],
  303. deps = [
  304. ":canonical_value_store",
  305. ":int",
  306. ":mem_usage",
  307. ":value_ids",
  308. ":value_store",
  309. ":yaml",
  310. "@llvm-project//llvm:Support",
  311. ],
  312. )
  313. cc_test(
  314. name = "shared_value_stores_test",
  315. size = "small",
  316. srcs = ["shared_value_stores_test.cpp"],
  317. deps = [
  318. ":shared_value_stores",
  319. "//common:raw_string_ostream",
  320. "//testing/base:gtest_main",
  321. "//toolchain/testing:yaml_test_helpers",
  322. "@googletest//:gtest",
  323. ],
  324. )
  325. cc_library(
  326. name = "yaml",
  327. hdrs = ["yaml.h"],
  328. deps = [
  329. "//common:check",
  330. "//common:ostream",
  331. "@llvm-project//llvm:Support",
  332. ],
  333. )