repositories.bzl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
  16. load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
  17. def tools_repositories():
  18. """Fetch binaries for `buildifier`, the Bazel formatting tool."""
  19. BUILDIFIER_VERSION = "7.3.1"
  20. BUILDIFIER_TARGETS = {
  21. "darwin-amd64": "sha256-N1+CMQPQFiCq7CCgwpxsvKmfT9ByWuMLk2VcZwT0TXE=",
  22. "darwin-arm64": "sha256-Wmr8asegn1RVuguJvZnVriO0F03F3J1sDtXOjKrD+BM=",
  23. "linux-amd64": "sha256-VHTMUSinToBng9VAgfWBZixL6K5lAi9VfpKB7V3IgAk=",
  24. "linux-arm64": "sha256-C/hsS//69PCO7Xe95bIILkrlA5oR4uiwOYTBc8NKVhw=",
  25. }
  26. buildifier(BUILDIFIER_VERSION, BUILDIFIER_TARGETS)
  27. def buildifier(version, targets):
  28. """
  29. Macro that downloads a pre-built `buildifier` binary for all of the specified targets.
  30. [`buildifier`](https://github.com/bazelbuild/buildtools)
  31. """
  32. for (target, integrity) in targets.items():
  33. maybe(
  34. http_file,
  35. name = "buildifier-{0}".format(target),
  36. executable = True,
  37. integrity = integrity,
  38. urls = [
  39. "https://github.com/MaterializeInc/toolchains/releases/download/buildifier-{VERSION}/buildifier-{TARGET}".format(VERSION = version, TARGET = target),
  40. "https://github.com/bazelbuild/buildtools/releases/download/v{VERSION}/buildifier-{TARGET}".format(VERSION = version, TARGET = target),
  41. ],
  42. )