WORKSPACE 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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.8.1"
  20. # Add Bazel's python rules and set up pip.
  21. http_archive(
  22. name = "rules_python",
  23. sha256 = "cdf6b84084aad8f10bf20b46b77cb48d83c319ebe6458a18e9d2cebf57807cdd",
  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:pip.bzl", "pip_install")
  28. # Create a central repo that knows about the pip dependencies.
  29. pip_install(
  30. name = "py_deps",
  31. requirements = "//github_tools:requirements.txt",
  32. )
  33. ###############################################################################
  34. # C++ rules
  35. ###############################################################################
  36. # Configure the bootstrapped Clang and LLVM toolchain for Bazel.
  37. load(
  38. "//bazel/cc_toolchains:clang_configuration.bzl",
  39. "configure_clang_toolchain",
  40. )
  41. configure_clang_toolchain(name = "bazel_cc_toolchain")
  42. ###############################################################################
  43. # Abseil libraries
  44. ###############################################################################
  45. # Head as of 2022-09-13.
  46. abseil_version = "530cd52f585c9d31b2b28cea7e53915af7a878e3"
  47. http_archive(
  48. name = "com_google_absl",
  49. sha256 = "f8a6789514a3b109111252af92da41d6e64f90efca9fb70515d86debee57dc24",
  50. strip_prefix = "abseil-cpp-{0}".format(abseil_version),
  51. urls = ["https://github.com/abseil/abseil-cpp/archive/{0}.tar.gz".format(abseil_version)],
  52. )
  53. ###############################################################################
  54. # RE2 libraries
  55. ###############################################################################
  56. # Head as of 2022-09-14.
  57. re2_version = "cc1c9db8bf5155d89d10d65998cdb226f676492c"
  58. http_archive(
  59. name = "com_googlesource_code_re2",
  60. sha256 = "8ef976c79a300f8c5e880535665bd4ba146fb09fb6d2342f8f1a02d9af29f365",
  61. strip_prefix = "re2-{0}".format(re2_version),
  62. urls = ["https://github.com/google/re2/archive/{0}.tar.gz".format(re2_version)],
  63. )
  64. ###############################################################################
  65. # GoogleTest libraries
  66. ###############################################################################
  67. # Head as of 2022-09-14.
  68. googletest_version = "1336c4b6d1a6f4bc6beebccb920e5ff858889292"
  69. http_archive(
  70. name = "com_google_googletest",
  71. sha256 = "d701aaeb9a258afba27210d746d971042be96c371ddc5a49f1e8914d9ea17e3c",
  72. strip_prefix = "googletest-{0}".format(googletest_version),
  73. urls = ["https://github.com/google/googletest/archive/{0}.tar.gz".format(googletest_version)],
  74. )
  75. ###############################################################################
  76. # Google Benchmark libraries
  77. ###############################################################################
  78. benchmark_version = "1.6.1"
  79. http_archive(
  80. name = "com_github_google_benchmark",
  81. sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
  82. strip_prefix = "benchmark-{0}".format(benchmark_version),
  83. urls = ["https://github.com/google/benchmark/archive/refs/tags/v{0}.tar.gz".format(benchmark_version)],
  84. )
  85. ###############################################################################
  86. # LLVM libraries
  87. ###############################################################################
  88. # We pin to specific upstream commits and try to track top-of-tree reasonably
  89. # closely rather than pinning to a specific release.
  90. llvm_version = "c5f6a287499a816cba5585708999e2c8b134290f"
  91. http_archive(
  92. name = "llvm-raw",
  93. build_file_content = "# empty",
  94. patch_args = ["-p1"],
  95. patches = [
  96. "@carbon//bazel/patches/llvm:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  97. "@carbon//bazel/patches/llvm:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  98. "@carbon//bazel/patches/llvm:0003_Modernize_py_binary_rule_for_lit.patch",
  99. ],
  100. sha256 = "03a8eb4b243846ee037d700b048ec48a87eeef480cb129ab56aa7e0537172b98",
  101. strip_prefix = "llvm-project-{0}".format(llvm_version),
  102. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_version)],
  103. )
  104. load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
  105. llvm_configure(
  106. name = "llvm-project",
  107. targets = [
  108. "AArch64",
  109. "X86",
  110. ],
  111. )
  112. # Dependencies copied from
  113. # https://github.com/llvm/llvm-project/blob/main/utils/bazel/WORKSPACE.
  114. maybe(
  115. http_archive,
  116. name = "llvm_zlib",
  117. build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD",
  118. sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731",
  119. strip_prefix = "zlib-ng-2.0.7",
  120. urls = [
  121. "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip",
  122. ],
  123. )
  124. maybe(
  125. http_archive,
  126. name = "llvm_zstd",
  127. build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD",
  128. sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0",
  129. strip_prefix = "zstd-1.5.2",
  130. urls = [
  131. "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz",
  132. ],
  133. )
  134. ###############################################################################
  135. # Flex/Bison rules
  136. ###############################################################################
  137. rules_m4_version = "0.2.3"
  138. http_archive(
  139. name = "rules_m4",
  140. sha256 = "10ce41f150ccfbfddc9d2394ee680eb984dc8a3dfea613afd013cfb22ea7445c",
  141. urls = ["https://github.com/jmillikin/rules_m4/releases/download/v{0}/rules_m4-v{0}.tar.xz".format(rules_m4_version)],
  142. )
  143. load("@rules_m4//m4:m4.bzl", "m4_register_toolchains")
  144. # When building M4, disable all compiler warnings as we can't realistically fix
  145. # them anyways.
  146. m4_register_toolchains(extra_copts = ["-w"])
  147. rules_flex_version = "0.2.1"
  148. http_archive(
  149. name = "rules_flex",
  150. sha256 = "8929fedc40909d19a4b42548d0785f796c7677dcef8b5d1600b415e5a4a7749f",
  151. urls = ["https://github.com/jmillikin/rules_flex/releases/download/v{0}/rules_flex-v{0}.tar.xz".format(rules_flex_version)],
  152. )
  153. load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
  154. # When building Flex, disable all compiler warnings as we can't realistically
  155. # fix them anyways.
  156. flex_register_toolchains(extra_copts = ["-w"])
  157. rules_bison_version = "0.2.2"
  158. http_archive(
  159. name = "rules_bison",
  160. sha256 = "2279183430e438b2dc77cacd7b1dbb63438971b2411406570f1ddd920b7c9145",
  161. urls = ["https://github.com/jmillikin/rules_bison/releases/download/v{0}/rules_bison-v{0}.tar.xz".format(rules_bison_version)],
  162. )
  163. load("@rules_bison//bison:bison.bzl", "bison_register_toolchains")
  164. # When building Bison, disable all compiler warnings as we can't realistically
  165. # fix them anyways.
  166. bison_register_toolchains(extra_copts = ["-w"])
  167. ###############################################################################
  168. # Protocol buffers - for structured fuzzer testing.
  169. ###############################################################################
  170. rules_cc_version = "0.0.4"
  171. http_archive(
  172. name = "rules_cc",
  173. sha256 = "af6cc82d87db94585bceeda2561cb8a9d55ad435318ccb4ddfee18a43580fb5d",
  174. strip_prefix = "rules_cc-{0}".format(rules_cc_version),
  175. urls = ["https://github.com/bazelbuild/rules_cc/releases/download/{0}/rules_cc-{0}.tar.gz".format(rules_cc_version)],
  176. )
  177. rules_proto_version = "5.3.0-21.7"
  178. http_archive(
  179. name = "rules_proto",
  180. sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
  181. strip_prefix = "rules_proto-{0}".format(rules_proto_version),
  182. urls = ["https://github.com/bazelbuild/rules_proto/archive/refs/tags/{0}.tar.gz".format(rules_proto_version)],
  183. )
  184. load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
  185. rules_proto_dependencies()
  186. rules_proto_toolchains()
  187. ###############################################################################
  188. # libprotobuf_mutator - for structured fuzzer testing.
  189. ###############################################################################
  190. libprotobuf_mutator_version = "1.1"
  191. http_archive(
  192. name = "com_google_libprotobuf_mutator",
  193. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  194. sha256 = "fd299fd72c5cf664259d9bd43a72cb74dc6a8b9604d107fe2d2e90885aeb7c16",
  195. strip_prefix = "libprotobuf-mutator-{0}".format(libprotobuf_mutator_version),
  196. urls = ["https://github.com/google/libprotobuf-mutator/archive/v{0}.tar.gz".format(libprotobuf_mutator_version)],
  197. )
  198. ###############################################################################
  199. # Example conversion repositories
  200. ###############################################################################
  201. local_repository(
  202. name = "brotli",
  203. path = "third_party/examples/brotli/original",
  204. )
  205. new_local_repository(
  206. name = "woff2",
  207. build_file = "third_party/examples/woff2/BUILD.original",
  208. path = "third_party/examples/woff2/original",
  209. workspace_file = "third_party/examples/woff2/WORKSPACE.original",
  210. )
  211. local_repository(
  212. name = "woff2_carbon",
  213. path = "third_party/examples/woff2/carbon",
  214. )