From 74c8ca4886cfc188d60a18e796743e842f675842 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 29 Mar 2024 12:48:51 -0700 Subject: [PATCH] Use the `host_platform` from `@platforms` in Bazel * Upgrade to `platforms` 0.0.9 * `--host_platform` now defaults to `@bazel_tools//tools:host_platform`, which is an alias of `@platforms//host` * `local_config_platform` (the repo rule) now just outputs a thin wrapper; `@local_config_platform//:host` is an alias of `@platforms//host`, and `@local_config_platform//:constraints.bzl` re-exports `@platforms//host:constraints.bzl` * Removed all test mocks of `local_config_platform`. A follow-up will guard prod usage behind a flag. Work towards https://github.com/bazelbuild/bazel/issues/8766 and https://github.com/bazelbuild/bazel/issues/18285. PiperOrigin-RevId: 620316973 Change-Id: I6593f62569f31faee69e88a520a0f7f42009e05d --- BUILD | 2 +- MODULE.bazel | 2 +- MODULE.bazel.lock | 86 ++++--- compile.sh | 4 +- site/en/concepts/platforms.md | 3 +- site/en/extending/platforms.md | 13 +- src/MODULE.tools | 2 +- .../build/lib/analysis/PlatformOptions.java | 2 +- .../LocalConfigPlatformFunction.java | 92 +------- .../local_config_platform.WORKSPACE | 6 + .../lib/analysis/AnalysisCachingTest.java | 3 +- ...ConfigurationsForLateBoundTargetsTest.java | 7 +- .../StarlarkAttrTransitionProviderTest.java | 8 +- .../StarlarkRuleTransitionProviderTest.java | 4 +- .../lib/analysis/mock/BazelAnalysisMock.java | 18 +- .../LocalConfigPlatformFunctionTest.java | 211 +++++------------- .../android/AndroidNdkRepositoryTest.java | 11 +- .../android/AndroidSdkRepositoryTest.java | 2 - .../google/devtools/build/lib/metrics/BUILD | 1 + .../lib/metrics/MetricsCollectorTest.java | 11 +- .../packages/util/MockPlatformSupport.java | 22 +- .../testutil/PostAnalysisQueryTest.java | 3 +- .../build/lib/rules/cpp/CppSysrootTest.java | 17 +- .../config/PlatformMappingFunctionTest.java | 2 +- .../config/PlatformMappingValueTest.java | 2 +- .../build/lib/testutil/TestConstants.java | 12 +- .../py/bazel/bzlmod/bazel_lockfile_test.py | 15 +- src/test/shell/bazel/bazel_workspaces_test.sh | 3 + src/test/shell/bazel/cc_integration_test.sh | 2 +- src/test/shell/bazel/platforms_test.sh | 6 + src/test/shell/integration/toolchain_test.sh | 8 +- src/test/shell/testenv.sh.tmpl | 3 +- src/test/tools/bzlmod/MODULE.bazel.lock | 71 ++++-- tools/BUILD | 5 + .../android_sdk_repository_template.bzl | 2 +- 35 files changed, 285 insertions(+), 376 deletions(-) diff --git a/BUILD b/BUILD index db478cd38019ca..d7de378642f5de 100644 --- a/BUILD +++ b/BUILD @@ -271,7 +271,7 @@ platform( constraint_values = [ ":highcpu_machine", ], - parents = ["@local_config_platform//:host"], + parents = ["@platforms//host"], ) platform( diff --git a/MODULE.bazel b/MODULE.bazel index 430a906d513ea9..e829c892b62601 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index afee7ec7b41e0d..4227fc418947da 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 6, - "moduleFileHash": "8decdf21c36296d808acd795a03834e96bcf8cd31edfd95ce0f47b91094dfbaf", + "moduleFileHash": "96aa9a91f21734669335fe8cc95a151da63e3990b5489a023976df0d62f294c5", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -631,7 +631,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", @@ -695,7 +695,7 @@ ], "extensionUsages": [], "deps": { - "platforms": "platforms@0.0.8", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -874,14 +874,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@_", @@ -892,9 +910,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 @@ -1028,7 +1046,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@_" @@ -1079,7 +1097,7 @@ } ], "deps": { - "platforms": "platforms@0.0.8", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -1183,7 +1201,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", @@ -1214,7 +1232,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "platforms": "platforms@0.0.8", + "platforms": "platforms@0.0.9", "bazel_features": "bazel_features@1.1.1", "rules_java": "rules_java@7.5.0", "bazel_skylib": "bazel_skylib@1.5.0", @@ -1563,7 +1581,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", @@ -1681,7 +1699,7 @@ "deps": { "bazel_features": "bazel_features@1.1.1", "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@_", @@ -1742,7 +1760,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@_" @@ -1830,7 +1848,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@_" }, @@ -1860,7 +1878,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@_" @@ -1892,7 +1910,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@_" }, @@ -2025,7 +2043,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", @@ -2154,7 +2172,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.28.0", @@ -2195,7 +2213,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@_" }, @@ -2367,7 +2385,7 @@ "rules_proto": "rules_proto@5.3.0-21.7", "rules_python": "rules_python@0.28.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", @@ -2383,7 +2401,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "platforms": "platforms@0.0.8", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_" } }, @@ -2827,8 +2845,8 @@ "general": { "bzlTransitiveDigest": "aUI/st4EW9i8qtBNAuP8n/ZqWg45cC/XT4qKpSzhCtc=", "recordedFileInputs": { - "@@//MODULE.bazel": "8decdf21c36296d808acd795a03834e96bcf8cd31edfd95ce0f47b91094dfbaf", - "@@//src/test/tools/bzlmod/MODULE.bazel.lock": "9afc690f573ce061e8c59773a8bcd3af0133bfd1b2856a1e1dba2a72d4ded49f" + "@@//MODULE.bazel": "96aa9a91f21734669335fe8cc95a151da63e3990b5489a023976df0d62f294c5", + "@@//src/test/tools/bzlmod/MODULE.bazel.lock": "9dfd761d5514e2594872dfeba760dd5abd378abcc638e2047972046a011bc214" }, "recordedDirentsInputs": {}, "envVariables": {}, @@ -4424,6 +4442,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=", diff --git a/compile.sh b/compile.sh index d91583d277cba8..90f2a29f8d39b2 100755 --- a/compile.sh +++ b/compile.sh @@ -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" ] \ diff --git a/site/en/concepts/platforms.md b/site/en/concepts/platforms.md index b89357fbb3fbe0..a99ffea6a65f34 100644 --- a/site/en/concepts/platforms.md +++ b/site/en/concepts/platforms.md @@ -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}. diff --git a/site/en/extending/platforms.md b/site/en/extending/platforms.md index 16b6868356d1df..b5834c5b211f62 100644 --- a/site/en/extending/platforms.md +++ b/site/en/extending/platforms.md @@ -106,7 +106,8 @@ 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} @@ -114,15 +115,15 @@ represents autodetected platform for the system Bazel is running on. 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 repo backed by a repo rule that detects the - host OS and CPU and writes the platform target. - * It also creates `@local_config_platform//:constraints.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. diff --git a/src/MODULE.tools b/src/MODULE.tools index 402d6b58c42686..3ca5e6fcfe88a4 100644 --- a/src/MODULE.tools +++ b/src/MODULE.tools @@ -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 = "6.4.0.2") -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") diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java index 729e3bedda8561..57822ef4e6da5a 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java @@ -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, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java index ef55022af8ceea..709943d058103f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java @@ -24,19 +24,15 @@ import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryValue; import com.google.devtools.build.lib.rules.repository.RepositoryFunction; import com.google.devtools.build.lib.rules.repository.ResolvedFileValue; -import com.google.devtools.build.lib.util.CPU; -import com.google.devtools.build.lib.util.OS; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.XattrProvider; import com.google.devtools.build.skyframe.SkyFunction.Environment; import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyKey; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import javax.annotation.Nullable; /** Create a local repository that describes the auto-detected host platform. */ public class LocalConfigPlatformFunction extends RepositoryFunction { @@ -60,18 +56,13 @@ public RepositoryDirectoryValue.Builder fetch( Map recordedInputValues, SkyKey key) throws RepositoryFunctionException { - - CPU hostCpu = CPU.getCurrent(); - OS hostOs = OS.getCurrent(); - String name = rule.getName(); try { outputDirectory.createDirectoryAndParents(); RepositoryFunction.writeFile(outputDirectory, "WORKSPACE", workspaceFileContent(name)); RepositoryFunction.writeFile(outputDirectory, "MODULE.bazel", moduleFileContent(name)); - RepositoryFunction.writeFile(outputDirectory, "BUILD.bazel", buildFileContent(name)); - RepositoryFunction.writeFile( - outputDirectory, "constraints.bzl", constraintFileContent(hostCpu, hostOs)); + RepositoryFunction.writeFile(outputDirectory, "BUILD.bazel", buildFileContent()); + RepositoryFunction.writeFile(outputDirectory, "constraints.bzl", constraintFileContent()); } catch (IOException e) { throw new RepositoryFunctionException( new IOException("Could not create content for " + name + ": " + e.getMessage()), @@ -104,50 +95,6 @@ public Object getResolvedInformation(XattrProvider xattrProvider) { return RepositoryDirectoryValue.builder().setPath(outputDirectory); } - @Nullable - static String cpuToConstraint(CPU cpu) { - switch (cpu) { - case X86_32: - return "@platforms//cpu:x86_32"; - case X86_64: - return "@platforms//cpu:x86_64"; - case PPC: - return "@platforms//cpu:ppc"; - case ARM: - return "@platforms//cpu:arm"; - case AARCH64: - return "@platforms//cpu:aarch64"; - case S390X: - return "@platforms//cpu:s390x"; - case MIPS64: - return "@platforms//cpu:mips64"; - case RISCV64: - return "@platforms//cpu:riscv64"; - default: - // Unknown, so skip it. - return null; - } - } - - @Nullable - static String osToConstraint(OS os) { - switch (os) { - case DARWIN: - return "@platforms//os:osx"; - case FREEBSD: - return "@platforms//os:freebsd"; - case OPENBSD: - return "@platforms//os:openbsd"; - case LINUX: - return "@platforms//os:linux"; - case WINDOWS: - return "@platforms//os:windows"; - default: - // Unknown, so skip it. - return null; - } - } - private static String workspaceFileContent(String repositoryName) { return format( ImmutableList.of( @@ -167,41 +114,24 @@ private static String moduleFileContent(String repositoryName) { repositoryName); } - private static String buildFileContent(String repositoryName) { + private static String buildFileContent() { return format( ImmutableList.of( "# DO NOT EDIT: automatically generated BUILD file for local_config_platform", "package(default_visibility = ['//visibility:public'])", - "load(':constraints.bzl', 'HOST_CONSTRAINTS')", - "platform(name = 'host',", - " # Auto-detected host platform constraints.", - " constraint_values = HOST_CONSTRAINTS,", - ")", + "alias(name = 'host', actual = '@platforms//host')", "exports_files([", " # Export constraints.bzl for use in downstream bzl_library targets.", " 'constraints.bzl',", - "])"), - repositoryName); + "])")); } - private static String constraintFileContent(CPU hostCpu, OS hostOs) { - List contents = new ArrayList<>(); - contents.add( - "# DO NOT EDIT: automatically generated constraints list for local_config_platform"); - contents.add("# Auto-detected host platform constraints."); - contents.add("HOST_CONSTRAINTS = ["); - - String cpuConstraint = cpuToConstraint(hostCpu); - if (cpuConstraint != null) { - contents.add(" '" + cpuConstraint + "',"); - } - String osConstraint = osToConstraint(hostOs); - if (osConstraint != null) { - contents.add(" '" + osConstraint + "',"); - } - contents.add("]"); - - return format(contents); + private static String constraintFileContent() { + return format( + ImmutableList.of( + "# DO NOT EDIT: automatically generated constraints list for local_config_platform", + "load('@platforms//host:constraints.bzl', _HOST_CONSTRAINTS='HOST_CONSTRAINTS')", + "HOST_CONSTRAINTS = _HOST_CONSTRAINTS")); } private static String format(List lines, Object... params) { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE index 6793501d23221a..901b3f3ae8653c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE @@ -10,3 +10,9 @@ maybe( local_config_platform, "local_config_platform", ) + +load("@platforms//host:extension.bzl", "host_platform_repo") +maybe( + host_platform_repo, + "host_platform", +) diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java index 5d19b2d732824a..977854c92bb32f 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java @@ -1407,8 +1407,7 @@ public void cacheClearMessageAfterChangingPlatform() throws Exception { "--max_config_changes_to_show=-1", "--platforms=" + TestConstants.PLATFORM_LABEL); update("//test:top"); useConfiguration( - "--max_config_changes_to_show=-1", - "--platforms=" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":piii"); + "--max_config_changes_to_show=-1", "--platforms=" + TestConstants.PIII_PLATFORM_LABEL); eventCollector.clear(); update("//test:top"); assertDoesNotContainEvent("--discard_analysis_cache"); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java index 9203111e077492..22d2513e6f67dd 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurationsForLateBoundTargetsTest.java @@ -17,6 +17,8 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.packages.Attribute.attr; import static com.google.devtools.build.lib.packages.BuildType.LABEL; +import static com.google.devtools.build.lib.testutil.TestConstants.PLATFORM_LABEL; +import static com.google.devtools.build.lib.testutil.TestConstants.PLATFORM_LABEL_ALIAS; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -140,8 +142,7 @@ public void lateBoundAttributeInExecConfiguration() throws Exception { ImmutableList.copyOf( SkyframeExecutorTestUtils.getExistingConfiguredTargets( skyframeExecutor, Label.parseCanonical("//foo:latebound_dep"))); - assertThat(deps).hasSize(1); - assertThat(deps.stream().filter(d -> getConfiguration(d).isExecConfiguration()).findFirst()) - .isPresent(); + assertThat(deps).hasSize(PLATFORM_LABEL_ALIAS.equals(PLATFORM_LABEL) ? 1 : 2); + assertThat(deps.stream().allMatch(d -> getConfiguration(d).isExecConfiguration())).isTrue(); } } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/StarlarkAttrTransitionProviderTest.java b/src/test/java/com/google/devtools/build/lib/analysis/StarlarkAttrTransitionProviderTest.java index 3b0d36f9b36343..d0445a5e2af3aa 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/StarlarkAttrTransitionProviderTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/StarlarkAttrTransitionProviderTest.java @@ -3244,9 +3244,7 @@ def impl(ctx): // When --platforms is empty and no platform mapping triggers, PlatformMappingValue sets // --platforms to PlatformOptions.computeTargetPlatform(), which defaults to the host. assertThat(getConfiguration(dep).getOptions().get(PlatformOptions.class).platforms) - .containsExactly( - Label.parseCanonicalUnchecked( - TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":host")); + .containsExactly(Label.parseCanonicalUnchecked(TestConstants.PLATFORM_LABEL_ALIAS)); } @Test @@ -3322,7 +3320,7 @@ public void testNoPlatformChange() throws Exception { scratch.file( "platforms/BUILD", "platform(name = 'my_platform',", - " parents = ['" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":host'],", + " parents = ['" + TestConstants.PLATFORM_LABEL + "'],", " constraint_values = [],", ")"); scratch.file( @@ -3383,7 +3381,7 @@ public void testCpuNoOpChangeIsFullyNoOp() throws Exception { scratch.file( "platforms/BUILD", "platform(name = 'my_platform',", - " parents = ['" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":host'],", + " parents = ['" + TestConstants.PLATFORM_LABEL + "'],", " constraint_values = [],", ")"); scratch.file( diff --git a/src/test/java/com/google/devtools/build/lib/analysis/StarlarkRuleTransitionProviderTest.java b/src/test/java/com/google/devtools/build/lib/analysis/StarlarkRuleTransitionProviderTest.java index 188f33d78c72a1..d2c5e4fa8e83ad 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/StarlarkRuleTransitionProviderTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/StarlarkRuleTransitionProviderTest.java @@ -1961,9 +1961,7 @@ def _transition_impl(settings, attr): .getOptions() .get(PlatformOptions.class) .platforms) - .containsExactly( - Label.parseCanonicalUnchecked( - TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":host")); + .containsExactly(Label.parseCanonicalUnchecked(TestConstants.PLATFORM_LABEL_ALIAS)); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java index 5c0778f7ff4465..1afc59904681b5 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java @@ -63,8 +63,6 @@ public ImmutableList getWorkspaceContents(MockToolsConfig config) { String bazelPlatformsWorkspace = config.getPath("platforms_workspace").getPathString(); String rulesJavaWorkspace = config.getPath("rules_java_workspace").getPathString(); String androidGmavenR8Workspace = config.getPath("android_gmaven_r8").getPathString(); - String localConfigPlatformWorkspace = - config.getPath("local_config_platform_workspace").getPathString(); String appleSupport = config.getPath("build_bazel_apple_support").getPathString(); return ImmutableList.of( @@ -98,10 +96,7 @@ public ImmutableList getWorkspaceContents(MockToolsConfig config) { // Note this path is created inside the test infrastructure in // createAndroidBuildContents() below. It may not reflect a real depot path. "register_toolchains('@bazel_tools//tools/android/dummy_sdk:all')", - "register_toolchains('@bazel_tools//tools/python:autodetecting_toolchain')", - "local_repository(name = 'local_config_platform', path = '" - + localConfigPlatformWorkspace - + "')"); + "register_toolchains('@bazel_tools//tools/python:autodetecting_toolchain')"); } /** Keep this in sync with the WORKSPACE content in {@link #getWorkspaceContents}. */ @@ -111,7 +106,6 @@ public ImmutableList getWorkspaceRepos() { "android_gmaven_r8", "bazel_tools", "com_google_protobuf", - "local_config_platform", "local_config_xcode", "platforms", "rules_java", @@ -149,10 +143,6 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten /* The rest of platforms is initialized in {@link MockPlatformSupport}. */ config.create("platforms_workspace/WORKSPACE", "workspace(name = 'platforms')"); config.create("platforms_workspace/MODULE.bazel", "module(name = 'platforms')"); - config.create( - "local_config_platform_workspace/WORKSPACE", "workspace(name = 'local_config_platform')"); - config.create( - "local_config_platform_workspace/MODULE.bazel", "module(name = 'local_config_platform')"); config.create("build_bazel_apple_support/WORKSPACE", "workspace(name = 'apple_support')"); config.create( "build_bazel_apple_support/MODULE.bazel", "module(name = 'build_bazel_apple_support')"); @@ -337,7 +327,7 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten "package(default_visibility=['//visibility:public'])", "platform(", " name = 'armeabi-v7a',", - " parents = ['" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":host'],", + " parents = ['" + TestConstants.PLATFORM_LABEL + "'],", " constraint_values = [", " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:android',", " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:armv7',", @@ -413,6 +403,9 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten MockGenruleSupport.setup(config); + config.create( + "embedded_tools/tools/BUILD", + "alias(name='host_platform',actual='" + TestConstants.PLATFORM_LABEL + "')"); config.create( "embedded_tools/tools/test/BUILD", """ @@ -926,7 +919,6 @@ public ImmutableMap getBuiltinModules(BlazeDirector ImmutableMap.builder() .put("bazel_tools", "embedded_tools") .put("platforms", "platforms_workspace") - .put("local_config_platform", "local_config_platform_workspace") .put("rules_java", "rules_java_workspace") .put("com_google_protobuf", "protobuf_workspace") .put("rules_proto", "third_party/bazel_rules/rules_proto") diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunctionTest.java index 7f016b657a30e4..60364d4bf8c2cc 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunctionTest.java @@ -16,180 +16,81 @@ import static com.google.common.truth.Truth.assertThat; -import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.platform.ConstraintSettingInfo; -import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.util.AbruptExitException; -import com.google.devtools.build.lib.util.CPU; -import com.google.devtools.build.lib.util.OS; import java.io.IOException; -import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; /** Tests for {@link LocalConfigPlatformFunction}. */ -@RunWith(Enclosed.class) -public class LocalConfigPlatformFunctionTest { - - /** Parameterized tests on CPU. */ - @RunWith(Parameterized.class) - public static class CpuConstraintTest { - @Parameters - public static Collection createInputValues() { - return ImmutableList.of( - // CPU value tests. - new Object[] {CPU.X86_64, "@platforms//cpu:x86_64"}, - new Object[] {CPU.X86_32, "@platforms//cpu:x86_32"}, - new Object[] {CPU.PPC, "@platforms//cpu:ppc"}, - new Object[] {CPU.ARM, "@platforms//cpu:arm"}, - new Object[] {CPU.AARCH64, "@platforms//cpu:aarch64"}, - new Object[] {CPU.S390X, "@platforms//cpu:s390x"}); - } - - private final CPU testCpu; - private final String expectedCpuConstraint; - - public CpuConstraintTest(CPU testCpu, String expectedCpuConstraint) { - this.testCpu = testCpu; - this.expectedCpuConstraint = expectedCpuConstraint; - } - - @Test - public void cpuConstraint() { - String constraint = LocalConfigPlatformFunction.cpuToConstraint(testCpu); - assertThat(constraint).isNotNull(); - assertThat(constraint).isEqualTo(expectedCpuConstraint); - } - - @Test - public void unknownCpuConstraint() { - assertThat(LocalConfigPlatformFunction.cpuToConstraint(CPU.UNKNOWN)).isNull(); - } +@RunWith(JUnit4.class) +public class LocalConfigPlatformFunctionTest extends BuildViewTestCase { + private static final ConstraintSettingInfo CPU_CONSTRAINT = + ConstraintSettingInfo.create(Label.parseCanonicalUnchecked("@platforms//cpu:cpu")); + private static final ConstraintSettingInfo OS_CONSTRAINT = + ConstraintSettingInfo.create(Label.parseCanonicalUnchecked("@platforms//os:os")); + + @Before + public void addLocalConfigPlatform() + throws InterruptedException, IOException, AbruptExitException { + scratch.appendFile("WORKSPACE", "local_config_platform(name='local_config_platform_test')"); + invalidatePackages(); } - /** Parameterized tests on OS. */ - @RunWith(Parameterized.class) - public static class OsConstraintTest { - @Parameters - public static Collection createInputValues() { - return ImmutableList.of( - // OS value tests. - new Object[] {OS.LINUX, "@platforms//os:linux"}, - new Object[] {OS.DARWIN, "@platforms//os:osx"}, - new Object[] {OS.FREEBSD, "@platforms//os:freebsd"}, - new Object[] {OS.OPENBSD, "@platforms//os:openbsd"}, - new Object[] {OS.WINDOWS, "@platforms//os:windows"}); - } - - private final OS testOs; - private final String expectedOsConstraint; + @Test + public void generateConfigRepository() throws Exception { + // Verify the package was created as expected. + ConfiguredTarget hostPlatform = getConfiguredTarget("@local_config_platform_test//:host"); + assertThat(hostPlatform).isNotNull(); - public OsConstraintTest(OS testOs, String expectedOsConstraint) { - this.testOs = testOs; - this.expectedOsConstraint = expectedOsConstraint; - } + PlatformInfo hostPlatformProvider = PlatformProviderUtils.platform(hostPlatform); + assertThat(hostPlatformProvider).isNotNull(); - @Test - public void osConstraint() { - String constraint = LocalConfigPlatformFunction.osToConstraint(testOs); - assertThat(constraint).isNotNull(); - assertThat(constraint).isEqualTo(expectedOsConstraint); - } - - @Test - public void unknownOsConstraint() { - assertThat(LocalConfigPlatformFunction.osToConstraint(OS.UNKNOWN)).isNull(); - } + // Verify the OS and CPU constraints exist. + assertThat(hostPlatformProvider.constraints().has(CPU_CONSTRAINT)).isTrue(); + assertThat(hostPlatformProvider.constraints().has(OS_CONSTRAINT)).isTrue(); } - /** Tests on overall functionality. */ - @RunWith(JUnit4.class) - public static class FunctionTest extends BuildViewTestCase { - private static final ConstraintSettingInfo CPU_CONSTRAINT = - ConstraintSettingInfo.create(Label.parseCanonicalUnchecked("@platforms//cpu:cpu")); - private static final ConstraintSettingInfo OS_CONSTRAINT = - ConstraintSettingInfo.create(Label.parseCanonicalUnchecked("@platforms//os:os")); - - @Before - public void addLocalConfigPlatform() - throws InterruptedException, IOException, AbruptExitException { - scratch.appendFile("WORKSPACE", "local_config_platform(name='local_config_platform_test')"); - invalidatePackages(); - } - - @Test - public void generateConfigRepository() throws Exception { - // Verify the package was created as expected. - ConfiguredTarget hostPlatform = getConfiguredTarget("@local_config_platform_test//:host"); - assertThat(hostPlatform).isNotNull(); - - PlatformInfo hostPlatformProvider = PlatformProviderUtils.platform(hostPlatform); - assertThat(hostPlatformProvider).isNotNull(); - - // Verify the OS and CPU constraints. - ConstraintValueInfo expectedCpuConstraint = - ConstraintValueInfo.create( - CPU_CONSTRAINT, - Label.parseCanonicalUnchecked( - LocalConfigPlatformFunction.cpuToConstraint(CPU.getCurrent()))); - assertThat(hostPlatformProvider.constraints().has(CPU_CONSTRAINT)).isTrue(); - assertThat(hostPlatformProvider.constraints().get(CPU_CONSTRAINT)) - .isEqualTo(expectedCpuConstraint); - - ConstraintValueInfo expectedOsConstraint = - ConstraintValueInfo.create( - OS_CONSTRAINT, - Label.parseCanonicalUnchecked( - LocalConfigPlatformFunction.osToConstraint(OS.getCurrent()))); - assertThat(hostPlatformProvider.constraints().has(OS_CONSTRAINT)).isTrue(); - assertThat(hostPlatformProvider.constraints().get(OS_CONSTRAINT)) - .isEqualTo(expectedOsConstraint); - } - - @Test - public void testHostConstraints() throws Exception { - scratch.file( - "test/platform/my_platform.bzl", - "def _impl(ctx):", - " constraints = [val[platform_common.ConstraintValueInfo] " - + "for val in ctx.attr.constraints]", - " platform = platform_common.PlatformInfo(", - " label = ctx.label, constraint_values = constraints)", - " return [platform]", - "my_platform = rule(", - " implementation = _impl,", - " attrs = {", - " 'constraints': attr.label_list(providers = [platform_common.ConstraintValueInfo])", - " }", - ")"); - scratch.file( - "test/platform/BUILD", - """ - load("@local_config_platform_test//:constraints.bzl", "HOST_CONSTRAINTS") - load("//test/platform:my_platform.bzl", "my_platform") - - my_platform( - name = "custom", - constraints = HOST_CONSTRAINTS, - ) - """); - - setBuildLanguageOptions("--experimental_platforms_api"); - ConfiguredTarget platform = getConfiguredTarget("//test/platform:custom"); - assertThat(platform).isNotNull(); - - PlatformInfo provider = PlatformProviderUtils.platform(platform); - assertThat(provider.constraints()).isNotNull(); - } + @Test + public void testHostConstraints() throws Exception { + scratch.file( + "test/platform/my_platform.bzl", + "def _impl(ctx):", + " constraints = [val[platform_common.ConstraintValueInfo] " + + "for val in ctx.attr.constraints]", + " platform = platform_common.PlatformInfo(", + " label = ctx.label, constraint_values = constraints)", + " return [platform]", + "my_platform = rule(", + " implementation = _impl,", + " attrs = {", + " 'constraints': attr.label_list(providers = [platform_common.ConstraintValueInfo])", + " }", + ")"); + scratch.file( + "test/platform/BUILD", + """ + load("@local_config_platform_test//:constraints.bzl", "HOST_CONSTRAINTS") + load("//test/platform:my_platform.bzl", "my_platform") + + my_platform( + name = "custom", + constraints = HOST_CONSTRAINTS, + ) + """); + + setBuildLanguageOptions("--experimental_platforms_api"); + ConfiguredTarget platform = getConfiguredTarget("//test/platform:custom"); + assertThat(platform).isNotNull(); + + PlatformInfo provider = PlatformProviderUtils.platform(platform); + assertThat(provider.constraints()).isNotNull(); } } diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java index ee04d765c46158..b4eab52c34bb5e 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java @@ -75,19 +75,12 @@ public void setup() throws Exception { // Set up a fake @platforms repository. scratch.appendFile( "WORKSPACE", "local_repository(name = 'platforms', path = 'platforms_workspace')"); - scratch.appendFile("WORKSPACE", "local_config_platform(name='local_config_platform')"); - if (!scratch.resolve("platforms_workspace/WORKSPACE").exists() - || !scratch.resolve("local_config_platform_workspace/WORKSPACE").exists()) { + if (!scratch.resolve("platforms_workspace/WORKSPACE").exists()) { // Create the needed platforms and constraints if they don't already exist. scratch.file("platforms_workspace/WORKSPACE", "workspace(name = 'platforms')"); MockPlatformSupport.setup( - mockToolsConfig, - "embedded_tools/platforms", - "@platforms//", - "platforms_workspace", - "@local_config_platform//", - "local_config_platform_workspace"); + mockToolsConfig, "embedded_tools/platforms", "@platforms//", "platforms_workspace"); } } diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryTest.java index 3e5d59b4ea3352..c78227f161bf66 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryTest.java @@ -41,8 +41,6 @@ public void setup() throws Exception { scratch.file( "embedded_tools/tools/android/android_sdk_repository_template.bzl", ResourceLoader.readFromResources("tools/android/android_sdk_repository_template.bzl")); - scratch.appendFile("WORKSPACE", "local_config_platform(name='local_config_platform')"); - scratch.overwriteFile("local_config_platform_workspace/constraints.bzl", "HOST_CONSTRAINTS=[]"); } private void scratchPlatformsDirectories(int... apiLevels) throws Exception { diff --git a/src/test/java/com/google/devtools/build/lib/metrics/BUILD b/src/test/java/com/google/devtools/build/lib/metrics/BUILD index 10026ef8f0d792..c9c934aace7ac0 100644 --- a/src/test/java/com/google/devtools/build/lib/metrics/BUILD +++ b/src/test/java/com/google/devtools/build/lib/metrics/BUILD @@ -48,6 +48,7 @@ java_test( "//src/main/java/com/google/devtools/build/lib/worker:worker_process_metrics", "//src/main/java/com/google/devtools/build/lib/worker:worker_process_status", "//src/test/java/com/google/devtools/build/lib/buildtool/util", + "//src/test/java/com/google/devtools/build/lib/testutil:TestConstants", "//third_party:guava", "//third_party:junit4", "//third_party:truth", diff --git a/src/test/java/com/google/devtools/build/lib/metrics/MetricsCollectorTest.java b/src/test/java/com/google/devtools/build/lib/metrics/MetricsCollectorTest.java index a695611991a18b..be44ba4c36e2eb 100644 --- a/src/test/java/com/google/devtools/build/lib/metrics/MetricsCollectorTest.java +++ b/src/test/java/com/google/devtools/build/lib/metrics/MetricsCollectorTest.java @@ -15,6 +15,8 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; +import static com.google.devtools.build.lib.testutil.TestConstants.PLATFORM_LABEL; +import static com.google.devtools.build.lib.testutil.TestConstants.PLATFORM_LABEL_ALIAS; import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableList; @@ -191,7 +193,7 @@ public void buildGraphAndArtifactMetrics() throws Exception { .isEqualTo( BuildGraphMetrics.newBuilder() .setOutputFileConfiguredTargetCount(1) - .setOtherConfiguredTargetCount(1) + .setOtherConfiguredTargetCount(PLATFORM_LABEL_ALIAS.equals(PLATFORM_LABEL) ? 1 : 2) .build()); int outputArtifactCount = buildGraphMetrics.getOutputArtifactCount(); assertThat(outputArtifactCount).isGreaterThan(0); @@ -282,6 +284,7 @@ public void buildGraphAndArtifactMetrics() throws Exception { .setActionCountNotIncludingAspects(2 + actionCount) .setInputFileConfiguredTargetCount(4) .setOutputArtifactCount(2 + outputArtifactCount) + .setOtherConfiguredTargetCount(PLATFORM_LABEL_ALIAS.equals(PLATFORM_LABEL) ? 0 : 1) // ArtifactNestedSet node for stale nested set is still in graph, since it is // technically still valid (even though nobody wants that nested set anymore). .setPostInvocationSkyframeNodeCount(newGraphSize + 1) @@ -312,6 +315,7 @@ public void buildGraphAndArtifactMetrics() throws Exception { .setActionCountNotIncludingAspects(2 + actionCount) .setInputFileConfiguredTargetCount(4) .setOutputArtifactCount(2 + outputArtifactCount) + .setOtherConfiguredTargetCount(PLATFORM_LABEL_ALIAS.equals(PLATFORM_LABEL) ? 0 : 1) .setPostInvocationSkyframeNodeCount(newGraphSize + 1) .build()); assertThat(buildMetricsEventListener.event.getBuildMetrics().getArtifactMetrics()) @@ -717,8 +721,9 @@ public void skymeldNullIncrementalBuild_buildGraphMetricsNotCollected() throws E addOptions("--experimental_merged_skyframe_analysis_execution"); BuildGraphMetrics expected = BuildGraphMetrics.newBuilder() - .setActionLookupValueCount(8) - .setActionLookupValueCountNotIncludingAspects(8) + .setActionLookupValueCount(PLATFORM_LABEL_ALIAS.equals(PLATFORM_LABEL) ? 8 : 9) + .setActionLookupValueCountNotIncludingAspects( + PLATFORM_LABEL_ALIAS.equals(PLATFORM_LABEL) ? 8 : 9) .setActionCount(2) .setActionCountNotIncludingAspects(2) .setInputFileConfiguredTargetCount(1) diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java index a4b893c3fcabc3..8f01cab58e8aeb 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java @@ -26,9 +26,7 @@ public static void setup(MockToolsConfig mockToolsConfig) throws IOException { mockToolsConfig, TestConstants.PLATFORMS_PATH, TestConstants.CONSTRAINTS_PACKAGE_ROOT, - TestConstants.CONSTRAINTS_PATH, - TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT, - TestConstants.LOCAL_CONFIG_PLATFORM_PATH); + TestConstants.CONSTRAINTS_PATH); } /** Adds mocks for basic exec and target platform. */ @@ -36,9 +34,7 @@ public static void setup( MockToolsConfig mockToolsConfig, String platformsPath, String constraintsPackageRoot, - String constraintsPath, - String localConfigPlatformPackageRoot, - String localConfigPlatformPath) + String constraintsPath) throws IOException { mockToolsConfig.create( constraintsPath + "/BUILD", @@ -170,7 +166,7 @@ public static void setup( " ],", ")"); mockToolsConfig.create( - localConfigPlatformPath + "/BUILD", + constraintsPath + "/host/BUILD", "package(default_visibility=['//visibility:public'])", "licenses(['notice'])", "platform(", @@ -189,6 +185,16 @@ public static void setup( " '" + constraintsPackageRoot + "os:linux',", " ],", ")"); + mockToolsConfig.create( + constraintsPath + "/host/constraints.bzl", + "HOST_CONSTRAINTS = [", + // Regardless of the actual machine the tests are run on, hardcode everything to a single + // default value for simplicity. + " '" + constraintsPackageRoot + "cpu:x86_64',", + " '" + constraintsPackageRoot + "os:linux',", + " ]"); + mockToolsConfig.create( + constraintsPath + "/host/extension.bzl", "def host_platform_repo(**kwargs):", " pass"); mockToolsConfig.create( "third_party/bazel_platforms/android/BUILD", @@ -196,7 +202,7 @@ public static void setup( "package(default_visibility=['//visibility:public'])", "platform(", " name = 'armeabi-v7a',", - " parents = ['" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":host'],", + " parents = ['" + TestConstants.PLATFORM_LABEL + "'],", " constraint_values = [", " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:android',", " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:armv7',", diff --git a/src/test/java/com/google/devtools/build/lib/query2/testutil/PostAnalysisQueryTest.java b/src/test/java/com/google/devtools/build/lib/query2/testutil/PostAnalysisQueryTest.java index 41bd75b6528a33..a11923f1644edc 100644 --- a/src/test/java/com/google/devtools/build/lib/query2/testutil/PostAnalysisQueryTest.java +++ b/src/test/java/com/google/devtools/build/lib/query2/testutil/PostAnalysisQueryTest.java @@ -17,6 +17,7 @@ import static com.google.devtools.build.lib.packages.Attribute.attr; import static com.google.devtools.build.lib.packages.BuildType.LABEL; import static com.google.devtools.build.lib.testutil.TestConstants.PLATFORM_LABEL; +import static com.google.devtools.build.lib.testutil.TestConstants.PLATFORM_LABEL_ALIAS; import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableList; @@ -61,7 +62,7 @@ public abstract class PostAnalysisQueryTest extends AbstractQueryTest { // Also filter out platform dependencies. @Override protected String getDependencyCorrection() { - return " - deps(" + PLATFORM_LABEL + ")"; + return " - deps(" + PLATFORM_LABEL_ALIAS + ")"; } static final String DEFAULT_UNIVERSE = "DEFAULT_UNIVERSE"; diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppSysrootTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppSysrootTest.java index e8e09035b281e1..7fe518449adc0a 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppSysrootTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppSysrootTest.java @@ -157,26 +157,23 @@ public void testSysrootInFeatureConfigBlocksLegacySysroot() throws Exception { @Test public void testSysrootWithExecConfig() throws Exception { // The exec BuildConfigurationValue shouldn't provide a sysroot option by default. - for (String platform : new String[] {"piii", "host"}) { - useConfiguration( - "--platforms=" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":" + platform); + for (String platform : + new String[] {TestConstants.PLATFORM_LABEL, TestConstants.PIII_PLATFORM_LABEL}) { + useConfiguration("--platforms=" + platform); BuildConfigurationValue config = getExecConfiguration(); testCCFlagsContainsSysroot(config, "/usr/grte/v1", true); } // The exec BuildConfigurationValue should work with label grte_top options. scratch.file("a/grte/top/BUILD", "filegroup(name='everything')"); - for (String platform : new String[] {"piii", "host"}) { - useConfiguration( - "--platforms=" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":" + platform, - "--host_grte_top=//a/grte/top"); + for (String platform : + new String[] {TestConstants.PLATFORM_LABEL, TestConstants.PIII_PLATFORM_LABEL}) { + useConfiguration("--platforms=" + platform, "--host_grte_top=//a/grte/top"); BuildConfigurationValue config = getExecConfiguration(); testCCFlagsContainsSysroot(config, "a/grte/top", true); // "--grte_top" does *not* set the exec grte_top, // so we don't get "a/grte/top" here, but instead the default "/usr/grte/v1" - useConfiguration( - "--platforms=" + TestConstants.LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":" + platform, - "--grte_top=//a/grte/top"); + useConfiguration("--platforms=" + platform, "--grte_top=//a/grte/top"); config = getExecConfiguration(); testCCFlagsContainsSysroot(config, "/usr/grte/v1", true); } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingFunctionTest.java index 7c16677b991999..98fd7d883a1b99 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingFunctionTest.java @@ -51,7 +51,7 @@ public final class PlatformMappingFunctionTest extends BuildViewTestCase { private static final Label PLATFORM1 = Label.parseCanonicalUnchecked("//platforms:one"); private static final Label DEFAULT_TARGET_PLATFORM = - Label.parseCanonicalUnchecked("@local_config_platform//:host"); + Label.parseCanonicalUnchecked("@bazel_tools//tools:host_platform"); private BuildOptions defaultBuildOptions; diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingValueTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingValueTest.java index 1a7a49270a1b9b..c493d1e310faca 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingValueTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/config/PlatformMappingValueTest.java @@ -51,7 +51,7 @@ public final class PlatformMappingValueTest { private static final BuildOptions DEFAULT_BUILD_CONFIG_PLATFORM_OPTIONS = BuildOptions.getDefaultBuildOptionsForFragments(BUILD_CONFIG_PLATFORM_OPTIONS); private static final Label DEFAULT_TARGET_PLATFORM = - Label.parseCanonicalUnchecked("@local_config_platform//:host"); + Label.parseCanonicalUnchecked("@bazel_tools//tools:host_platform"); @Test public void testMapNoMappings() throws OptionsParsingException { diff --git a/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java b/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java index 1a1fff686705e9..09ee8d61ec9eee 100644 --- a/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java +++ b/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java @@ -146,8 +146,8 @@ private TestConstants() { */ public static final ImmutableList PRODUCT_SPECIFIC_FLAGS = ImmutableList.of( - "--platforms=@local_config_platform//:host", - "--host_platform=@local_config_platform//:host", + "--platforms=@bazel_tools//tools:host_platform", + "--host_platform=@bazel_tools//tools:host_platform", // TODO(#7849): Remove after flag flip. "--incompatible_use_toolchain_resolution_for_java_rules"); @@ -159,15 +159,13 @@ private TestConstants() { public static final String APPLE_PLATFORM_PATH = "build_bazel_apple_support/platforms"; public static final String APPLE_PLATFORM_PACKAGE_ROOT = "@build_bazel_apple_support//platforms"; public static final String CONSTRAINTS_PACKAGE_ROOT = "@platforms//"; - public static final String LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT = - "@local_config_platform//"; public static final String PLATFORMS_PATH = "embedded_tools/platforms"; public static final String CONSTRAINTS_PATH = "platforms_workspace"; - public static final String LOCAL_CONFIG_PLATFORM_PATH = "local_config_platform_workspace"; - public static final String PLATFORM_LABEL = - LOCAL_CONFIG_PLATFORM_PACKAGE_ROOT + ":host"; + public static final String PLATFORM_LABEL = "@platforms//host"; + public static final String PLATFORM_LABEL_ALIAS = "@bazel_tools//tools:host_platform"; + public static final String PIII_PLATFORM_LABEL = "@platforms//host:piii"; public static final Label ANDROID_DEFAULT_SDK = Label.parseCanonicalUnchecked("@bazel_tools//tools/android:sdk"); diff --git a/src/test/py/bazel/bzlmod/bazel_lockfile_test.py b/src/test/py/bazel/bzlmod/bazel_lockfile_test.py index 21ca3706cc50d5..520289fb15fa88 100644 --- a/src/test/py/bazel/bzlmod/bazel_lockfile_test.py +++ b/src/test/py/bazel/bzlmod/bazel_lockfile_test.py @@ -446,10 +446,9 @@ def testModuleExtensionsInDifferentBuilds(self): with open(self.Path('MODULE.bazel.lock'), 'r') as f: lockfile = json.loads(f.read().strip()) self.assertGreater(len(lockfile['moduleDepGraph']), 0) - self.assertEqual( - list(lockfile['moduleExtensions'].keys()), - ['//:extension.bzl%extA', '//:extension.bzl%extB'], - ) + ext_keys = list(lockfile['moduleExtensions'].keys()) + self.assertIn('//:extension.bzl%extA', ext_keys) + self.assertIn('//:extension.bzl%extB', ext_keys) def testUpdateModuleExtension(self): self.ScratchFile( @@ -590,15 +589,15 @@ def testRemoveModuleExtensionsNotUsed(self): self.RunBazel(['build', '@hello//:all']) with open(self.Path('MODULE.bazel.lock'), 'r') as f: lockfile = json.loads(f.read().strip()) - self.assertEqual( - list(lockfile['moduleExtensions'].keys()), ['//:extension.bzl%ext'] - ) + ext_keys = list(lockfile['moduleExtensions'].keys()) + self.assertIn('//:extension.bzl%ext', ext_keys) self.ScratchFile('MODULE.bazel', []) self.RunBazel(['build', '//:all']) with open(self.Path('MODULE.bazel.lock'), 'r') as f: lockfile = json.loads(f.read().strip()) - self.assertEqual(len(lockfile['moduleExtensions']), 0) + ext_keys = list(lockfile['moduleExtensions'].keys()) + self.assertNotIn('//:extension.bzl%ext', ext_keys) def testNoAbsoluteRootModuleFilePath(self): self.ScratchFile( diff --git a/src/test/shell/bazel/bazel_workspaces_test.sh b/src/test/shell/bazel/bazel_workspaces_test.sh index b600f6a3eb8337..80569299020f62 100755 --- a/src/test/shell/bazel/bazel_workspaces_test.sh +++ b/src/test/shell/bazel/bazel_workspaces_test.sh @@ -38,6 +38,7 @@ genrule( outs=["out.txt"], cmd="echo Result > $(location out.txt)" ) +filegroup(name="noop") EOF cat >> repos.bzl <&1 >> $TEST_log || fail "could not build //:noop" bazel build //:test --experimental_workspace_rules_log_file=output 2>&1 >> $TEST_log || fail "could not build //:test" ${BAZEL_RUNFILES}/src/tools/workspacelog/parser --log_path=output > output.log.txt "$@" || fail "error parsing output" } diff --git a/src/test/shell/bazel/cc_integration_test.sh b/src/test/shell/bazel/cc_integration_test.sh index 791f682ff55ce5..e5e1887d14a904 100755 --- a/src/test/shell/bazel/cc_integration_test.sh +++ b/src/test/shell/bazel/cc_integration_test.sh @@ -902,7 +902,7 @@ EOF BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 bazel build '//:ok' --toolchain_resolution_debug=@bazel_tools//tools/cpp:toolchain_type &>"$TEST_log" && \ fail "Toolchains shouldn't be found" - expect_log "ToolchainResolution: No @@bazel_tools//tools/cpp:toolchain_type toolchain found for target platform @@local_config_platform//:host." + expect_log "ToolchainResolution: No @@bazel_tools//tools/cpp:toolchain_type toolchain found for target platform @@platforms//host:host." } function setup_workspace_layout_with_external_directory() { diff --git a/src/test/shell/bazel/platforms_test.sh b/src/test/shell/bazel/platforms_test.sh index 04145724415b25..cb82db91cf4538 100755 --- a/src/test/shell/bazel/platforms_test.sh +++ b/src/test/shell/bazel/platforms_test.sh @@ -66,6 +66,12 @@ EOF # Have to use a rule that doesn't require a target platform, or else there will # be a cycle. toolchain_type(name = 'yolo') +EOF + mkdir override/host + touch override/host/BUILD + cat > override/host/extension.bzl < $TEST_log || fail "Build failed" expect_log "Performing resolution of //${pkg}/toolchain:test_toolchain for target platform ${default_host_platform}" expect_log "Toolchain //register/${pkg}:test_toolchain_impl_1 is compatible with target platform, searching for execution platforms:" - expect_log "Compatible execution platform ${default_host_platform}" + expect_log "Compatible execution platform ${default_host_platform_alias}" expect_log "Recap of selected //${pkg}/toolchain:test_toolchain toolchains for target platform ${default_host_platform}:" - expect_log "Selected //register/${pkg}:test_toolchain_impl_1 to run on execution platform ${default_host_platform}" + expect_log "Selected //register/${pkg}:test_toolchain_impl_1 to run on execution platform ${default_host_platform_alias}" expect_log "Target platform ${default_host_platform}: Selected execution platform ${default_host_platform}, type //${pkg}/toolchain:test_toolchain -> toolchain //register/${pkg}:test_toolchain_impl_1" expect_log 'Using toolchain: rule message: "this is the rule", toolchain extra_str: "foo from test_toolchain"' } @@ -722,9 +722,9 @@ EOF "//${pkg}/demo:use" &> $TEST_log || fail "Build failed" expect_log "Performing resolution of //${pkg}/toolchain:test_toolchain for target platform ${default_host_platform}" expect_log "Toolchain //register/${pkg}:test_toolchain_impl_1 is compatible with target platform, searching for execution platforms:" - expect_log "Compatible execution platform ${default_host_platform}" + expect_log "Compatible execution platform ${default_host_platform_alias}" expect_log "Recap of selected //${pkg}/toolchain:test_toolchain toolchains for target platform ${default_host_platform}:" - expect_log "Selected //register/${pkg}:test_toolchain_impl_1 to run on execution platform ${default_host_platform}" + expect_log "Selected //register/${pkg}:test_toolchain_impl_1 to run on execution platform ${default_host_platform_alias}" expect_log "ToolchainResolution: Target platform ${default_host_platform}: Selected execution platform ${default_host_platform}, type //${pkg}/toolchain:test_toolchain -> toolchain //register/${pkg}:test_toolchain_impl_1" expect_log 'Using toolchain: rule message: "this is the rule", toolchain extra_str: "foo from test_toolchain"' } diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index c9fe3be52083f8..8a57f2e89f800d 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -92,7 +92,8 @@ distdir_bzl_file="${BAZEL_RUNFILES}/distdir.bzl" tools_dir="$(dirname $(rlocation io_bazel/tools/BUILD))" # Platforms -default_host_platform="@@local_config_platform//:host" +default_host_platform="@@platforms//host:host" +default_host_platform_alias="@@bazel_tools//tools:host_platform" # Sandbox tools process_wrapper="${BAZEL_RUNFILES}/src/main/tools/process-wrapper" diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index b43d461d97435e..afb7dbd395b625 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -13,7 +13,7 @@ "compatibilityMode": "ERROR" }, "localOverrideHashes": { - "bazel_tools": "14ba3cf3e7948f93b5ad01aaafb2fedb13690d301267faa7584083cede96b9b9" + "bazel_tools": "7631c24ab20d40e76d3fe317703b2519af9dc7e10edeef7bfe1d362f0495b513" }, "moduleDepGraph": { "": { @@ -191,7 +191,7 @@ "rules_proto": "rules_proto@5.3.0-21.7", "rules_python": "rules_python@0.22.1", "buildozer": "buildozer@6.4.0.2", - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "com_google_protobuf": "protobuf@21.7", "zlib": "zlib@1.3", "build_bazel_apple_support": "apple_support@1.5.0", @@ -207,7 +207,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_" } }, @@ -240,7 +240,7 @@ } ], "deps": { - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -344,7 +344,7 @@ } ], "deps": { - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "rules_cc": "rules_cc@0.0.9", "bazel_skylib": "bazel_skylib@1.3.0", "rules_proto": "rules_proto@5.3.0-21.7", @@ -506,7 +506,7 @@ } ], "deps": { - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "bazel_skylib": "bazel_skylib@1.3.0", "rules_proto": "rules_proto@5.3.0-21.7", "com_google_protobuf": "protobuf@21.7", @@ -595,14 +595,32 @@ } } }, - "platforms@0.0.7": { + "platforms@0.0.9": { "name": "platforms", - "version": "0.0.7", - "key": "platforms@0.0.7", + "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@_", @@ -613,9 +631,9 @@ "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz" + "https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz" ], - "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=", + "integrity": "sha256-XtpTnIQSZQMcL4LYrno6ZJC9YhduDAOPxGnqv5H2FJs=", "strip_prefix": "", "remote_patches": {}, "remote_patch_strip": 0 @@ -715,7 +733,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "rules_cc": "rules_cc@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -768,7 +786,7 @@ ], "deps": { "bazel_skylib": "bazel_skylib@1.3.0", - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -798,7 +816,7 @@ ], "extensionUsages": [], "deps": { - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -857,7 +875,7 @@ "extensionUsages": [], "deps": { "rules_cc": "rules_cc@0.0.9", - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -890,7 +908,7 @@ "rules_proto": "rules_proto@5.3.0-21.7", "com_google_protobuf": "protobuf@21.7", "com_google_absl": "abseil-cpp@20211102.0", - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -1004,7 +1022,7 @@ "extensionUsages": [], "deps": { "com_google_absl": "abseil-cpp@20211102.0", - "platforms": "platforms@0.0.7", + "platforms": "platforms@0.0.9", "rules_cc": "rules_cc@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -1243,6 +1261,23 @@ "recordedRepoMappingEntries": [] } }, + "@@platforms//host:extension.bzl%host_platform": { + "general": { + "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", + "usagesDigest": "n09YBuQPPWD2ruteuyEi0J/rtBYGRWuaq/aBOPdseDE=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "host_platform": { + "bzlFile": "@@platforms//host:extension.bzl", + "ruleClassName": "host_platform_repo", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [] + } + }, "@@rules_java~//java:extensions.bzl%toolchains": { "general": { "bzlTransitiveDigest": "Q1jn8wFEVBEfiV1W71qDFOM2MzdJMZuk83csUrBnhvM=", diff --git a/tools/BUILD b/tools/BUILD index 53e20c309442d7..4ab65d45550cb6 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -91,3 +91,8 @@ sh_binary( name = "upload_bazel_mirror", srcs = ["upload_bazel_mirror.sh"], ) + +alias( + name = "host_platform", + actual = "@platforms//host", +) diff --git a/tools/android/android_sdk_repository_template.bzl b/tools/android/android_sdk_repository_template.bzl index 04c073000c784c..66ddff1b5b891a 100644 --- a/tools/android/android_sdk_repository_template.bzl +++ b/tools/android/android_sdk_repository_template.bzl @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS") +load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS") load("@rules_java//java:defs.bzl", "java_binary", "java_import") def _bool_flag_impl(_unused_ctx):