blob: d84047d9bdc76140a2cc97505f2781cf97b11ede [file] [log] [blame]
Googler3c84aa82023-04-11 09:40:31 -07001# Copyright 2023 The Bazel Authors. 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 at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Module extensions for loading dependencies we need to build Bazel.
16
17"""
18
Googlerf3163122024-08-27 12:05:12 -070019load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
Yun Pengc1f2aff2023-11-07 09:51:02 -080020load("//:distdir.bzl", "distdir_tar", "repo_cache_tar")
Googlerc1d753e2024-10-04 13:59:07 -070021load("//:repositories.bzl", "DIST_ARCHIVE_REPOS", "embedded_jdk_repositories")
Yun Pengc1f2aff2023-11-07 09:51:02 -080022load("//:workspace_deps.bzl", "WORKSPACE_REPOS")
Yun Peng9d308492023-08-08 00:49:00 -070023load("//src/main/res:winsdk_configure.bzl", "winsdk_configure")
Yun Pengb27ca732023-09-06 02:57:04 -070024load("//src/test/shell/bazel:list_source_repository.bzl", "list_source_repository")
Yun Peng50c83752023-10-10 18:30:26 -070025load("//src/tools/bzlmod:utils.bzl", "parse_bazel_module_repos")
Yun Pengb27ca732023-09-06 02:57:04 -070026load("//tools/distributions/debian:deps.bzl", "debian_deps")
Googlercf140392023-08-01 12:34:14 -070027
Yun Pengb27ca732023-09-06 02:57:04 -070028### Dependencies for building Bazel
Fabian Meumertzheimc529cb22024-06-21 03:13:33 -070029def _bazel_build_deps(ctx):
30 ctx.path(Label("//:MODULE.bazel")) # Make sure the `bootstrap_repo_cache` repo is updated when MODULE.bazel changes.
Googler3c84aa82023-04-11 09:40:31 -070031 embedded_jdk_repositories()
Googlercf140392023-08-01 12:34:14 -070032 debian_deps()
Fabian Meumertzheimb9a05782024-05-13 09:18:57 -070033 repo_cache_tar(
34 name = "bootstrap_repo_cache",
35 repos = DIST_ARCHIVE_REPOS,
36 dirname = "derived/repository_cache",
37 module_files = [
38 "//:MODULE.bazel",
Fabian Meumertzheimb9a05782024-05-13 09:18:57 -070039 "//third_party/remoteapis:MODULE.bazel",
40 "//src:MODULE.tools",
41 ],
42 )
Fabian Meumertzheimc529cb22024-06-21 03:13:33 -070043 BAZEL_TOOLS_DEPS_REPOS = parse_bazel_module_repos(ctx, ctx.path(Label("//src/test/tools/bzlmod:MODULE.bazel.lock")))
Yun Peng50c83752023-10-10 18:30:26 -070044 repo_cache_tar(name = "bazel_tools_repo_cache", repos = BAZEL_TOOLS_DEPS_REPOS, lockfile = "//src/test/tools/bzlmod:MODULE.bazel.lock")
Yun Pengc1f2aff2023-11-07 09:51:02 -080045 distdir_tar(name = "workspace_repo_cache", dist_deps = WORKSPACE_REPOS)
Fabian Meumertzheimc529cb22024-06-21 03:13:33 -070046 return ctx.extension_metadata(reproducible = True)
Googler3c84aa82023-04-11 09:40:31 -070047
Yun Pengb27ca732023-09-06 02:57:04 -070048bazel_build_deps = module_extension(implementation = _bazel_build_deps)
Googlercf140392023-08-01 12:34:14 -070049
Yun Pengb27ca732023-09-06 02:57:04 -070050### Dependencies for testing Bazel
Fabian Meumertzheimc529cb22024-06-21 03:13:33 -070051def _bazel_test_deps(ctx):
Googlercf140392023-08-01 12:34:14 -070052 list_source_repository(name = "local_bazel_source_list")
Yun Peng9d308492023-08-08 00:49:00 -070053 winsdk_configure(name = "local_config_winsdk")
Googlerf3163122024-08-27 12:05:12 -070054
55 # /usr/local/kythe is setup on Bazel CI machines
56 local_repository(
57 name = "kythe_release",
58 path = "/usr/local/kythe",
59 )
Fabian Meumertzheimc529cb22024-06-21 03:13:33 -070060 return ctx.extension_metadata(reproducible = True)
Googlercf140392023-08-01 12:34:14 -070061
Yun Pengb27ca732023-09-06 02:57:04 -070062bazel_test_deps = module_extension(implementation = _bazel_test_deps)