diff --git a/src/test/shell/integration/java_integration_test.sh b/src/test/shell/integration/java_integration_test.sh index a61ff4c4743f6e..5e01bc99585da0 100755 --- a/src/test/shell/integration/java_integration_test.sh +++ b/src/test/shell/integration/java_integration_test.sh @@ -272,12 +272,13 @@ constraint_value( toolchain( name = 'java_runtime_toolchain', toolchain = ':runtime', - toolchain_type = '//tools/jdk:runtime_toolchain_type', + toolchain_type = '@bazel_tools//tools/jdk:runtime_toolchain_type', target_compatible_with = [':constraint'], ) platform( name = 'platform', - constraint_values = [":constraint"], + parents = ['@bazel_tools//platforms:host_platform'], + constraint_values = [':constraint'], ) EOF else @@ -294,11 +295,10 @@ toolchain( ) platform( name = 'platform', + parents = ['//buildenv/platforms:host_platform'], constraint_values = [ - ":constraint", - "//buildenv/platforms/java/constraints:java8", - "//buildenv/platforms:linux", - "//buildenv/platforms:x86_64", + ':constraint', + '//buildenv/platforms/java/constraints:java8', ], ) EOF diff --git a/tools/cpp/BUILD.tpl b/tools/cpp/BUILD.tpl index febd47ffd618a5..d32f3e1fa8427a 100644 --- a/tools/cpp/BUILD.tpl +++ b/tools/cpp/BUILD.tpl @@ -17,6 +17,7 @@ package(default_visibility = ["//visibility:public"]) load(":cc_toolchain_config.bzl", "cc_toolchain_config") +load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS") licenses(["notice"]) # Apache 2.0 @@ -75,12 +76,8 @@ cc_toolchain_config( toolchain( name = "cc-toolchain-%{name}", - exec_compatible_with = [ - # TODO(katre): add autodiscovered constraints for host CPU and OS. - ], - target_compatible_with = [ - # TODO(katre): add autodiscovered constraints for host CPU and OS. - ], + exec_compatible_with = HOST_CONSTRAINTS, + target_compatible_with = HOST_CONSTRAINTS, toolchain = ":cc-compiler-%{name}", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) @@ -109,9 +106,7 @@ cc_toolchain_config( toolchain( name = "cc-toolchain-armeabi-v7a", - exec_compatible_with = [ - # TODO(katre): add autodiscovered constraints for host CPU and OS. - ], + exec_compatible_with = HOST_CONSTRAINTS, target_compatible_with = [ "@bazel_tools//platforms:arm", "@bazel_tools//platforms:android", diff --git a/tools/osx/crosstool/BUILD.tpl b/tools/osx/crosstool/BUILD.tpl index 6f49c97cec865e..2ef62b9a37b817 100644 --- a/tools/osx/crosstool/BUILD.tpl +++ b/tools/osx/crosstool/BUILD.tpl @@ -1,6 +1,6 @@ package(default_visibility = ["//visibility:public"]) -load(":osx_archs.bzl", "OSX_TOOLS_ARCHS") +load(":osx_archs.bzl", "OSX_TOOLS_ARCHS", "OSX_TOOLS_CONSTRAINTS") load(":cc_toolchain_config.bzl", "cc_toolchain_config") CC_TOOLCHAINS = [( @@ -10,10 +10,10 @@ CC_TOOLCHAINS = [( cpu, ":cc-compiler-" + cpu, ) for cpu in OSX_TOOLS_ARCHS] + [ - ("k8|compiler", ":cc-compiler-darwin_x86_64", ), - ("darwin|compiler", ":cc-compiler-darwin_x86_64", ), - ("k8", ":cc-compiler-darwin_x86_64", ), - ("darwin", ":cc-compiler-darwin_x86_64", ), + ("k8|compiler", ":cc-compiler-darwin_x86_64"), + ("darwin|compiler", ":cc-compiler-darwin_x86_64"), + ("k8", ":cc-compiler-darwin_x86_64"), + ("darwin", ":cc-compiler-darwin_x86_64"), ] cc_library( @@ -39,13 +39,13 @@ cc_toolchain_suite( filegroup( name = "osx_tools_" + arch, srcs = [ - ":cc_wrapper", - ":libtool", - ":make_hashed_objlist.py", - ":wrapped_clang", - ":wrapped_clang_pp", - ":wrapped_ar", - ":xcrunwrapper.sh", + ":cc_wrapper", + ":libtool", + ":make_hashed_objlist.py", + ":wrapped_ar", + ":wrapped_clang", + ":wrapped_clang_pp", + ":xcrunwrapper.sh", ], ) for arch in OSX_TOOLS_ARCHS @@ -54,12 +54,6 @@ cc_toolchain_suite( [ apple_cc_toolchain( name = "cc-compiler-" + arch, - toolchain_identifier = ( - arch if arch != "armeabi-v7a" else "stub_armeabi-v7a" - ), - toolchain_config = ":" + ( - arch if arch != "armeabi-v7a" else "stub_armeabi-v7a" - ), all_files = ":osx_tools_" + arch, ar_files = ":empty", as_files = ":empty", @@ -69,6 +63,12 @@ cc_toolchain_suite( objcopy_files = ":empty", strip_files = ":osx_tools_" + arch, supports_param_files = 0, + toolchain_config = ":" + ( + arch if arch != "armeabi-v7a" else "stub_armeabi-v7a" + ), + toolchain_identifier = ( + arch if arch != "armeabi-v7a" else "stub_armeabi-v7a" + ), ) for arch in OSX_TOOLS_ARCHS ] @@ -76,8 +76,8 @@ cc_toolchain_suite( [ cc_toolchain_config( name = (arch if arch != "armeabi-v7a" else "stub_armeabi-v7a"), - cpu = arch, compiler = "compiler", + cpu = arch, ) for arch in OSX_TOOLS_ARCHS ] @@ -86,11 +86,11 @@ cc_toolchain_suite( toolchain( name = "cc-toolchain-" + arch, exec_compatible_with = [ - # TODO(katre): add autodiscovered constraints for host CPU and OS. - ], - target_compatible_with = [ - # TODO(katre): add autodiscovered constraints for host CPU and OS. + # These only execute on macOS. + "@bazel_tools//platforms:osx", + "@bazel_tools//platforms:x86_64", ], + target_compatible_with = OSX_TOOLS_CONSTRAINTS[arch], toolchain = ":cc-compiler-" + arch, toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) diff --git a/tools/osx/crosstool/osx_archs.bzl b/tools/osx/crosstool/osx_archs.bzl index 56a0e62cf5af38..4f6bdc03dc199d 100644 --- a/tools/osx/crosstool/osx_archs.bzl +++ b/tools/osx/crosstool/osx_archs.bzl @@ -32,3 +32,22 @@ OSX_TOOLS_ARCHS = [ "watchos_arm64_32", "tvos_arm64", ] + OSX_TOOLS_NON_DEVICE_ARCHS + +# Target constraints for each arch. +# TODO(apple-rules): Rename osx constraint to macOS. +# TODO(apple-rules): Add constraints for watchos and tvos. +OSX_TOOLS_CONSTRAINTS = { + "darwin_x86_64": ["@bazel_tools//platforms:osx", "@bazel_tools//platforms:x86_64"], + "ios_i386": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:x86_32"], + "ios_x86_64": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:x86_64"], + "watchos_i386": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:x86_32"], + "watchos_x86_64": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:x86_64"], + "tvos_x86_64": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:x86_64"], + "armeabi-v7a": ["@bazel_tools//platforms:arm"], + "ios_armv7": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:arm"], + "ios_arm64": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:arm"], + "ios_arm64e": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:arm"], + "watchos_armv7k": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:arm"], + "watchos_arm64_32": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:arm"], + "tvos_arm64": ["@bazel_tools//platforms:ios", "@bazel_tools//platforms:arm"], +}