WORKSPACE 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 = ["@//:bazel/llvm-patches/0001-Patch-for-mallinfo2-when-using-Bazel-build-system.patch"],
  74. sha256 = "0a3929c5f2fe756820277be7b10e95f7480e7cb7f297ec574d3e9ddeac9068d7",
  75. strip_prefix = "llvm-project-%s" % llvm_version,
  76. urls = ["https://github.com/llvm/llvm-project/archive/%s.tar.gz" % llvm_version],
  77. )
  78. load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
  79. llvm_configure(
  80. name = "llvm-project",
  81. repo_mapping = {"@llvm_zlib": "@zlib"},
  82. targets = [
  83. "AArch64",
  84. "X86",
  85. ],
  86. )
  87. load("@llvm-raw//utils/bazel:terminfo.bzl", "llvm_terminfo_system")
  88. # We require successful detection and use of a system terminfo library.
  89. llvm_terminfo_system(name = "llvm_terminfo")
  90. load("@llvm-raw//utils/bazel:zlib.bzl", "llvm_zlib_system")
  91. # We require successful detection and use of a system zlib library.
  92. llvm_zlib_system(name = "zlib")
  93. ###############################################################################
  94. # Flex/Bison rules
  95. ###############################################################################
  96. rules_m4_version = "0.2.1"
  97. http_archive(
  98. name = "rules_m4",
  99. sha256 = "eaa674cd84546038ecbcc49cdd346134a20961a41fa1a541e80d8bf4b470c34d",
  100. strip_prefix = "rules_m4-%s" % rules_m4_version,
  101. urls = ["https://github.com/jmillikin/rules_m4/archive/v%s.tar.gz" %
  102. rules_m4_version],
  103. )
  104. load("@rules_m4//m4:m4.bzl", "m4_register_toolchains")
  105. # When building M4, disable all compiler warnings as we can't realistically fix
  106. # them anyways.
  107. m4_register_toolchains(extra_copts = ["-w"])
  108. # TODO: Can switch to a normal release version when it includes:
  109. # https://github.com/jmillikin/rules_flex/commit/1f1d9c306c2b4b8be2cb899a3364b84302124e77
  110. rules_flex_version = "1f1d9c306c2b4b8be2cb899a3364b84302124e77"
  111. http_archive(
  112. name = "rules_flex",
  113. sha256 = "a4e99a0a241c8a5aa238e81724ea3529722522c3702fd3aa674add5eb9807002",
  114. strip_prefix = "rules_flex-%s" % rules_flex_version,
  115. urls = ["https://github.com/jmillikin/rules_flex/archive/%s.tar.gz" %
  116. rules_flex_version],
  117. )
  118. load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
  119. # When building Flex, disable all compiler warnings as we can't realistically
  120. # fix them anyways.
  121. flex_register_toolchains(extra_copts = ["-w"])
  122. # TODO: Can switch to a normal release version when it includes:
  123. # https://github.com/jmillikin/rules_bison/commit/478079b28605a38000eaf83719568d756b3383a0
  124. rules_bison_version = "478079b28605a38000eaf83719568d756b3383a0"
  125. http_archive(
  126. name = "rules_bison",
  127. sha256 = "6bc2d382e4ffccd66e60a74521c24722fc8fdfe9af49ff182f79bb5994fa1ba4",
  128. strip_prefix = "rules_bison-%s" % rules_bison_version,
  129. urls = ["https://github.com/jmillikin/rules_bison/archive/%s.tar.gz" %
  130. rules_bison_version],
  131. )
  132. load("@rules_bison//bison:bison.bzl", "bison_register_toolchains")
  133. # When building Bison, disable all compiler warnings as we can't realistically
  134. # fix them anyways.
  135. bison_register_toolchains(extra_copts = ["-w"])
  136. ###############################################################################
  137. # Protocol buffers - for structured fuzzer testing.
  138. ###############################################################################
  139. # TODO: `rules_proto` pulls in a version of `rules_cc` with a frozenset bug.
  140. rules_cc_version = "0.0.1"
  141. http_archive(
  142. name = "rules_cc",
  143. sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
  144. urls = ["https://github.com/bazelbuild/rules_cc/releases/download/%s/rules_cc-%s.tar.gz" % (rules_cc_version, rules_cc_version)],
  145. )
  146. rules_proto_version = "4.0.0-3.20.0"
  147. http_archive(
  148. name = "rules_proto",
  149. sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
  150. strip_prefix = "rules_proto-%s" % rules_proto_version,
  151. urls = [
  152. "https://github.com/bazelbuild/rules_proto/archive/refs/tags/%s.tar.gz" % rules_proto_version,
  153. ],
  154. )
  155. load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
  156. rules_proto_dependencies()
  157. rules_proto_toolchains()
  158. ###############################################################################
  159. # libprotobuf_mutator - for structured fuzzer testing.
  160. ###############################################################################
  161. libprotobuf_mutator_version = "1.0"
  162. http_archive(
  163. name = "com_google_libprotobuf_mutator",
  164. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  165. sha256 = "792f250fb546bde8590e72d64311ea00a70c175fd77df6bb5e02328fa15fe28e",
  166. strip_prefix = "libprotobuf-mutator-%s" % libprotobuf_mutator_version,
  167. urls = ["https://github.com/google/libprotobuf-mutator/archive/v%s.tar.gz" % libprotobuf_mutator_version],
  168. )
  169. ###############################################################################
  170. # Example conversion repositories
  171. ###############################################################################
  172. local_repository(
  173. name = "brotli",
  174. path = "third_party/examples/brotli/original",
  175. )
  176. new_local_repository(
  177. name = "woff2",
  178. build_file = "third_party/examples/woff2/BUILD.original",
  179. path = "third_party/examples/woff2/original",
  180. workspace_file = "third_party/examples/woff2/WORKSPACE.original",
  181. )
  182. local_repository(
  183. name = "woff2_carbon",
  184. path = "third_party/examples/woff2/carbon",
  185. )