BUILD.bazel 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License in the LICENSE file at the
  6. # root of this repository, or online at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """
  16. Registering toolchains.
  17. We should only be _manually_ registering esoteric toolchains, more common
  18. toolchains like C or Rust should be handled by a higher level rule set, e.g.
  19. [`toolchains_llvm`](https://github.com/bazel-contrib/toolchains_llvm) or
  20. [`rules_rust`](https://github.com/bazelbuild/rules_rust) respectively.
  21. Note: These registrations live here, and not in the `WORKSPACE` file or a
  22. `.bzl` file because of Bazel limitations.
  23. See: <https://bazel.build/extending/toolchains>
  24. """
  25. load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_toolchain")
  26. # Rust Bindgen Toolchains
  27. #
  28. # [`bindgen`](https://github.com/rust-lang/rust-bindgen) automatically generates Rust FFI
  29. # bindings to C libraries using `clang`. `rules_rust` provides the `bindgen` CLI tool
  30. # and we need to provide the necessary parts of a `clang` toolchain.
  31. # Darwin aarch64
  32. rust_bindgen_toolchain(
  33. name = "bindgen_toolchain_darwin__aarch64",
  34. bindgen = "@rules_rust_bindgen//3rdparty:bindgen",
  35. clang = "@rust_bindgen__darwin_aarch64//:clang",
  36. libclang = "@rust_bindgen__darwin_aarch64//:libclang",
  37. libstdcxx = "@rust_bindgen__darwin_aarch64//:libc++",
  38. )
  39. toolchain(
  40. name = "rust_bindgen_toolchain__darwin_aarch64",
  41. exec_compatible_with = [
  42. "@platforms//os:macos",
  43. ],
  44. toolchain = "bindgen_toolchain_darwin__aarch64",
  45. toolchain_type = "@rules_rust_bindgen//:toolchain_type",
  46. visibility = ["//visibility:public"],
  47. )
  48. # Darwin x86_64
  49. rust_bindgen_toolchain(
  50. name = "bindgen_toolchain_darwin__x86_64",
  51. bindgen = "@rules_rust_bindgen//3rdparty:bindgen",
  52. clang = "@rust_bindgen__darwin_x86_64//:clang",
  53. libclang = "@rust_bindgen__darwin_x86_64//:libclang",
  54. libstdcxx = "@rust_bindgen__darwin_x86_64//:libc++",
  55. )
  56. toolchain(
  57. name = "rust_bindgen_toolchain__darwin_x86_64",
  58. exec_compatible_with = [
  59. "@platforms//os:macos",
  60. "@platforms//cpu:x86_64",
  61. ],
  62. toolchain = "bindgen_toolchain_darwin__x86_64",
  63. toolchain_type = "@rules_rust_bindgen//:toolchain_type",
  64. visibility = ["//visibility:public"],
  65. )
  66. # Linux aarch64
  67. rust_bindgen_toolchain(
  68. name = "bindgen_toolchain_linux__aarch64",
  69. bindgen = "@rules_rust_bindgen//3rdparty:bindgen",
  70. clang = "@rust_bindgen__linux_aarch64//:clang",
  71. libclang = "@rust_bindgen__linux_aarch64//:libclang",
  72. libstdcxx = "@rust_bindgen__linux_aarch64//:libc++",
  73. )
  74. toolchain(
  75. name = "rust_bindgen_toolchain__linux_aarch64",
  76. exec_compatible_with = [
  77. "@platforms//os:linux",
  78. "@platforms//cpu:aarch64",
  79. ],
  80. toolchain = "bindgen_toolchain_linux__aarch64",
  81. toolchain_type = "@rules_rust_bindgen//:toolchain_type",
  82. visibility = ["//visibility:public"],
  83. )
  84. # Linux x86_64
  85. rust_bindgen_toolchain(
  86. name = "bindgen_toolchain_linux__x86_64",
  87. bindgen = "@rules_rust_bindgen//3rdparty:bindgen",
  88. clang = "@rust_bindgen__linux_x86_64//:clang",
  89. libclang = "@rust_bindgen__linux_x86_64//:libclang",
  90. libstdcxx = "@rust_bindgen__linux_x86_64//:libc++",
  91. )
  92. toolchain(
  93. name = "rust_bindgen_toolchain__linux_x86_64",
  94. exec_compatible_with = [
  95. "@platforms//os:linux",
  96. "@platforms//cpu:x86_64",
  97. ],
  98. toolchain = "bindgen_toolchain_linux__x86_64",
  99. toolchain_type = "@rules_rust_bindgen//:toolchain_type",
  100. visibility = ["//visibility:public"],
  101. )