WORKSPACE 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. abseil_version = "20211102.0"
  36. http_archive(
  37. name = "com_google_absl",
  38. sha256 = "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
  39. strip_prefix = "abseil-cpp-%s" % abseil_version,
  40. urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/%s.tar.gz" % abseil_version],
  41. )
  42. ###############################################################################
  43. # GoogleTest libraries
  44. ###############################################################################
  45. # Version as of 2021-12-07. Not a major release, but gets a clang-tidy fix.
  46. googletest_version = "4c5650f68866e3c2e60361d5c4c95c6f335fb64b"
  47. http_archive(
  48. name = "com_google_googletest",
  49. sha256 = "770e61fa13d51320736c2881ff6279212e4eab8a9100709fff8c44759f61d126",
  50. strip_prefix = "googletest-%s" % googletest_version,
  51. urls = ["https://github.com/google/googletest/archive/%s.tar.gz" % googletest_version],
  52. )
  53. ###############################################################################
  54. # Google Benchmark libraries
  55. ###############################################################################
  56. benchmark_version = "1.6.1"
  57. http_archive(
  58. name = "com_github_google_benchmark",
  59. sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
  60. strip_prefix = "benchmark-%s" % benchmark_version,
  61. urls = ["https://github.com/google/benchmark/archive/refs/tags/v%s.tar.gz" % benchmark_version],
  62. )
  63. ###############################################################################
  64. # LLVM libraries
  65. ###############################################################################
  66. # We pin to specific upstream commits and try to track top-of-tree reasonably
  67. # closely rather than pinning to a specific release.
  68. llvm_version = "6fa65f8a98967a5d2d2a6863e0f67a40d2961905"
  69. http_archive(
  70. name = "llvm-raw",
  71. build_file_content = "# empty",
  72. patch_args = ["-p1"],
  73. patches = [
  74. "@//:bazel/llvm-patches/0001-Patch-for-mallinfo2-when-using-Bazel-build-system.patch",
  75. "@//:bazel/llvm-patches/0002-Added-Bazel-build-for-compiler-rt-fuzzer.patch",
  76. ],
  77. sha256 = "0a3929c5f2fe756820277be7b10e95f7480e7cb7f297ec574d3e9ddeac9068d7",
  78. strip_prefix = "llvm-project-%s" % llvm_version,
  79. urls = ["https://github.com/llvm/llvm-project/archive/%s.tar.gz" % llvm_version],
  80. )
  81. load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
  82. llvm_configure(
  83. name = "llvm-project",
  84. repo_mapping = {"@llvm_zlib": "@zlib"},
  85. targets = [
  86. "AArch64",
  87. "X86",
  88. ],
  89. )
  90. load("@llvm-raw//utils/bazel:terminfo.bzl", "llvm_terminfo_system")
  91. # We require successful detection and use of a system terminfo library.
  92. llvm_terminfo_system(name = "llvm_terminfo")
  93. load("@llvm-raw//utils/bazel:zlib.bzl", "llvm_zlib_system")
  94. # We require successful detection and use of a system zlib library.
  95. llvm_zlib_system(name = "zlib")
  96. ###############################################################################
  97. # Flex/Bison rules
  98. ###############################################################################
  99. rules_m4_version = "0.2.1"
  100. http_archive(
  101. name = "rules_m4",
  102. sha256 = "eaa674cd84546038ecbcc49cdd346134a20961a41fa1a541e80d8bf4b470c34d",
  103. strip_prefix = "rules_m4-%s" % rules_m4_version,
  104. urls = ["https://github.com/jmillikin/rules_m4/archive/v%s.tar.gz" %
  105. rules_m4_version],
  106. )
  107. load("@rules_m4//m4:m4.bzl", "m4_register_toolchains")
  108. # When building M4, disable all compiler warnings as we can't realistically fix
  109. # them anyways.
  110. m4_register_toolchains(extra_copts = ["-w"])
  111. # TODO: Can switch to a normal release version when it includes:
  112. # https://github.com/jmillikin/rules_flex/commit/1f1d9c306c2b4b8be2cb899a3364b84302124e77
  113. rules_flex_version = "1f1d9c306c2b4b8be2cb899a3364b84302124e77"
  114. http_archive(
  115. name = "rules_flex",
  116. sha256 = "a4e99a0a241c8a5aa238e81724ea3529722522c3702fd3aa674add5eb9807002",
  117. strip_prefix = "rules_flex-%s" % rules_flex_version,
  118. urls = ["https://github.com/jmillikin/rules_flex/archive/%s.tar.gz" %
  119. rules_flex_version],
  120. )
  121. load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
  122. # When building Flex, disable all compiler warnings as we can't realistically
  123. # fix them anyways.
  124. flex_register_toolchains(extra_copts = ["-w"])
  125. # TODO: Can switch to a normal release version when it includes:
  126. # https://github.com/jmillikin/rules_bison/commit/478079b28605a38000eaf83719568d756b3383a0
  127. rules_bison_version = "478079b28605a38000eaf83719568d756b3383a0"
  128. http_archive(
  129. name = "rules_bison",
  130. sha256 = "6bc2d382e4ffccd66e60a74521c24722fc8fdfe9af49ff182f79bb5994fa1ba4",
  131. strip_prefix = "rules_bison-%s" % rules_bison_version,
  132. urls = ["https://github.com/jmillikin/rules_bison/archive/%s.tar.gz" %
  133. rules_bison_version],
  134. )
  135. load("@rules_bison//bison:bison.bzl", "bison_register_toolchains")
  136. # When building Bison, disable all compiler warnings as we can't realistically
  137. # fix them anyways.
  138. bison_register_toolchains(extra_copts = ["-w"])
  139. ###############################################################################
  140. # Protocol buffers - for structured fuzzer testing.
  141. ###############################################################################
  142. # TODO: `rules_proto` pulls in a version of `rules_cc` with a frozenset bug.
  143. rules_cc_version = "0.0.1"
  144. http_archive(
  145. name = "rules_cc",
  146. sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
  147. urls = ["https://github.com/bazelbuild/rules_cc/releases/download/%s/rules_cc-%s.tar.gz" % (rules_cc_version, rules_cc_version)],
  148. )
  149. rules_proto_version = "4.0.0-3.20.0"
  150. http_archive(
  151. name = "rules_proto",
  152. sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
  153. strip_prefix = "rules_proto-%s" % rules_proto_version,
  154. urls = [
  155. "https://github.com/bazelbuild/rules_proto/archive/refs/tags/%s.tar.gz" % rules_proto_version,
  156. ],
  157. )
  158. load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
  159. rules_proto_dependencies()
  160. rules_proto_toolchains()
  161. ###############################################################################
  162. # libprotobuf_mutator - for structured fuzzer testing.
  163. ###############################################################################
  164. libprotobuf_mutator_version = "1.0"
  165. http_archive(
  166. name = "com_google_libprotobuf_mutator",
  167. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  168. sha256 = "792f250fb546bde8590e72d64311ea00a70c175fd77df6bb5e02328fa15fe28e",
  169. strip_prefix = "libprotobuf-mutator-%s" % libprotobuf_mutator_version,
  170. urls = ["https://github.com/google/libprotobuf-mutator/archive/v%s.tar.gz" % libprotobuf_mutator_version],
  171. )
  172. ###############################################################################
  173. # Example conversion repositories
  174. ###############################################################################
  175. local_repository(
  176. name = "brotli",
  177. path = "third_party/examples/brotli/original",
  178. )
  179. new_local_repository(
  180. name = "woff2",
  181. build_file = "third_party/examples/woff2/BUILD.original",
  182. path = "third_party/examples/woff2/original",
  183. workspace_file = "third_party/examples/woff2/WORKSPACE.original",
  184. )
  185. local_repository(
  186. name = "woff2_carbon",
  187. path = "third_party/examples/woff2/carbon",
  188. )