-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Motivation
Part of Starlarkifying native Bazel flags: move language-specific flags out of the Bazel binary and into the rule set's .bzl definitions. This gives rules owners (in this case, primarily rules_apple) more ownership over their logic and decouples the flag definitions from Bazel releases.
This Starlarkifies flags previously defined in ObjcCommandLineOptions.java.
This removes ctx.fragments.objc.
Description
When flipped, this flag causes Bazel to no longer provide the native objc fragment. ctx.fragments.objc will no longer exist.
A new rules_apple release (and potentially other rules dealing with Objective-C) will use the absence of this fragment as a signal to read all equivalent flag values from Starlark-defined build settings.
This is intended to be a user no-op for most Objective-C builds. However, there are some differences meriting an incompatible flag:
- Setting Starlark flags requires an equals sign:
$ bazel build //foo --//my:flag=valuemust be used instead of$ bazel build //foo --//my:flag value. Since we will be aliasing the old native flags to the new Starlark flags, this means users must use the--flag=valuesyntax for the affected ObjC flags. - Your repository must load the necessary rules (
rules_appleor others) for the ObjC Starlark flags to be defined and resolved. This should generally already be true for Objective-C builds. - If you have custom .bzl code or aspects that read from
ctx.fragments.objc, this will break. You need to update your code to read the equivalent Starlark build settings. Please comment on this issue if you need guidance.
This change only affects Bazel 10+ (or whatever version this flag is enabled in). Older Bazel versions will continue to work.
Incompatible Flag
--incompatible_remove_ctx_objc_fragment
Migration Guide
- If using Bazel 10.0+: Update to a recent
rules_appleversion that supports Starlark-based flags for ObjC. Release information for the requiredrules_appleversion is TBD. Ensure all invocations of former native ObjC flags use the--flag=valuesyntax. - If using Bazel <10.0: No action is needed.
In which Bazel LTS version will this incompatible change be enabled?
Targeting Bazel 10 (or possibly earlier patch into 9).
TODO List
- Prepare and release the version of
rules_applethat reads from Starlark settings whenctx.fragments.objcis not present. - Add flag aliases to
rules_apple/MODULE.bazelto map old native flag names to the new Starlark settings. - Flip the flag default to true in Bazel.
- Eventually, remove the native ObjC fragment and options class from the Bazel binary.