Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.2.0] Cherry-picks for starlarkifying all repo rules #22133

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4555d1d
aquery: interpret "//foo:bar" as "all configured targets with label /…
Wyverald Mar 28, 2024
dd192e7
Local repo rules in Starlark
Wyverald Mar 14, 2024
41a3ba1
Add missing TOC entry to Starlark local repo rules
Wyverald Mar 21, 2024
839c48a
Remove tests for legacy non-platforms Android builds.
katre Nov 28, 2023
27e1b82
Remove `--crosstool_top` from tests
mai93 Mar 15, 2024
439caa2
Stop using `--android_cpu` in tests.
katre Mar 21, 2024
988edce
Fix C++ unit test to use C++ toolchains
comius Nov 29, 2023
be90874
Make incompatible_enable_cc_toolchain_resolution a no-op in android_s…
Wyverald Apr 25, 2024
1acd1f6
remove fat_apk_usage from blaze
a-googler Mar 12, 2024
2328206
Remove `--host_crosstool_top` and `--crosstool_top` from tests
mai93 Mar 14, 2024
df2b9df
Replace `--cpu` usages with `--platforms` in tests
mai93 Mar 19, 2024
1bb00bc
Use the `host_platform` from `@platforms` in Bazel
Wyverald Mar 29, 2024
67c3255
Forcibly use the bundled version of `@platforms` for loading the host…
Wyverald Apr 5, 2024
9b35e10
Force `local_config_platform` to redirect to the bundled platforms repo
Wyverald Apr 17, 2024
526d9fa
Extract Bazel registry creation into a SkyFunction
fmeum Apr 19, 2024
2d50139
Add new flag `--incompatible_disable_native_repo_rules`
Wyverald Apr 19, 2024
48bd6d7
Revert `android_sdk_repository` to using `local_config_platform`
Wyverald Apr 23, 2024
f0d328b
update lockfiles
Wyverald Apr 25, 2024
766c4ba
fix build?
Wyverald Apr 25, 2024
03ca07b
Fix obtaining C++ toolchains
comius Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ platform(
constraint_values = [
":highcpu_machine",
],
parents = ["@local_config_platform//:host"],
parents = ["@platforms//host"],
)

platform(
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "grpc", version = "1.48.1.bcr.1", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "rules_pkg", version = "0.9.1")
bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_skydoc")
bazel_dep(name = "zstd-jni", version = "1.5.2-3.bcr.1")
Expand Down
86 changes: 60 additions & 26 deletions MODULE.bazel.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lockFileVersion": 6,
"moduleFileHash": "e32e677a18c4d02bebe4c5df2d8c1d348e16ad8be10c4b0ab6a925f204b3a98c",
"moduleFileHash": "d687c7eccb1f2f0c8203804f6d808b08c3dfb79250428a9e137d136ff596e744",
"flags": {
"cmdRegistries": [
"https://bcr.bazel.build/"
Expand Down Expand Up @@ -614,7 +614,7 @@
"bazel_skylib": "bazel_skylib@1.5.0",
"com_google_protobuf": "protobuf@21.7",
"com_github_grpc_grpc": "grpc@1.48.1.bcr.1",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"rules_pkg": "rules_pkg@0.9.1",
"io_bazel_skydoc": "stardoc@0.5.6",
"zstd-jni": "zstd-jni@1.5.2-3.bcr.1",
Expand Down Expand Up @@ -678,7 +678,7 @@
],
"extensionUsages": [],
"deps": {
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
},
Expand Down Expand Up @@ -857,14 +857,32 @@
}
}
},
"platforms@0.0.8": {
"platforms@0.0.9": {
"name": "platforms",
"version": "0.0.8",
"key": "platforms@0.0.8",
"version": "0.0.9",
"key": "platforms@0.0.9",
"repoName": "platforms",
"executionPlatformsToRegister": [],
"toolchainsToRegister": [],
"extensionUsages": [],
"extensionUsages": [
{
"extensionBzlFile": "@platforms//host:extension.bzl",
"extensionName": "host_platform",
"usingModule": "platforms@0.0.9",
"location": {
"file": "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel",
"line": 9,
"column": 30
},
"imports": {
"host_platform": "host_platform"
},
"devImports": [],
"tags": [],
"hasDevUseExtension": false,
"hasNonDevUseExtension": true
}
],
"deps": {
"rules_license": "rules_license@0.0.7",
"bazel_tools": "bazel_tools@_",
Expand All @@ -875,9 +893,9 @@
"ruleClassName": "http_archive",
"attributes": {
"urls": [
"https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz"
"https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz"
],
"integrity": "sha256-gVBAZgU4ns7LbaB8vLUJ1WN6OrmiS8abEQFTE2fYnXQ=",
"integrity": "sha256-XtpTnIQSZQMcL4LYrno6ZJC9YhduDAOPxGnqv5H2FJs=",
"strip_prefix": "",
"remote_patches": {},
"remote_patch_strip": 0
Expand Down Expand Up @@ -1011,7 +1029,7 @@
"toolchainsToRegister": [],
"extensionUsages": [],
"deps": {
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"rules_cc": "rules_cc@0.0.9",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
Expand Down Expand Up @@ -1062,7 +1080,7 @@
}
],
"deps": {
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
},
Expand Down Expand Up @@ -1166,7 +1184,7 @@
}
],
"deps": {
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"rules_cc": "rules_cc@0.0.9",
"bazel_skylib": "bazel_skylib@1.5.0",
"rules_proto": "rules_proto@5.3.0-21.7",
Expand Down Expand Up @@ -1197,7 +1215,7 @@
"toolchainsToRegister": [],
"extensionUsages": [],
"deps": {
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_features": "bazel_features@1.1.0",
"rules_java": "rules_java@7.5.0",
"bazel_skylib": "bazel_skylib@1.5.0",
Expand Down Expand Up @@ -1546,7 +1564,7 @@
],
"deps": {
"bazel_skylib": "bazel_skylib@1.5.0",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"rules_java": "rules_java@7.5.0",
"rules_kotlin": "rules_kotlin@1.9.0",
"io_bazel_stardoc": "stardoc@0.5.6",
Expand Down Expand Up @@ -1664,7 +1682,7 @@
"deps": {
"bazel_features": "bazel_features@1.1.0",
"bazel_skylib": "bazel_skylib@1.5.0",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"rules_proto": "rules_proto@5.3.0-21.7",
"com_google_protobuf": "protobuf@21.7",
"bazel_tools": "bazel_tools@_",
Expand Down Expand Up @@ -1725,7 +1743,7 @@
"extensionUsages": [],
"deps": {
"com_google_absl": "abseil-cpp@20230125.1",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"rules_cc": "rules_cc@0.0.9",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
Expand Down Expand Up @@ -1813,7 +1831,7 @@
],
"deps": {
"bazel_skylib": "bazel_skylib@1.5.0",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
},
Expand Down Expand Up @@ -1843,7 +1861,7 @@
"extensionUsages": [],
"deps": {
"rules_cc": "rules_cc@0.0.9",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_skylib": "bazel_skylib@1.5.0",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
Expand Down Expand Up @@ -1875,7 +1893,7 @@
"deps": {
"bazel_skylib": "bazel_skylib@1.5.0",
"com_github_grpc_grpc": "grpc@1.48.1.bcr.1",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
},
Expand Down Expand Up @@ -2008,7 +2026,7 @@
],
"deps": {
"bazel_skylib": "bazel_skylib@1.5.0",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"rules_proto": "rules_proto@5.3.0-21.7",
"com_google_protobuf": "protobuf@21.7",
"gazelle": "gazelle@0.30.0",
Expand Down Expand Up @@ -2137,7 +2155,7 @@
}
],
"deps": {
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_skylib": "bazel_skylib@1.5.0",
"rules_java": "rules_java@7.5.0",
"rules_python": "rules_python@0.26.0",
Expand Down Expand Up @@ -2178,7 +2196,7 @@
"rules_proto": "rules_proto@5.3.0-21.7",
"com_google_protobuf": "protobuf@21.7",
"com_google_absl": "abseil-cpp@20230125.1",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
},
Expand Down Expand Up @@ -2343,7 +2361,7 @@
"rules_proto": "rules_proto@5.3.0-21.7",
"rules_python": "rules_python@0.26.0",
"buildozer": "buildozer@6.4.0.2",
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"com_google_protobuf": "protobuf@21.7",
"zlib": "zlib@1.3",
"build_bazel_apple_support": "apple_support@1.8.1",
Expand All @@ -2359,7 +2377,7 @@
"toolchainsToRegister": [],
"extensionUsages": [],
"deps": {
"platforms": "platforms@0.0.8",
"platforms": "platforms@0.0.9",
"bazel_tools": "bazel_tools@_"
}
},
Expand Down Expand Up @@ -2803,8 +2821,8 @@
"general": {
"bzlTransitiveDigest": "1xHBfvy8lWUE+9Ns02wqVWqROfZKJJFwZw62RuYDutw=",
"recordedFileInputs": {
"@@//MODULE.bazel": "e32e677a18c4d02bebe4c5df2d8c1d348e16ad8be10c4b0ab6a925f204b3a98c",
"@@//src/test/tools/bzlmod/MODULE.bazel.lock": "6b96a6a50f84f5403a718a27955a8c954943f76ee5c4def7f8b23401b2a417bf"
"@@//MODULE.bazel": "d687c7eccb1f2f0c8203804f6d808b08c3dfb79250428a9e137d136ff596e744",
"@@//src/test/tools/bzlmod/MODULE.bazel.lock": "aa02cf727fc271914357e6f23f27213d91fdea23e18e649a5915a24fc86148b4"
},
"recordedDirentsInputs": {},
"envVariables": {},
Expand Down Expand Up @@ -4384,6 +4402,22 @@
]
}
},
"@@platforms//host:extension.bzl%host_platform": {
"general": {
"bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"host_platform": {
"bzlFile": "@@platforms//host:extension.bzl",
"ruleClassName": "host_platform_repo",
"attributes": {}
}
},
"recordedRepoMappingEntries": []
}
},
"@@rules_go~//go:extensions.bzl%go_sdk": {
"general": {
"bzlTransitiveDigest": "k4MEsADgBfRC+sbMqB3lZL0JpdsCxlwSYO+z9zn9Y80=",
Expand Down
4 changes: 2 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ log "Building output/bazel"
# host.
bazel_build "src:bazel_nojdk${EXE_EXT}" \
--action_env=PATH \
--host_platform=@local_config_platform//:host \
--platforms=@local_config_platform//:host \
--host_platform=@platforms//host \
--platforms=@platforms//host \
|| fail "Could not build Bazel"
bazel_bin_path="$(get_bazel_bin_path)/src/bazel_nojdk${EXE_EXT}"
[ -e "$bazel_bin_path" ] \
Expand Down
3 changes: 2 additions & 1 deletion site/en/concepts/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ Project owners should define explicit
they want to build for. These are then triggered with `--platforms`.

When `--platforms` isn't set, Bazel defaults to a `platform` representing the
local build machine. This is auto-generated at `@local_config_platform//:host`
local build machine. This is auto-generated at `@platforms//host` (aliased as
`@bazel_tools//tools:host_platform`)
so there's no need to explicitly define it. It maps the local machine's `OS`
and `CPU` with `constraint_value`s declared in
[`@platforms`](https://github.com/bazelbuild/platforms){: .external}.
Expand Down
13 changes: 7 additions & 6 deletions site/en/extending/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,24 @@ systems. These are all located in
[https://github.com/bazelbuild/platforms](https://github.com/bazelbuild/platforms){: .external}.

Bazel ships with the following special platform definition:
`@local_config_platform//:host`. This is the autodetected host platform value -
`@platforms//host` (aliased as `@bazel_tools//tools:host_platform`). This is the
autodetected host platform value -
represents autodetected platform for the system Bazel is running on.

## Specifying a platform for a build {:#specifying-build-platform}

You can specify the host and target platforms for a build using the following
command-line flags:

* `--host_platform` - defaults to `@local_config_platform//:host`
* `@local_config_platform` is a repository rule that detects the host OS and
CPU and writes the platform target.
* It also creates `@local_config_platform//:constraintz.bzl`, which exposes
* `--host_platform` - defaults to `@bazel_tools//tools:host_platform`
* This target is aliased to `@platforms//host`, which is backed by a repo
rule that detects the host OS and CPU and writes the platform target.
* There's also `@platforms//host:constraints.bzl`, which exposes
an array called `HOST_CONSTRAINTS`, which can be used in other BUILD and
Starlark files.
* `--platforms` - defaults to the host platform
* This means that when no other flags are set,
`@local_config_platform//:host` is the target platform.
`@platforms//host` is the target platform.
* If `--host_platform` is set and not `--platforms`, the value of
`--host_platform` is both the host and target platform.

Expand Down
2 changes: 1 addition & 1 deletion src/MODULE.tools
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bazel_dep(name = "rules_proto", version = "4.0.0")
bazel_dep(name = "rules_python", version = "0.22.1")

bazel_dep(name = "buildozer", version = "7.1.1.1")
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "protobuf", version = "3.19.6", repo_name = "com_google_protobuf")
bazel_dep(name = "zlib", version = "1.3")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ toc:
path: /rules/lib/repo/git
- title: http
path: /rules/lib/repo/http
- title: local
path: /rules/lib/repo/local
- title: utils
path: /rules/lib/repo/utils
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ public Builder addWorkspaceFilePrefix(String contents) {
return this;
}

@CanIgnoreReturnValue
@VisibleForTesting
public Builder clearWorkspaceFilePrefixForTesting() {
defaultWorkspaceFilePrefix.delete(0, defaultWorkspaceFilePrefix.length());
return this;
}

@CanIgnoreReturnValue
public Builder addWorkspaceFileSuffix(String contents) {
defaultWorkspaceFileSuffix.append(contents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static boolean platformIsDefault(Label platform) {
name = "host_platform",
oldName = "experimental_host_platform",
converter = EmptyToNullLabelConverter.class,
defaultValue = "@local_config_platform//:host",
defaultValue = "@bazel_tools//tools:host_platform",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {
OptionEffectTag.AFFECTS_OUTPUTS,
Expand Down