BUILD 7.8 KB

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