Skip to content

Commit

Permalink
[8.0.0] Backport MODULE.bazel file changes (#24481)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorcloudy authored Nov 25, 2024
1 parent 9f4be82 commit 11596c3
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 63 deletions.
23 changes: 18 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_license//rules:license.bzl", "license")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_python//python:defs.bzl", "py_binary")
load("//src/tools/bzlmod:utils.bzl", "get_canonical_repo_name")
Expand Down Expand Up @@ -155,16 +156,28 @@ filegroup(
],
)

# Bazel sources excluding files that are not needed in the distfile.
pkg_files(
name = "dist-srcs",
srcs = ["//:srcs"],
attributes = pkg_attributes(mode = "0755"),
excludes = [
"//examples:srcs",
"//site:srcs",
"//src:srcs-to-exclude-in-distfile",
],
renames = {
"MODULE.bazel.lock.dist": "MODULE.bazel.lock",
},
strip_prefix = "/", # Ensure paths are relative to the workspace root.
)

pkg_tar(
name = "bazel-srcs",
srcs = [
":dist-srcs",
":generated_resources",
":srcs",
],
# TODO(aiuto): Replace with pkg_filegroup when that is available.
remap_paths = {
"MODULE.bazel.lock.dist": "MODULE.bazel.lock",
},
strip_prefix = ".",
# Public but bazel-only visibility.
visibility = ["//:__subpackages__"],
Expand Down
29 changes: 21 additions & 8 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ local_path_override(
# The following Bazel modules are not direct dependencies for building Bazel,
# but are required for visibility from DIST_ARCHIVE_REPOS in repositories.bzl
bazel_dep(name = "apple_support", version = "1.15.1")
bazel_dep(name = "bazel_features", version = "1.21.0")
bazel_dep(name = "c-ares", version = "1.15.0")
bazel_dep(name = "rules_go", version = "0.48.0")
bazel_dep(name = "rules_kotlin", version = "1.9.6")
Expand Down Expand Up @@ -361,16 +362,28 @@ http_file(

bazel_dep(name = "bazel_ci_rules", version = "1.0.0")

bazel_test_deps = use_extension("//:extensions.bzl", "bazel_test_deps")
use_repo(
bazel_test_deps,
"kythe_release",
"local_bazel_source_list",
"local_config_winsdk",
rbe_preconfig = use_repo_rule("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig")

rbe_preconfig(
name = "rbe_ubuntu2004",
toolchain = "ubuntu2004",
)

bazel_rbe_deps = use_extension("//:rbe_extension.bzl", "bazel_rbe_deps")
use_repo(bazel_rbe_deps, "rbe_ubuntu2004")
list_source_repository = use_repo_rule("//src/test/shell/bazel:list_source_repository.bzl", "list_source_repository")

list_source_repository(name = "local_bazel_source_list")

winsdk_configure = use_repo_rule("//src/main/res:winsdk_configure.bzl", "winsdk_configure")

winsdk_configure(name = "local_config_winsdk")

# /usr/local/kythe is setup on Bazel CI machines
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")

local_repository(
name = "kythe_release",
path = "/usr/local/kythe",
)

remote_coverage_tools_extension = use_extension("//tools/test:extensions.bzl", "remote_coverage_tools_extension")
use_repo(remote_coverage_tools_extension, "remote_coverage_tools")
Expand Down
7 changes: 4 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
"""

load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
load("//:distdir.bzl", "distdir_tar", "repo_cache_tar")
load("//:repositories.bzl", "DIST_ARCHIVE_REPOS", "embedded_jdk_repositories")
load("//:workspace_deps.bzl", "WORKSPACE_REPOS")
load("//src/main/res:winsdk_configure.bzl", "winsdk_configure")
load("//src/test/shell/bazel:list_source_repository.bzl", "list_source_repository")
load("//src/tools/bzlmod:utils.bzl", "parse_bazel_module_repos")
load("//tools/distributions/debian:deps.bzl", "debian_deps")

Expand All @@ -46,17 +43,3 @@ def _bazel_build_deps(ctx):
return ctx.extension_metadata(reproducible = True)

bazel_build_deps = module_extension(implementation = _bazel_build_deps)

### Dependencies for testing Bazel
def _bazel_test_deps(ctx):
list_source_repository(name = "local_bazel_source_list")
winsdk_configure(name = "local_config_winsdk")

# /usr/local/kythe is setup on Bazel CI machines
local_repository(
name = "kythe_release",
path = "/usr/local/kythe",
)
return ctx.extension_metadata(reproducible = True)

bazel_test_deps = module_extension(implementation = _bazel_test_deps)
28 changes: 0 additions & 28 deletions rbe_extension.bzl

This file was deleted.

23 changes: 23 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,29 @@ filegroup(
visibility = ["//:__pkg__"],
)

# Source files that can be excluded from //:bazel-distfile to avoid triggering the bootstrap test.
filegroup(
name = "srcs-to-exclude-in-distfile",
srcs = [
"//src/test/cpp:srcs",
"//src/test/gen:srcs",
"//src/test/java/com/google/devtools/build/docgen:srcs",
"//src/test/java/com/google/devtools/build/lib:srcs",
"//src/test/java/com/google/devtools/build/lib/shell:srcs",
"//src/test/java/com/google/devtools/build/skyframe:srcs",
"//src/test/java/com/google/devtools/common/options:srcs",
"//src/test/java/net/starlark/java/eval:srcs",
"//src/test/java/net/starlark/java/spelling:srcs",
"//src/test/native/windows:srcs",
"//src/test/py/bazel:srcs",
"//src/test/res:srcs",
"//src/test/shell:srcs",
"//src/test/testdata/test_tls_certificate",
"//src/test/tools:srcs",
],
visibility = ["//:__pkg__"],
)

genrule(
name = "derived_java_srcs",
srcs = [
Expand Down
3 changes: 3 additions & 0 deletions src/MODULE.tools
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "zlib", version = "1.3.1.bcr.3")
bazel_dep(name = "rules_proto", version = "7.0.2")

# Enforce a minimal required version
bazel_dep(name = "bazel_features", version = "1.21.0")

xcode_configure = use_extension("//tools/osx:xcode_configure.bzl", "xcode_configure_extension")
use_repo(xcode_configure, "local_config_xcode")

Expand Down
5 changes: 3 additions & 2 deletions src/test/tools/bzlmod/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 11596c3

Please sign in to comment.