BUILD 8.1 KB

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