WORKSPACE 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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.3.0"
  10. # Add Bazel's python rules and set up pip.
  11. http_archive(
  12. name = "rules_python",
  13. sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b",
  14. url = "https://github.com/bazelbuild/rules_python/releases/download/%s/rules_python-%s.tar.gz" % (
  15. rules_python_version,
  16. rules_python_version,
  17. ),
  18. )
  19. load("@rules_python//python:pip.bzl", "pip_install")
  20. # Create a central repo that knows about the pip dependencies.
  21. pip_install(
  22. name = "py_deps",
  23. requirements = "//github_tools:requirements.txt",
  24. )
  25. ###############################################################################
  26. # Python mypy rules
  27. ###############################################################################
  28. # NOTE: https://github.com/bazelbuild/bazel/issues/4948 tracks bazel supporting
  29. # typing directly. If it's added, we will probably want to switch.
  30. # Add mypy
  31. mypy_integration_version = "0.2.0"
  32. http_archive(
  33. name = "mypy_integration",
  34. sha256 = "621df076709dc72809add1f5fe187b213fee5f9b92e39eb33851ab13487bd67d",
  35. strip_prefix = "bazel-mypy-integration-%s" % mypy_integration_version,
  36. urls = [
  37. "https://github.com/thundergolfer/bazel-mypy-integration/archive/refs/tags/%s.tar.gz" % mypy_integration_version,
  38. ],
  39. )
  40. load(
  41. "@mypy_integration//repositories:repositories.bzl",
  42. mypy_integration_repositories = "repositories",
  43. )
  44. mypy_integration_repositories()
  45. load("@mypy_integration//:config.bzl", "mypy_configuration")
  46. mypy_configuration("//bazel/mypy:mypy.ini")
  47. load("@mypy_integration//repositories:deps.bzl", mypy_integration_deps = "deps")
  48. mypy_integration_deps(
  49. mypy_requirements_file = "//bazel/mypy:version.txt",
  50. )
  51. ###############################################################################
  52. # C++ rules
  53. ###############################################################################
  54. # Configure the bootstrapped Clang and LLVM toolchain for Bazel.
  55. load(
  56. "//bazel/cc_toolchains:clang_configuration.bzl",
  57. "configure_clang_toolchain",
  58. )
  59. configure_clang_toolchain(name = "bazel_cc_toolchain")
  60. ###############################################################################
  61. # LLVM libraries
  62. ###############################################################################
  63. local_repository(
  64. name = "llvm_bazel",
  65. path = "third_party/llvm-bazel/llvm-bazel",
  66. )
  67. load("@llvm_bazel//:configure.bzl", "llvm_configure")
  68. llvm_configure(
  69. name = "llvm-project",
  70. src_path = "third_party/llvm-project",
  71. src_workspace = "@carbon//:WORKSPACE",
  72. targets = [
  73. "AArch64",
  74. "X86",
  75. ],
  76. )
  77. load("@llvm_bazel//:terminfo.bzl", "llvm_terminfo_system")
  78. # We require successful detection and use of a system terminfo library.
  79. llvm_terminfo_system(name = "llvm_terminfo")
  80. load("@llvm_bazel//:zlib.bzl", "llvm_zlib_system")
  81. # We require successful detection and use of a system zlib library.
  82. llvm_zlib_system(name = "llvm_zlib")
  83. ###############################################################################
  84. # Flex/Bison rules
  85. ###############################################################################
  86. # TODO: Can switch to a normal release version when it includes:
  87. # https://github.com/jmillikin/rules_m4/commit/b504241407916d1d6d72c66a766daacf9603cf8b
  88. rules_m4_version = "b504241407916d1d6d72c66a766daacf9603cf8b"
  89. http_archive(
  90. name = "rules_m4",
  91. sha256 = "e6003c5f45746a2ad01335a8526044591f2b6c5c68852cee1bcd28adc2cf452b",
  92. strip_prefix = "rules_m4-%s" % rules_m4_version,
  93. urls = ["https://github.com/jmillikin/rules_m4/archive/%s.zip" %
  94. rules_m4_version],
  95. )
  96. load("@rules_m4//m4:m4.bzl", "m4_register_toolchains")
  97. # When building M4, disable all compiler warnings as we can't realistically fix
  98. # them anyways.
  99. m4_register_toolchains(extra_copts = ["-w"])
  100. # TODO: Can switch to a normal release version when it includes:
  101. # https://github.com/jmillikin/rules_flex/commit/1f1d9c306c2b4b8be2cb899a3364b84302124e77
  102. rules_flex_version = "1f1d9c306c2b4b8be2cb899a3364b84302124e77"
  103. http_archive(
  104. name = "rules_flex",
  105. sha256 = "ad1c3a1a9bdd6254df857f84f3ab4c052df6e21ce4af5d32710f2feff2abf4dd",
  106. strip_prefix = "rules_flex-%s" % rules_flex_version,
  107. urls = ["https://github.com/jmillikin/rules_flex/archive/%s.zip" %
  108. rules_flex_version],
  109. )
  110. load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
  111. # When building Flex, disable all compiler warnings as we can't realistically
  112. # fix them anyways.
  113. flex_register_toolchains(extra_copts = ["-w"])
  114. # TODO: Can switch to a normal release version when it includes:
  115. # https://github.com/jmillikin/rules_bison/commit/478079b28605a38000eaf83719568d756b3383a0
  116. rules_bison_version = "478079b28605a38000eaf83719568d756b3383a0"
  117. http_archive(
  118. name = "rules_bison",
  119. sha256 = "d662d200f4e2a868f6873d666402fa4d413f07ba1a433591c5f60ac601157fb9",
  120. strip_prefix = "rules_bison-%s" % rules_bison_version,
  121. urls = ["https://github.com/jmillikin/rules_bison/archive/%s.zip" %
  122. rules_bison_version],
  123. )
  124. load("@rules_bison//bison:bison.bzl", "bison_register_toolchains")
  125. # When building Bison, disable all compiler warnings as we can't realistically
  126. # fix them anyways.
  127. bison_register_toolchains(extra_copts = ["-w"])
  128. ###############################################################################
  129. # Example conversion repositories
  130. ###############################################################################
  131. local_repository(
  132. name = "brotli",
  133. path = "third_party/examples/brotli/original",
  134. )
  135. new_local_repository(
  136. name = "woff2",
  137. build_file = "third_party/examples/woff2/BUILD.original",
  138. path = "third_party/examples/woff2/original",
  139. workspace_file = "third_party/examples/woff2/WORKSPACE.original",
  140. )
  141. local_repository(
  142. name = "woff2_carbon",
  143. path = "third_party/examples/woff2/carbon",
  144. )