Googler | 3c84aa8 | 2023-04-11 09:40:31 -0700 | [diff] [blame] | 1 | # 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 | |
Googler | f316312 | 2024-08-27 12:05:12 -0700 | [diff] [blame] | 19 | load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository") |
Yun Peng | c1f2aff | 2023-11-07 09:51:02 -0800 | [diff] [blame] | 20 | load("//:distdir.bzl", "distdir_tar", "repo_cache_tar") |
Googler | c1d753e | 2024-10-04 13:59:07 -0700 | [diff] [blame] | 21 | load("//:repositories.bzl", "DIST_ARCHIVE_REPOS", "embedded_jdk_repositories") |
Yun Peng | c1f2aff | 2023-11-07 09:51:02 -0800 | [diff] [blame] | 22 | load("//:workspace_deps.bzl", "WORKSPACE_REPOS") |
Yun Peng | 9d30849 | 2023-08-08 00:49:00 -0700 | [diff] [blame] | 23 | load("//src/main/res:winsdk_configure.bzl", "winsdk_configure") |
Yun Peng | b27ca73 | 2023-09-06 02:57:04 -0700 | [diff] [blame] | 24 | load("//src/test/shell/bazel:list_source_repository.bzl", "list_source_repository") |
Yun Peng | 50c8375 | 2023-10-10 18:30:26 -0700 | [diff] [blame] | 25 | load("//src/tools/bzlmod:utils.bzl", "parse_bazel_module_repos") |
Yun Peng | b27ca73 | 2023-09-06 02:57:04 -0700 | [diff] [blame] | 26 | load("//tools/distributions/debian:deps.bzl", "debian_deps") |
Googler | cf14039 | 2023-08-01 12:34:14 -0700 | [diff] [blame] | 27 | |
Yun Peng | b27ca73 | 2023-09-06 02:57:04 -0700 | [diff] [blame] | 28 | ### Dependencies for building Bazel |
Fabian Meumertzheim | c529cb2 | 2024-06-21 03:13:33 -0700 | [diff] [blame] | 29 | def _bazel_build_deps(ctx): |
| 30 | ctx.path(Label("//:MODULE.bazel")) # Make sure the `bootstrap_repo_cache` repo is updated when MODULE.bazel changes. |
Googler | 3c84aa8 | 2023-04-11 09:40:31 -0700 | [diff] [blame] | 31 | embedded_jdk_repositories() |
Googler | cf14039 | 2023-08-01 12:34:14 -0700 | [diff] [blame] | 32 | debian_deps() |
Fabian Meumertzheim | b9a0578 | 2024-05-13 09:18:57 -0700 | [diff] [blame] | 33 | 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 Meumertzheim | b9a0578 | 2024-05-13 09:18:57 -0700 | [diff] [blame] | 39 | "//third_party/remoteapis:MODULE.bazel", |
| 40 | "//src:MODULE.tools", |
| 41 | ], |
| 42 | ) |
Fabian Meumertzheim | c529cb2 | 2024-06-21 03:13:33 -0700 | [diff] [blame] | 43 | BAZEL_TOOLS_DEPS_REPOS = parse_bazel_module_repos(ctx, ctx.path(Label("//src/test/tools/bzlmod:MODULE.bazel.lock"))) |
Yun Peng | 50c8375 | 2023-10-10 18:30:26 -0700 | [diff] [blame] | 44 | repo_cache_tar(name = "bazel_tools_repo_cache", repos = BAZEL_TOOLS_DEPS_REPOS, lockfile = "//src/test/tools/bzlmod:MODULE.bazel.lock") |
Yun Peng | c1f2aff | 2023-11-07 09:51:02 -0800 | [diff] [blame] | 45 | distdir_tar(name = "workspace_repo_cache", dist_deps = WORKSPACE_REPOS) |
Fabian Meumertzheim | c529cb2 | 2024-06-21 03:13:33 -0700 | [diff] [blame] | 46 | return ctx.extension_metadata(reproducible = True) |
Googler | 3c84aa8 | 2023-04-11 09:40:31 -0700 | [diff] [blame] | 47 | |
Yun Peng | b27ca73 | 2023-09-06 02:57:04 -0700 | [diff] [blame] | 48 | bazel_build_deps = module_extension(implementation = _bazel_build_deps) |
Googler | cf14039 | 2023-08-01 12:34:14 -0700 | [diff] [blame] | 49 | |
Yun Peng | b27ca73 | 2023-09-06 02:57:04 -0700 | [diff] [blame] | 50 | ### Dependencies for testing Bazel |
Fabian Meumertzheim | c529cb2 | 2024-06-21 03:13:33 -0700 | [diff] [blame] | 51 | def _bazel_test_deps(ctx): |
Googler | cf14039 | 2023-08-01 12:34:14 -0700 | [diff] [blame] | 52 | list_source_repository(name = "local_bazel_source_list") |
Yun Peng | 9d30849 | 2023-08-08 00:49:00 -0700 | [diff] [blame] | 53 | winsdk_configure(name = "local_config_winsdk") |
Googler | f316312 | 2024-08-27 12:05:12 -0700 | [diff] [blame] | 54 | |
| 55 | # /usr/local/kythe is setup on Bazel CI machines |
| 56 | local_repository( |
| 57 | name = "kythe_release", |
| 58 | path = "/usr/local/kythe", |
| 59 | ) |
Fabian Meumertzheim | c529cb2 | 2024-06-21 03:13:33 -0700 | [diff] [blame] | 60 | return ctx.extension_metadata(reproducible = True) |
Googler | cf14039 | 2023-08-01 12:34:14 -0700 | [diff] [blame] | 61 | |
Yun Peng | b27ca73 | 2023-09-06 02:57:04 -0700 | [diff] [blame] | 62 | bazel_test_deps = module_extension(implementation = _bazel_test_deps) |