WORKSPACE 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. workspace(name = "carbon")
  5. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
  6. load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
  7. skylib_version = "1.3.0"
  8. http_archive(
  9. name = "bazel_skylib",
  10. sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
  11. urls = [
  12. "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz".format(skylib_version),
  13. "https://github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz".format(skylib_version),
  14. ],
  15. )
  16. ###############################################################################
  17. # Python rules
  18. ###############################################################################
  19. rules_python_version = "0.27.0"
  20. # Add Bazel's python rules and set up pip.
  21. http_archive(
  22. name = "rules_python",
  23. sha256 = "9acc0944c94adb23fba1c9988b48768b1bacc6583b52a2586895c5b7491e2e31",
  24. strip_prefix = "rules_python-{0}".format(rules_python_version),
  25. url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/{0}.tar.gz".format(rules_python_version),
  26. )
  27. load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
  28. py_repositories()
  29. python_register_toolchains(
  30. name = "python311",
  31. python_version = "3.11",
  32. )
  33. load("@python311//:defs.bzl", "interpreter")
  34. load("@rules_python//python:pip.bzl", "pip_parse")
  35. # Create a central repo that knows about the pip dependencies.
  36. pip_parse(
  37. name = "py_deps",
  38. python_interpreter_target = interpreter,
  39. requirements_lock = "//github_tools:requirements.txt",
  40. )
  41. load("@py_deps//:requirements.bzl", "install_deps")
  42. install_deps()
  43. ###############################################################################
  44. # C++ rules
  45. ###############################################################################
  46. # Configure the bootstrapped Clang and LLVM toolchain for Bazel.
  47. load(
  48. "//bazel/cc_toolchains:clang_configuration.bzl",
  49. "clang_register_toolchains",
  50. )
  51. clang_register_toolchains(name = "bazel_cc_toolchain")
  52. ###############################################################################
  53. # Abseil libraries
  54. ###############################################################################
  55. # Head as of 2023-07-31.
  56. abseil_version = "407f2fdd5ec6f79287919486aa5869b346093906"
  57. http_archive(
  58. name = "com_google_absl",
  59. sha256 = "953a914ac42f87caf5ed6a86890e183ae4e2bc69666a90c67605091d6e77e502",
  60. strip_prefix = "abseil-cpp-{0}".format(abseil_version),
  61. urls = ["https://github.com/abseil/abseil-cpp/archive/{0}.tar.gz".format(abseil_version)],
  62. )
  63. ###############################################################################
  64. # RE2 libraries
  65. ###############################################################################
  66. # Head as of 2023-07-31.
  67. re2_version = "960c861764ff54c9a12ff683ba55ccaad1a8f73b"
  68. http_archive(
  69. name = "com_googlesource_code_re2",
  70. sha256 = "8315f22198c25e9f7f1a3754566824710c08ddbb39d93e9920f4a131e871fc15",
  71. strip_prefix = "re2-{0}".format(re2_version),
  72. urls = ["https://github.com/google/re2/archive/{0}.tar.gz".format(re2_version)],
  73. )
  74. ###############################################################################
  75. # GoogleTest libraries
  76. ###############################################################################
  77. # Head as of 2023-07-31.
  78. googletest_version = "c875c4e2249ec124c24f72141b3780c22256fd44"
  79. http_archive(
  80. name = "com_google_googletest",
  81. sha256 = "21e0cd1110ba534409facccdda1bad90174e7ee7ded60c00dd2b43b4df654080",
  82. strip_prefix = "googletest-{0}".format(googletest_version),
  83. urls = ["https://github.com/google/googletest/archive/{0}.tar.gz".format(googletest_version)],
  84. )
  85. ###############################################################################
  86. # Google Benchmark libraries
  87. ###############################################################################
  88. benchmark_version = "1.6.1"
  89. http_archive(
  90. name = "com_github_google_benchmark",
  91. sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
  92. strip_prefix = "benchmark-{0}".format(benchmark_version),
  93. urls = ["https://github.com/google/benchmark/archive/refs/tags/v{0}.tar.gz".format(benchmark_version)],
  94. )
  95. ###############################################################################
  96. # LLVM libraries
  97. ###############################################################################
  98. # We pin to specific upstream commits and try to track top-of-tree reasonably
  99. # closely rather than pinning to a specific release.
  100. llvm_version = "3d51010a3350660160981c6b8e624dcc87c208a3"
  101. http_archive(
  102. name = "llvm-raw",
  103. build_file_content = "# empty",
  104. patch_args = ["-p1"],
  105. patches = [
  106. "@carbon//bazel/patches/llvm:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  107. "@carbon//bazel/patches/llvm:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  108. "@carbon//bazel/patches/llvm:0003_Add_library_for_clangd.patch",
  109. ],
  110. sha256 = "efbca707a6eb1c714b849de120309070eef282660c0f4be5b68efef62cc95cf5",
  111. strip_prefix = "llvm-project-{0}".format(llvm_version),
  112. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_version)],
  113. )
  114. load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
  115. llvm_configure(
  116. name = "llvm-project",
  117. targets = [
  118. "AArch64",
  119. "X86",
  120. ],
  121. )
  122. # Dependencies copied from
  123. # https://github.com/llvm/llvm-project/blob/main/utils/bazel/WORKSPACE.
  124. maybe(
  125. http_archive,
  126. name = "llvm_zlib",
  127. build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD",
  128. sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731",
  129. strip_prefix = "zlib-ng-2.0.7",
  130. urls = [
  131. "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip",
  132. ],
  133. )
  134. maybe(
  135. http_archive,
  136. name = "llvm_zstd",
  137. build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD",
  138. sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0",
  139. strip_prefix = "zstd-1.5.2",
  140. urls = [
  141. "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz",
  142. ],
  143. )
  144. ###############################################################################
  145. # Flex/Bison rules
  146. ###############################################################################
  147. rules_m4_version = "0.2.3"
  148. http_archive(
  149. name = "rules_m4",
  150. sha256 = "10ce41f150ccfbfddc9d2394ee680eb984dc8a3dfea613afd013cfb22ea7445c",
  151. urls = ["https://github.com/jmillikin/rules_m4/releases/download/v{0}/rules_m4-v{0}.tar.xz".format(rules_m4_version)],
  152. )
  153. load("@rules_m4//m4:m4.bzl", "m4_register_toolchains")
  154. # When building M4, disable all compiler warnings as we can't realistically fix
  155. # them anyways.
  156. m4_register_toolchains(extra_copts = ["-w"])
  157. rules_flex_version = "0.2.1"
  158. http_archive(
  159. name = "rules_flex",
  160. sha256 = "8929fedc40909d19a4b42548d0785f796c7677dcef8b5d1600b415e5a4a7749f",
  161. urls = ["https://github.com/jmillikin/rules_flex/releases/download/v{0}/rules_flex-v{0}.tar.xz".format(rules_flex_version)],
  162. )
  163. load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
  164. # When building Flex, disable all compiler warnings as we can't realistically
  165. # fix them anyways.
  166. flex_register_toolchains(extra_copts = ["-w"])
  167. rules_bison_version = "0.2.2"
  168. http_archive(
  169. name = "rules_bison",
  170. sha256 = "2279183430e438b2dc77cacd7b1dbb63438971b2411406570f1ddd920b7c9145",
  171. urls = ["https://github.com/jmillikin/rules_bison/releases/download/v{0}/rules_bison-v{0}.tar.xz".format(rules_bison_version)],
  172. )
  173. load("@rules_bison//bison:bison.bzl", "bison_register_toolchains")
  174. # When building Bison, disable all compiler warnings as we can't realistically
  175. # fix them anyways.
  176. bison_register_toolchains(extra_copts = ["-w"])
  177. ###############################################################################
  178. # Protocol buffers - for structured fuzzer testing.
  179. ###############################################################################
  180. rules_cc_version = "0.0.4"
  181. http_archive(
  182. name = "rules_cc",
  183. sha256 = "af6cc82d87db94585bceeda2561cb8a9d55ad435318ccb4ddfee18a43580fb5d",
  184. strip_prefix = "rules_cc-{0}".format(rules_cc_version),
  185. urls = ["https://github.com/bazelbuild/rules_cc/releases/download/{0}/rules_cc-{0}.tar.gz".format(rules_cc_version)],
  186. )
  187. rules_proto_version = "5.3.0-21.7"
  188. http_archive(
  189. name = "rules_proto",
  190. sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
  191. strip_prefix = "rules_proto-{0}".format(rules_proto_version),
  192. urls = ["https://github.com/bazelbuild/rules_proto/archive/refs/tags/{0}.tar.gz".format(rules_proto_version)],
  193. )
  194. load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
  195. rules_proto_dependencies()
  196. rules_proto_toolchains()
  197. ###############################################################################
  198. # libprotobuf_mutator - for structured fuzzer testing.
  199. ###############################################################################
  200. libprotobuf_mutator_version = "1.1"
  201. http_archive(
  202. name = "com_google_libprotobuf_mutator",
  203. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  204. sha256 = "fd299fd72c5cf664259d9bd43a72cb74dc6a8b9604d107fe2d2e90885aeb7c16",
  205. strip_prefix = "libprotobuf-mutator-{0}".format(libprotobuf_mutator_version),
  206. urls = ["https://github.com/google/libprotobuf-mutator/archive/v{0}.tar.gz".format(libprotobuf_mutator_version)],
  207. )
  208. ###############################################################################
  209. # Example conversion repositories
  210. ###############################################################################
  211. local_repository(
  212. name = "brotli",
  213. path = "third_party/examples/brotli/original",
  214. )
  215. new_local_repository(
  216. name = "woff2",
  217. build_file = "third_party/examples/woff2/BUILD.original",
  218. path = "third_party/examples/woff2/original",
  219. workspace_file = "third_party/examples/woff2/WORKSPACE.original",
  220. )
  221. local_repository(
  222. name = "woff2_carbon",
  223. path = "third_party/examples/woff2/carbon",
  224. )
  225. ###############################################################################
  226. # Treesitter rules
  227. ###############################################################################
  228. http_archive(
  229. name = "rules_nodejs",
  230. sha256 = "d124665ea12f89153086746821cf6c9ef93ab88360a50c1aeefa1fe522421704",
  231. strip_prefix = "rules_nodejs-6.0.0-beta1",
  232. url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.0.0-beta1/rules_nodejs-v6.0.0-beta1.tar.gz",
  233. )
  234. load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
  235. nodejs_register_toolchains(
  236. name = "nodejs",
  237. node_version = DEFAULT_NODE_VERSION,
  238. )
  239. http_archive(
  240. name = "rules_tree_sitter",
  241. sha256 = "a09f177a2b8acb2f8a84def6ca0c41a5bd26b25634aa7313f22ade6c54e57ca1",
  242. strip_prefix = "rules_tree_sitter-bc3a2131053207de7dfd9b24046b811ce770e35d",
  243. urls = ["https://github.com/Maan2003/rules_tree_sitter/archive/bc3a2131053207de7dfd9b24046b811ce770e35d.tar.gz"],
  244. )
  245. load("@rules_tree_sitter//tree_sitter:tree_sitter.bzl", "tree_sitter_register_toolchains")
  246. tree_sitter_register_toolchains()