MODULE.bazel 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. """Bazel modules.
  5. If `MODULE.bazel.lock` changes locally, it means the host platform hasn't yet
  6. been added to the lock file. Running `bazel mod deps` provides a canonical
  7. update to `MODULE.bazel.lock`; create a PR with those changes in order to
  8. include the host platform.
  9. Platforms tested with GitHub actions are kept up-to-date. Other platforms may
  10. fall out of sync on dependency changes, and should be updated with a PR the same
  11. way a platform is added.
  12. """
  13. module(name = "carbon")
  14. http_archive = use_repo_rule(
  15. "@bazel_tools//tools/build_defs/repo:http.bzl",
  16. "http_archive",
  17. )
  18. bazel_dep(name = "bazel_skylib", version = "1.5.0")
  19. bazel_dep(
  20. name = "abseil-cpp",
  21. version = "20230802.0",
  22. repo_name = "com_google_absl",
  23. )
  24. bazel_dep(
  25. name = "re2",
  26. version = "2023-11-01",
  27. repo_name = "com_googlesource_code_re2",
  28. )
  29. bazel_dep(
  30. name = "googletest",
  31. version = "1.14.0.bcr.1",
  32. repo_name = "com_google_googletest",
  33. )
  34. bazel_dep(
  35. name = "google_benchmark",
  36. version = "1.8.3",
  37. repo_name = "com_github_google_benchmark",
  38. )
  39. bazel_dep(name = "rules_bison", version = "0.2.2")
  40. bazel_dep(name = "rules_flex", version = "0.2.1")
  41. bazel_dep(name = "rules_m4", version = "0.2.3")
  42. bazel_dep(name = "rules_cc", version = "0.0.9")
  43. bazel_dep(name = "rules_proto", version = "6.0.0-rc1")
  44. bazel_dep(
  45. name = "protobuf",
  46. version = "21.7",
  47. repo_name = "com_google_protobuf",
  48. )
  49. libprotobuf_mutator_version = "1.1"
  50. http_archive(
  51. name = "com_google_libprotobuf_mutator",
  52. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  53. sha256 = "fd299fd72c5cf664259d9bd43a72cb74dc6a8b9604d107fe2d2e90885aeb7c16",
  54. strip_prefix = "libprotobuf-mutator-{0}".format(libprotobuf_mutator_version),
  55. urls = ["https://github.com/google/libprotobuf-mutator/archive/v{0}.tar.gz".format(libprotobuf_mutator_version)],
  56. )
  57. clang_tidy_version = "d2aecc583d14c9554febeab185833c1e8cce5384"
  58. http_archive(
  59. name = "bazel_clang_tidy",
  60. sha256 = "89c198a9f544beac119bb41904d16d8870686ccb5fe946442c1576934c9e6869",
  61. strip_prefix = "bazel_clang_tidy-{0}".format(clang_tidy_version),
  62. urls = ["https://github.com/erenon/bazel_clang_tidy/archive/{0}.tar.gz".format(clang_tidy_version)],
  63. )
  64. bazel_cc_toolchain = use_extension(
  65. "//bazel/cc_toolchains:clang_configuration.bzl",
  66. "clang_toolchain_extension",
  67. )
  68. use_repo(bazel_cc_toolchain, "bazel_cc_toolchain")
  69. register_toolchains("@bazel_cc_toolchain//:all")
  70. bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
  71. git_override(
  72. module_name = "hedron_compile_commands",
  73. # HEAD as of 2023-12-19.
  74. commit = "af167878427c469db96444b65f026d064ec62a4f",
  75. remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
  76. )
  77. ###############################################################################
  78. # llvm-project
  79. ###############################################################################
  80. # We pin to specific upstream commits and try to track top-of-tree reasonably
  81. # closely rather than pinning to a specific release.
  82. llvm_project_version = "3d51010a3350660160981c6b8e624dcc87c208a3"
  83. # Required for llvm-project.
  84. bazel_dep(name = "platforms", version = "0.0.8")
  85. # zlib and zstd dependencies are copied from
  86. bazel_dep(name = "zlib", version = "1.3", repo_name = "llvm_zlib")
  87. bazel_dep(name = "zstd", version = "1.5.5", repo_name = "llvm_zstd")
  88. # Load a repository for the raw llvm-project, pre-overlay.
  89. http_archive(
  90. name = "llvm-raw",
  91. build_file_content = "# empty",
  92. patch_args = ["-p1"],
  93. patches = [
  94. "@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  95. "@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  96. "@carbon//bazel/llvm_project:0003_Add_library_for_clangd.patch",
  97. ],
  98. sha256 = "efbca707a6eb1c714b849de120309070eef282660c0f4be5b68efef62cc95cf5",
  99. strip_prefix = "llvm-project-{0}".format(llvm_project_version),
  100. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
  101. )
  102. # Apply the overlay to produce llvm-project.
  103. llvm_project = use_extension(
  104. "//bazel/llvm_project:llvm_project.bzl",
  105. "llvm_project",
  106. )
  107. use_repo(llvm_project, "llvm-project")
  108. ###############################################################################
  109. # Python
  110. ###############################################################################
  111. bazel_dep(name = "rules_python", version = "0.27.1")
  112. python = use_extension("@rules_python//python/extensions:python.bzl", "python")
  113. python.toolchain(
  114. python_version = "3.11",
  115. )
  116. use_repo(python, "python_versions")
  117. # Create a central repo that knows about the pip dependencies.
  118. pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
  119. pip.parse(
  120. hub_name = "py_deps",
  121. python_version = "3.11",
  122. requirements_lock = "//github_tools:requirements.txt",
  123. )
  124. use_repo(pip, "py_deps")