Skip to content

Commit

Permalink
Add --incompatible_disable_native_apple_binary_rule flag to disable…
Browse files Browse the repository at this point in the history
… the native `apple_binary` rule.

When enabled, an error message directs users to use the Starlark version of the rule from rules_apple instead.

RELNOTES: The `--incompatible_disable_native_apple_binary_rule` flag has been added which disables the native `apple_binary` rule. Users who need to use `apple_binary` directly (if they cannot use one of the more specific Apple rules) should load it from https://github.com/bazelbuild/rules_apple.
PiperOrigin-RevId: 345260363
  • Loading branch information
allevato authored and copybara-github committed Dec 2, 2020
1 parent 03350fa commit 65e9732
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ static Iterable<String> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -102,6 +103,7 @@ public ObjcConfiguration(BuildOptions buildOptions) {
this.shouldScanIncludes = objcOptions.scanIncludes;
this.avoidHardcodedCompilationFlags =
objcOptions.incompatibleAvoidHardcodedObjcCompilationFlags;
this.disableNativeAppleBinaryRule = objcOptions.incompatibleDisableNativeAppleBinaryRule;
}

/**
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 65e9732

Please sign in to comment.