diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java index b5f26f5b82f100..4691a39dc0e502 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java @@ -118,6 +118,14 @@ static Iterable getValues() { @Override public final ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException, ActionConflictException { + ObjcConfiguration objcConfig = + ruleContext.getConfiguration().getFragment(ObjcConfiguration.class); + if (objcConfig.disableNativeAppleBinaryRule()) { + ruleContext.throwWithRuleError( + "The native apple_binary rule is deprecated and will be deleted. Please use the Starlark" + + " rule from https://github.com/bazelbuild/rules_apple."); + } + AppleBinaryOutput appleBinaryOutput = linkMultiArchBinary( ruleContext, diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java index 6d3fe727c52c9e..7d76a41e4e8522 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java @@ -255,4 +255,20 @@ public class ObjcCommandLineOptions extends FragmentOptions { "Prevents Bazel from adding compiler options to Objective-C compilation actions. Options" + " set in the crosstool are still applied.") public boolean incompatibleAvoidHardcodedObjcCompilationFlags; + + @Option( + name = "incompatible_disable_native_apple_binary_rule", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.INPUT_STRICTNESS, + effectTags = { + OptionEffectTag.EAGERNESS_TO_EXIT, + }, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, + help = + "If enabled, direct usage of the native apple_binary rule is disabled. Please use the" + + " Starlark rule from https://github.com/bazelbuild/rules_apple instead.") + public boolean incompatibleDisableNativeAppleBinaryRule; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java index 1b71bdd2551234..f363d691dde7ef 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java @@ -69,6 +69,7 @@ public class ObjcConfiguration extends Fragment implements ObjcConfigurationApi< private final HeaderDiscovery.DotdPruningMode dotdPruningPlan; private final boolean shouldScanIncludes; private final boolean avoidHardcodedCompilationFlags; + private final boolean disableNativeAppleBinaryRule; public ObjcConfiguration(BuildOptions buildOptions) { CoreOptions options = buildOptions.get(CoreOptions.class); @@ -102,6 +103,7 @@ public ObjcConfiguration(BuildOptions buildOptions) { this.shouldScanIncludes = objcOptions.scanIncludes; this.avoidHardcodedCompilationFlags = objcOptions.incompatibleAvoidHardcodedObjcCompilationFlags; + this.disableNativeAppleBinaryRule = objcOptions.incompatibleDisableNativeAppleBinaryRule; } /** @@ -260,4 +262,9 @@ public HeaderDiscovery.DotdPruningMode getDotdPruningPlan() { public boolean shouldScanIncludes() { return shouldScanIncludes; } + + /** Returns true iff the native {@code apple_binary} rule should be disabled. */ + public boolean disableNativeAppleBinaryRule() { + return disableNativeAppleBinaryRule; + } }