diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt index d622f0c9626280..6e6c5c95925233 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt @@ -29,8 +29,8 @@ cc_toolchain_config( toolchain( name = "%toolchainName%_toolchain", target_compatible_with = [ - "@bazel_tools//platforms:android", - "@bazel_tools//platforms:%platform_cpu%", + "@platforms//os:android", + "@platforms//cpu:%platform_cpu%", ], toolchain = "@androidndk//:%toolchainName%", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java index 370a976825b491..2f6902e44cb820 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java @@ -51,7 +51,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
Each constraint_value
in this list must be for a different
constraint_setting
. For example, you cannot define a platform that requires the
cpu architecture to be both @platforms//cpu:x86_64
and
- @bazel_tools//platforms:arm
.
+ @platforms//cpu:arm
.
*/
.add(
attr(CONSTRAINT_VALUES_ATTR, BuildType.LABEL_LIST)
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 8c6ce70986da62..74d39e725ad4c7 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
@@ -23,12 +23,28 @@ public class MockPlatformSupport {
/** Adds mocks for basic host and target platform. */
public static void setup(MockToolsConfig mockToolsConfig) throws IOException {
+ setup(
+ mockToolsConfig,
+ TestConstants.PLATFORM_PACKAGE_ROOT,
+ TestConstants.PLATFORMS_PATH,
+ TestConstants.CONSTRAINTS_PACKAGE_ROOT,
+ TestConstants.CONSTRAINTS_PATH);
+ }
+
+ /** Adds mocks for basic host and target platform. */
+ public static void setup(
+ MockToolsConfig mockToolsConfig,
+ String platformPackageRoot,
+ String platformsPath,
+ String constraintsPackageRoot,
+ String constraintsPath)
+ throws IOException {
mockToolsConfig.create(
- TestConstants.CONSTRAINTS_PATH + "/BUILD",
+ constraintsPath + "/BUILD",
"package(default_visibility=['//visibility:public'])",
"licenses(['notice'])");
mockToolsConfig.create(
- TestConstants.CONSTRAINTS_PATH + "/cpu/BUILD",
+ constraintsPath + "/cpu/BUILD",
"package(default_visibility=['//visibility:public'])",
"licenses(['notice'])",
"constraint_setting(name = 'cpu')",
@@ -57,7 +73,7 @@ public static void setup(MockToolsConfig mockToolsConfig) throws IOException {
" constraint_setting = ':cpu',",
")");
mockToolsConfig.create(
- TestConstants.CONSTRAINTS_PATH + "/os/BUILD",
+ constraintsPath + "/os/BUILD",
"package(default_visibility=['//visibility:public'])",
"licenses(['notice'])",
"constraint_setting(name = 'os')",
@@ -90,32 +106,30 @@ public static void setup(MockToolsConfig mockToolsConfig) throws IOException {
" constraint_setting = ':os',",
")");
mockToolsConfig.create(
- TestConstants.PLATFORMS_PATH + "/BUILD",
+ platformsPath + "/BUILD",
"package(default_visibility=['//visibility:public'])",
- "constraint_setting(name = 'os')",
- "constraint_value(name = 'android', constraint_setting = ':os')",
"platform(",
" name = 'default_target',",
" constraint_values = [",
// Regardless of the actual machine the tests are run on, hardcode everything to a single
// default value for simplicity.
- " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:x86_64',",
- " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:linux',",
- " '" + TestConstants.PLATFORM_PACKAGE_ROOT + "/java/constraints:jdk11',",
- " '" + TestConstants.PLATFORM_PACKAGE_ROOT + "/java/constraints:java8',",
+ " '" + constraintsPackageRoot + "cpu:x86_64',",
+ " '" + constraintsPackageRoot + "os:linux',",
+ " '" + platformPackageRoot + "/java/constraints:jdk11',",
+ " '" + platformPackageRoot + "/java/constraints:java8',",
" ],",
")",
"platform(",
" name = 'default_host',",
" constraint_values = [",
- " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:x86_64',",
- " '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:linux',",
- " '" + TestConstants.PLATFORM_PACKAGE_ROOT + "/java/constraints:jdk11',",
- " '" + TestConstants.PLATFORM_PACKAGE_ROOT + "/java/constraints:java8',",
+ " '" + constraintsPackageRoot + "cpu:x86_64',",
+ " '" + constraintsPackageRoot + "os:linux',",
+ " '" + platformPackageRoot + "/java/constraints:jdk11',",
+ " '" + platformPackageRoot + "/java/constraints:java8',",
" ],",
")");
mockToolsConfig.create(
- TestConstants.PLATFORMS_PATH + "/java/constraints/BUILD",
+ platformsPath + "/java/constraints/BUILD",
"package(default_visibility = ['//visibility:public'])",
"constraint_setting(name = 'runtime')",
"constraint_value(",
diff --git a/tools/android/android_sdk_repository_template.bzl b/tools/android/android_sdk_repository_template.bzl
index 5fb1da30579728..3eb23a09aa67c9 100644
--- a/tools/android/android_sdk_repository_template.bzl
+++ b/tools/android/android_sdk_repository_template.bzl
@@ -165,7 +165,7 @@ def create_android_sdk_rules(
toolchain_type = "@bazel_tools//tools/android:sdk_toolchain_type",
exec_compatible_with = HOST_CONSTRAINTS,
target_compatible_with = [
- "@bazel_tools//platforms:android",
+ "@platforms//os:android",
],
toolchain = ":sdk-%d" % api_level,
)