diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh index 8a52f141cbdf51..90782f93e33414 100755 --- a/scripts/bootstrap/compile.sh +++ b/scripts/bootstrap/compile.sh @@ -273,9 +273,6 @@ EOF # Set up @bazel_tools//platforms properly mkdir -p ${BAZEL_TOOLS_REPO}/platforms cp tools/platforms/BUILD.tools ${BAZEL_TOOLS_REPO}/platforms/BUILD - link_file \ - "${PWD}/tools/platforms/fail_with_incompatible_use_platforms_repo_for_constraints.bzl" \ - "${BAZEL_TOOLS_REPO}/platforms/fail_with_incompatible_use_platforms_repo_for_constraints.bzl" # Overwrite tools.WORKSPACE, this is only for the bootstrap binary chmod u+w "${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE" diff --git a/site/docs/platforms.md b/site/docs/platforms.md index 777a6eb978367f..4c3079e2b59e52 100644 --- a/site/docs/platforms.md +++ b/site/docs/platforms.md @@ -88,36 +88,35 @@ glibc version of 2.25. (See below for more on Bazel's built-in constraints.) platform( name = "linux_x86", constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:x86_64", ":glibc_2_25", ], ) ``` Note that it is an error for a platform to specify more than one value of the -same constraint setting, such as `@platforms//cpu:x86_64` and -`@platforms//cpu:arm` for `@platforms//cpu:cpu`. +same constraint setting, such as `@bazel_tools//platforms:x86_64` and +`@bazel_tools//platforms:arm` for `@bazel_tools//platforms:cpu`. ## Built-in constraints and platforms Bazel ships with constraint definitions for the most popular CPU architectures -and operating systems. These are all located in the repository -`@platforms`. This repository is developed at -[github.com/bazelbuild/platforms](https://github.com/bazelbuild/platforms): +and operating systems. These are all located in the package +`@bazel_tools//platforms`: -* `//cpu:cpu` for the CPU architecture, with values `//cpu:x86_32`, - `//cpu:x86_64`, `//cpu:ppc`, `//cpu:arm`, `//cpu:s390x` -* `//os:os` for the operating system, with values `//os:android`, - `//os:freebsd`, `//os:ios`, `//os:linux`, `//os:osx`, `//os:windows` +* `:cpu` for the CPU architecture, with values `:x86_32`, `:x86_64`, `:ppc`, + `:arm`, `:s390x` +* `:os` for the operating system, with values `:android`, `:freebsd`, `:ios`, + `:linux`, `:osx`, `:windows` There are also the following special platform definitions: -* `@bazel_tools//platforms:host_platform` - represents the CPU and operating - system for the host environment +* `:host_platform` - represents the CPU and operating system for the host + environment -* `@bazel_tools//platforms:target_platform` - represents the CPU and operating - system for the target environment +* `:target_platform` - represents the CPU and operating system for the target + environment The CPU values used by these two platforms can be specified with the `--host_cpu` and `--cpu` flags. diff --git a/site/docs/toolchains.md b/site/docs/toolchains.md index 747af158947de6..998f623ba96b84 100644 --- a/site/docs/toolchains.md +++ b/site/docs/toolchains.md @@ -104,14 +104,14 @@ We can improve on this solution by using `select` to choose the `compiler` config_setting( name = "on_linux", constraint_values = [ - "@platforms//os:linux", + "@bazel_tools//platforms:linux", ], ) config_setting( name = "on_windows", constraint_values = [ - "@platforms//os:windows", + "@bazel_tools//platforms:windows", ], ) @@ -276,12 +276,12 @@ appropriate for a given platform. toolchain( name = "barc_linux_toolchain", exec_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:x86_64", ], target_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:x86_64", ], toolchain = ":barc_linux", toolchain_type = ":toolchain_type", @@ -290,12 +290,12 @@ toolchain( toolchain( name = "barc_windows_toolchain", exec_compatible_with = [ - "@platforms//os:windows", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:windows", + "@bazel_tools//platforms:x86_64", ], target_compatible_with = [ - "@platforms//os:windows", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:windows", + "@bazel_tools//platforms:x86_64", ], toolchain = ":barc_windows", toolchain_type = ":toolchain_type", @@ -336,7 +336,7 @@ toolchain will be selected based on the target and execution platforms. platform( name = "my_target_platform", constraint_values = [ - "@platforms//os:linux", + "@bazel_tools//platforms:linux", ], ) @@ -351,7 +351,7 @@ bazel build //my_pkg:my_bar_binary --platforms=//my_pkg:my_target_platform ``` Bazel will see that `//my_pkg:my_bar_binary` is being built with a platform that -has `@platforms//os:linux` and therefore resolve the +has `@bazel_tools//platforms:linux` and therefore resolve the `//bar_tools:toolchain_type` reference to `//bar_tools:barc_linux_toolchain`. This will end up building `//bar_tools:barc_linux` but not `//barc_tools:barc_windows`. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java index 61b9d947bdd1ec..c03f9ed49555e3 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java @@ -68,18 +68,6 @@ public class CoreOptions extends FragmentOptions implements Cloneable { help = "If true, the genfiles directory is folded into the bin directory.") public boolean mergeGenfilesDirectory; - @Option( - name = "incompatible_use_platforms_repo_for_constraints", - defaultValue = "false", - documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, - effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, - metadataTags = { - OptionMetadataTag.INCOMPATIBLE_CHANGE, - OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES - }, - help = "If true, constraint settings from @bazel_tools are removed.") - public boolean usePlatformsRepoForConstraints; - @Option( name = "define", converter = Converters.AssignmentConverter.class, 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 35379910d63f31..1209c5d3fc94f2 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 @@ -81,17 +81,17 @@ public RepositoryDirectoryValue.Builder fetch( static String cpuToConstraint(CPU cpu) { switch (cpu) { case X86_32: - return "@platforms//cpu:x86_32"; + return "@bazel_tools//platforms:x86_32"; case X86_64: - return "@platforms//cpu:x86_64"; + return "@bazel_tools//platforms:x86_64"; case PPC: - return "@platforms//cpu:ppc"; + return "@bazel_tools//platforms:ppc"; case ARM: - return "@platforms//cpu:arm"; + return "@bazel_tools//platforms:arm"; case AARCH64: - return "@platforms//cpu:aarch64"; + return "@bazel_tools//platforms:aarch64"; case S390X: - return "@platforms//cpu:s390x"; + return "@bazel_tools//platforms:s390x"; default: // Unknown, so skip it. return null; @@ -102,13 +102,13 @@ static String cpuToConstraint(CPU cpu) { static String osToConstraint(OS os) { switch (os) { case DARWIN: - return "@platforms//os:osx"; + return "@bazel_tools//platforms:osx"; case FREEBSD: - return "@platforms//os:freebsd"; + return "@bazel_tools//platforms:freebsd"; case LINUX: - return "@platforms//os:linux"; + return "@bazel_tools//platforms:linux"; case WINDOWS: - return "@platforms//os:windows"; + return "@bazel_tools//platforms:windows"; default: // Unknown, so skip it. return null; diff --git a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java index 25aedb6e0a203f..7522324fc94949 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java @@ -327,7 +327,7 @@ Matches an expected configuration state (expressed as Bazel flags or platform co config_setting( name = "64bit_glibc_2_25", constraint_values = [ - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:x86_64", "//example:glibc_2_25", ] ) diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java index e9416be459cc6e..511619a1b6fcab 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java @@ -67,7 +67,7 @@ public RuleDefinition.Metadata getMetadata() {

Each constraint_setting has an extensible set of associated constraint_values. Usually these are defined in the same package, but sometimes a different package will introduce new values for an existing setting. For instance, the predefined -setting @platforms//cpu:cpu can be extended with a custom value in order to +setting @bazel_tools//platforms:cpu can be extended with a custom value in order to define a platform targeting an obscure cpu architecture. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java index 2ca844a86277e6..43ccf342c7401b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java @@ -67,7 +67,7 @@ public Metadata getMetadata() {

 constraint_value(
     name = "mips",
-    constraint_setting = "@platforms//cpu:cpu",
+    constraint_setting = "@bazel_tools//platforms:cpu",
 )
 
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 bafdb7b0e7e9b4..c54d05a0aeccf1 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 @@ -49,7 +49,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 + cpu architecture to be both @bazel_tools//platforms:x86_64 and @bazel_tools//platforms:arm. */ .add( @@ -130,8 +130,8 @@ public Metadata getMetadata() { platform( name = "linux_arm", constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:arm", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:arm", ], ) @@ -177,8 +177,8 @@ public Metadata getMetadata() { platform( name = "parent", constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:arm", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:arm", ], remote_execution_properties = """ parent properties @@ -188,7 +188,7 @@ public Metadata getMetadata() { name = "child_a", parents = [":parent"], constraint_values = [ - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:x86_64", ], remote_execution_properties = """ child a properties @@ -210,8 +210,8 @@ public Metadata getMetadata() {