WORKSPACE 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. ###############################################################################
  7. # Python rules
  8. ###############################################################################
  9. rules_python_version = "0.8.1"
  10. # Add Bazel's python rules and set up pip.
  11. http_archive(
  12. name = "rules_python",
  13. sha256 = "cdf6b84084aad8f10bf20b46b77cb48d83c319ebe6458a18e9d2cebf57807cdd",
  14. strip_prefix = "rules_python-%s" % rules_python_version,
  15. url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/%s.tar.gz" % rules_python_version,
  16. )
  17. load("@rules_python//python:pip.bzl", "pip_install")
  18. # Create a central repo that knows about the pip dependencies.
  19. pip_install(
  20. name = "py_deps",
  21. requirements = "//github_tools:requirements.txt",
  22. )
  23. ###############################################################################
  24. # C++ rules
  25. ###############################################################################
  26. # Configure the bootstrapped Clang and LLVM toolchain for Bazel.
  27. load(
  28. "//bazel/cc_toolchains:clang_configuration.bzl",
  29. "configure_clang_toolchain",
  30. )
  31. configure_clang_toolchain(name = "bazel_cc_toolchain")
  32. ###############################################################################
  33. # Abseil libraries
  34. ###############################################################################
  35. # Head as of 2022-09-13.
  36. abseil_version = "530cd52f585c9d31b2b28cea7e53915af7a878e3"
  37. http_archive(
  38. name = "com_google_absl",
  39. sha256 = "f8a6789514a3b109111252af92da41d6e64f90efca9fb70515d86debee57dc24",
  40. strip_prefix = "abseil-cpp-%s" % abseil_version,
  41. urls = ["https://github.com/abseil/abseil-cpp/archive/%s.tar.gz" % abseil_version],
  42. )
  43. ###############################################################################
  44. # RE2 libraries
  45. ###############################################################################
  46. # Head as of 2022-09-14.
  47. re2_version = "cc1c9db8bf5155d89d10d65998cdb226f676492c"
  48. http_archive(
  49. name = "com_googlesource_code_re2",
  50. sha256 = "8ef976c79a300f8c5e880535665bd4ba146fb09fb6d2342f8f1a02d9af29f365",
  51. strip_prefix = "re2-%s" % re2_version,
  52. urls = ["https://github.com/google/re2/archive/%s.tar.gz" % re2_version],
  53. )
  54. ###############################################################################
  55. # GoogleTest libraries
  56. ###############################################################################
  57. # Head as of 2022-09-14.
  58. googletest_version = "1336c4b6d1a6f4bc6beebccb920e5ff858889292"
  59. http_archive(
  60. name = "com_google_googletest",
  61. sha256 = "d701aaeb9a258afba27210d746d971042be96c371ddc5a49f1e8914d9ea17e3c",
  62. strip_prefix = "googletest-%s" % googletest_version,
  63. urls = ["https://github.com/google/googletest/archive/%s.tar.gz" % googletest_version],
  64. )
  65. ###############################################################################
  66. # Google Benchmark libraries
  67. ###############################################################################
  68. benchmark_version = "1.6.1"
  69. http_archive(
  70. name = "com_github_google_benchmark",
  71. sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
  72. strip_prefix = "benchmark-%s" % benchmark_version,
  73. urls = ["https://github.com/google/benchmark/archive/refs/tags/v%s.tar.gz" % benchmark_version],
  74. )
  75. ###############################################################################
  76. # LLVM libraries
  77. ###############################################################################
  78. # We pin to specific upstream commits and try to track top-of-tree reasonably
  79. # closely rather than pinning to a specific release.
  80. llvm_version = "6fa65f8a98967a5d2d2a6863e0f67a40d2961905"
  81. http_archive(
  82. name = "llvm-raw",
  83. build_file_content = "# empty",
  84. patch_args = ["-p1"],
  85. patches = [
  86. "@carbon//bazel/llvm-patches:0001-Patch-for-mallinfo2-when-using-Bazel-build-system.patch",
  87. "@carbon//bazel/llvm-patches:0002-Added-Bazel-build-for-compiler-rt-fuzzer.patch",
  88. ],
  89. sha256 = "0a3929c5f2fe756820277be7b10e95f7480e7cb7f297ec574d3e9ddeac9068d7",
  90. strip_prefix = "llvm-project-%s" % llvm_version,
  91. urls = ["https://github.com/llvm/llvm-project/archive/%s.tar.gz" % llvm_version],
  92. )
  93. load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
  94. llvm_configure(
  95. name = "llvm-project",
  96. repo_mapping = {"@llvm_zlib": "@zlib"},
  97. targets = [
  98. "AArch64",
  99. "X86",
  100. ],
  101. )
  102. load("@llvm-raw//utils/bazel:terminfo.bzl", "llvm_terminfo_system")
  103. # We require successful detection and use of a system terminfo library.
  104. llvm_terminfo_system(name = "llvm_terminfo")
  105. load("@llvm-raw//utils/bazel:zlib.bzl", "llvm_zlib_system")
  106. # We require successful detection and use of a system zlib library.
  107. llvm_zlib_system(name = "zlib")
  108. ###############################################################################
  109. # Flex/Bison rules
  110. ###############################################################################
  111. rules_m4_version = "0.2.1"
  112. http_archive(
  113. name = "rules_m4",
  114. sha256 = "eaa674cd84546038ecbcc49cdd346134a20961a41fa1a541e80d8bf4b470c34d",
  115. strip_prefix = "rules_m4-%s" % rules_m4_version,
  116. urls = ["https://github.com/jmillikin/rules_m4/archive/v%s.tar.gz" %
  117. rules_m4_version],
  118. )
  119. load("@rules_m4//m4:m4.bzl", "m4_register_toolchains")
  120. # When building M4, disable all compiler warnings as we can't realistically fix
  121. # them anyways.
  122. m4_register_toolchains(extra_copts = ["-w"])
  123. # TODO: Can switch to a normal release version when it includes:
  124. # https://github.com/jmillikin/rules_flex/commit/1f1d9c306c2b4b8be2cb899a3364b84302124e77
  125. rules_flex_version = "1f1d9c306c2b4b8be2cb899a3364b84302124e77"
  126. http_archive(
  127. name = "rules_flex",
  128. sha256 = "a4e99a0a241c8a5aa238e81724ea3529722522c3702fd3aa674add5eb9807002",
  129. strip_prefix = "rules_flex-%s" % rules_flex_version,
  130. urls = ["https://github.com/jmillikin/rules_flex/archive/%s.tar.gz" %
  131. rules_flex_version],
  132. )
  133. load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
  134. # When building Flex, disable all compiler warnings as we can't realistically
  135. # fix them anyways.
  136. flex_register_toolchains(extra_copts = ["-w"])
  137. # TODO: Can switch to a normal release version when it includes:
  138. # https://github.com/jmillikin/rules_bison/commit/478079b28605a38000eaf83719568d756b3383a0
  139. rules_bison_version = "478079b28605a38000eaf83719568d756b3383a0"
  140. http_archive(
  141. name = "rules_bison",
  142. sha256 = "6bc2d382e4ffccd66e60a74521c24722fc8fdfe9af49ff182f79bb5994fa1ba4",
  143. strip_prefix = "rules_bison-%s" % rules_bison_version,
  144. urls = ["https://github.com/jmillikin/rules_bison/archive/%s.tar.gz" %
  145. rules_bison_version],
  146. )
  147. load("@rules_bison//bison:bison.bzl", "bison_register_toolchains")
  148. # When building Bison, disable all compiler warnings as we can't realistically
  149. # fix them anyways.
  150. bison_register_toolchains(extra_copts = ["-w"])
  151. ###############################################################################
  152. # Protocol buffers - for structured fuzzer testing.
  153. ###############################################################################
  154. # TODO: `rules_proto` pulls in a version of `rules_cc` with a frozenset bug.
  155. rules_cc_version = "0.0.1"
  156. http_archive(
  157. name = "rules_cc",
  158. sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
  159. urls = ["https://github.com/bazelbuild/rules_cc/releases/download/%s/rules_cc-%s.tar.gz" % (rules_cc_version, rules_cc_version)],
  160. )
  161. rules_proto_version = "4.0.0-3.20.0"
  162. http_archive(
  163. name = "rules_proto",
  164. sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
  165. strip_prefix = "rules_proto-%s" % rules_proto_version,
  166. urls = [
  167. "https://github.com/bazelbuild/rules_proto/archive/refs/tags/%s.tar.gz" % rules_proto_version,
  168. ],
  169. )
  170. load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
  171. rules_proto_dependencies()
  172. rules_proto_toolchains()
  173. ###############################################################################
  174. # libprotobuf_mutator - for structured fuzzer testing.
  175. ###############################################################################
  176. # Head as of 2022-09-13.
  177. libprotobuf_mutator_version = "a304ec48dcf15d942607032151f7e9ee504b5dcf"
  178. http_archive(
  179. name = "com_google_libprotobuf_mutator",
  180. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  181. sha256 = "0ce80217393fe6b01dac9818127e664801d865fefd708b98183181c0ed457878",
  182. strip_prefix = "libprotobuf-mutator-%s" % libprotobuf_mutator_version,
  183. urls = ["https://github.com/google/libprotobuf-mutator/archive/%s.tar.gz" % libprotobuf_mutator_version],
  184. )
  185. ###############################################################################
  186. # Example conversion repositories
  187. ###############################################################################
  188. local_repository(
  189. name = "brotli",
  190. path = "third_party/examples/brotli/original",
  191. )
  192. new_local_repository(
  193. name = "woff2",
  194. build_file = "third_party/examples/woff2/BUILD.original",
  195. path = "third_party/examples/woff2/original",
  196. workspace_file = "third_party/examples/woff2/WORKSPACE.original",
  197. )
  198. local_repository(
  199. name = "woff2_carbon",
  200. path = "third_party/examples/woff2/carbon",
  201. )