WORKSPACE 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. skylib_version = "1.3.0"
  7. http_archive(
  8. name = "bazel_skylib",
  9. sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
  10. urls = [
  11. "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz".format(skylib_version),
  12. "https://github.com/bazelbuild/bazel-skylib/releases/download/{0}/bazel-skylib-{0}.tar.gz".format(skylib_version),
  13. ],
  14. )
  15. ###############################################################################
  16. # Python rules
  17. ###############################################################################
  18. rules_python_version = "0.8.1"
  19. # Add Bazel's python rules and set up pip.
  20. http_archive(
  21. name = "rules_python",
  22. sha256 = "cdf6b84084aad8f10bf20b46b77cb48d83c319ebe6458a18e9d2cebf57807cdd",
  23. strip_prefix = "rules_python-{0}".format(rules_python_version),
  24. url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/{0}.tar.gz".format(rules_python_version),
  25. )
  26. load("@rules_python//python:pip.bzl", "pip_install")
  27. # Create a central repo that knows about the pip dependencies.
  28. pip_install(
  29. name = "py_deps",
  30. requirements = "//github_tools:requirements.txt",
  31. )
  32. ###############################################################################
  33. # C++ rules
  34. ###############################################################################
  35. # Configure the bootstrapped Clang and LLVM toolchain for Bazel.
  36. load(
  37. "//bazel/cc_toolchains:clang_configuration.bzl",
  38. "configure_clang_toolchain",
  39. )
  40. configure_clang_toolchain(name = "bazel_cc_toolchain")
  41. ###############################################################################
  42. # Abseil libraries
  43. ###############################################################################
  44. # Head as of 2022-09-13.
  45. abseil_version = "530cd52f585c9d31b2b28cea7e53915af7a878e3"
  46. http_archive(
  47. name = "com_google_absl",
  48. sha256 = "f8a6789514a3b109111252af92da41d6e64f90efca9fb70515d86debee57dc24",
  49. strip_prefix = "abseil-cpp-{0}".format(abseil_version),
  50. urls = ["https://github.com/abseil/abseil-cpp/archive/{0}.tar.gz".format(abseil_version)],
  51. )
  52. ###############################################################################
  53. # RE2 libraries
  54. ###############################################################################
  55. # Head as of 2022-09-14.
  56. re2_version = "cc1c9db8bf5155d89d10d65998cdb226f676492c"
  57. http_archive(
  58. name = "com_googlesource_code_re2",
  59. sha256 = "8ef976c79a300f8c5e880535665bd4ba146fb09fb6d2342f8f1a02d9af29f365",
  60. strip_prefix = "re2-{0}".format(re2_version),
  61. urls = ["https://github.com/google/re2/archive/{0}.tar.gz".format(re2_version)],
  62. )
  63. ###############################################################################
  64. # GoogleTest libraries
  65. ###############################################################################
  66. # Head as of 2022-09-14.
  67. googletest_version = "1336c4b6d1a6f4bc6beebccb920e5ff858889292"
  68. http_archive(
  69. name = "com_google_googletest",
  70. sha256 = "d701aaeb9a258afba27210d746d971042be96c371ddc5a49f1e8914d9ea17e3c",
  71. strip_prefix = "googletest-{0}".format(googletest_version),
  72. urls = ["https://github.com/google/googletest/archive/{0}.tar.gz".format(googletest_version)],
  73. )
  74. ###############################################################################
  75. # Google Benchmark libraries
  76. ###############################################################################
  77. benchmark_version = "1.6.1"
  78. http_archive(
  79. name = "com_github_google_benchmark",
  80. sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
  81. strip_prefix = "benchmark-{0}".format(benchmark_version),
  82. urls = ["https://github.com/google/benchmark/archive/refs/tags/v{0}.tar.gz".format(benchmark_version)],
  83. )
  84. ###############################################################################
  85. # LLVM libraries
  86. ###############################################################################
  87. # We pin to specific upstream commits and try to track top-of-tree reasonably
  88. # closely rather than pinning to a specific release.
  89. llvm_version = "ecfa2d3d9943a48411d04a4b3103c42b4653d9af"
  90. http_archive(
  91. name = "llvm-raw",
  92. build_file_content = "# empty",
  93. patch_args = ["-p1"],
  94. patches = [
  95. "@carbon//bazel/patches/llvm:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  96. "@carbon//bazel/patches/llvm:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  97. ],
  98. sha256 = "8e9cbb937b1a40536cd809e09603a1810d86a8c314fee0cca36fc493e78289e5",
  99. strip_prefix = "llvm-project-{0}".format(llvm_version),
  100. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_version)],
  101. )
  102. load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
  103. llvm_configure(
  104. name = "llvm-project",
  105. repo_mapping = {"@llvm_zlib": "@zlib"},
  106. targets = [
  107. "AArch64",
  108. "X86",
  109. ],
  110. )
  111. load("@llvm-raw//utils/bazel:terminfo.bzl", "llvm_terminfo_system")
  112. # We require successful detection and use of a system terminfo library.
  113. llvm_terminfo_system(name = "llvm_terminfo")
  114. load("@llvm-raw//utils/bazel:zlib.bzl", "llvm_zlib_system")
  115. # We require successful detection and use of a system zlib library.
  116. llvm_zlib_system(name = "zlib")
  117. ###############################################################################
  118. # Flex/Bison rules
  119. ###############################################################################
  120. rules_m4_version = "0.2.1"
  121. http_archive(
  122. name = "rules_m4",
  123. patch_args = ["-p1"],
  124. patches = [
  125. # Trying to upstream: https://github.com/jmillikin/rules_m4/pull/15
  126. "@carbon//bazel/patches/m4:0001_Support_M4_building_on_FreeBSD.patch",
  127. ],
  128. sha256 = "eaa674cd84546038ecbcc49cdd346134a20961a41fa1a541e80d8bf4b470c34d",
  129. strip_prefix = "rules_m4-{0}".format(rules_m4_version),
  130. urls = ["https://github.com/jmillikin/rules_m4/archive/v{0}.tar.gz".format(rules_m4_version)],
  131. )
  132. load("@rules_m4//m4:m4.bzl", "m4_register_toolchains")
  133. # When building M4, disable all compiler warnings as we can't realistically fix
  134. # them anyways.
  135. m4_register_toolchains(extra_copts = ["-w"])
  136. # TODO: Can switch to a normal release version when it includes:
  137. # https://github.com/jmillikin/rules_flex/commit/1f1d9c306c2b4b8be2cb899a3364b84302124e77
  138. rules_flex_version = "1f1d9c306c2b4b8be2cb899a3364b84302124e77"
  139. http_archive(
  140. name = "rules_flex",
  141. sha256 = "a4e99a0a241c8a5aa238e81724ea3529722522c3702fd3aa674add5eb9807002",
  142. strip_prefix = "rules_flex-{0}".format(rules_flex_version),
  143. urls = ["https://github.com/jmillikin/rules_flex/archive/{0}.tar.gz".format(rules_flex_version)],
  144. )
  145. load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
  146. # When building Flex, disable all compiler warnings as we can't realistically
  147. # fix them anyways.
  148. flex_register_toolchains(extra_copts = ["-w"])
  149. # TODO: Can switch to a normal release version when it includes:
  150. # https://github.com/jmillikin/rules_bison/commit/478079b28605a38000eaf83719568d756b3383a0
  151. rules_bison_version = "478079b28605a38000eaf83719568d756b3383a0"
  152. http_archive(
  153. name = "rules_bison",
  154. patch_args = ["-p1"],
  155. patches = [
  156. # Trying to upstream: https://github.com/jmillikin/rules_bison/pull/13
  157. "@carbon//bazel/patches/bison:0001_Support_Bison_building_on_FreeBSD.patch",
  158. ],
  159. sha256 = "6bc2d382e4ffccd66e60a74521c24722fc8fdfe9af49ff182f79bb5994fa1ba4",
  160. strip_prefix = "rules_bison-{0}".format(rules_bison_version),
  161. urls = ["https://github.com/jmillikin/rules_bison/archive/{0}.tar.gz".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. )