BUILD 8.1 KB

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