-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to rules_apple 3.0.0 #759
Conversation
rules/framework.bzl
Outdated
@@ -25,6 +25,7 @@ load("@build_bazel_rules_apple//apple/internal:apple_toolchains.bzl", "AppleMacT | |||
load("@build_bazel_rules_apple//apple/internal:swift_support.bzl", "swift_support") | |||
load("@build_bazel_rules_apple//apple/internal/utils:clang_rt_dylibs.bzl", "clang_rt_dylibs") | |||
load("@build_bazel_rules_apple//apple:providers.bzl", "AppleBundleInfo", "IosFrameworkBundleInfo") | |||
load("@build_bazel_rules_apple//apple/internal:providers.bzl", "new_applebundleinfo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to rely on yet another internal provider from rules_apple here? It seems like it would continue to work well on 5.x.x pretty easily w/o the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the issue with this line is everyone will have to run a commit later than:
bazelbuild/rules_apple#2194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's incompatible because the initializer intentionally fails here in _make_banned_init
:
AppleBundleInfo, new_applebundleinfo = provider(
doc = ...,
fields = {
...
},
init = _make_banned_init(provider_name = "AppleBundleInfo"),
)
Keeping rules_ios
close to the head of rules_apple
was intentional with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah what I'm wondering, is how to make it work backwards with older versions:
e.g.
# in rules_ios/framework.bzl or util module
def _wrapped_bundule_init(**kwargs):
if old_version:
return AppleBundleInfo(kwargs)
else:
return new_applebundleinfo(kwargs)
Though the initializer moving to a private API which used to be public is another story 😮💨
if (arch == "armv7s" or arch == "arm64e"): | ||
# unsupported platform-arch by rules_apple | ||
# unsupported platform-arch by rules_apple | ||
unsupported_platforms = ["armv7", "armv7s", "i386"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping arm64e
was intentional here since it exists in rules_apple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this works on 2.5?
9009b1a
to
7e1d2aa
Compare
305a4f7
to
fb044b7
Compare
7e1d2aa
to
771a0cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to review this update and see what it takes to support older versions.
Use new provider initialization pattern, use new apple_platform_split_transition, drop support for i386 slices in xcframeworks, passthrough minimum_os_version to all test rules.
771a0cb
to
3b4e5ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like with few quick changes there isn't a reason it wouldn't support 2.5.x by making some of these conditional. Likely this can be done with wrappers to further centralize the calling of rules_apple APIs here
if (arch == "armv7s" or arch == "arm64e"): | ||
# unsupported platform-arch by rules_apple | ||
# unsupported platform-arch by rules_apple | ||
unsupported_platforms = ["armv7", "armv7s", "i386"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this works on 2.5?
@@ -664,8 +675,11 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps): | |||
resource_deps = ctx.attr.deps + ctx.attr.transitive_deps + ctx.attr.data | |||
current_apple_platform = transition_support.current_apple_platform(apple_fragment = ctx.fragments.apple, xcode_config = ctx.attr._xcode_config) | |||
platform_type = str(current_apple_platform.platform.platform_type) | |||
rule_descriptor = rule_support.rule_descriptor_no_ctx(platform_type, apple_product_type.framework) | |||
platform_prerequisites = _platform_prerequisites(ctx, rule_descriptor, platform_type) | |||
rule_descriptor = rule_support.rule_descriptor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way to plumb in the rule_descriptor
from above?
@@ -694,6 +708,7 @@ def _bundle_dynamic_framework(ctx, is_extension_safe, avoid_deps): | |||
ctx, | |||
avoid_deps = avoid_deps, | |||
entitlements = None, | |||
exported_symbols_lists = ctx.files.exported_symbols_lists, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# If this isn't backwards compatible with 2.5.0
if rules_apple_api_version_3:
kwargs["exported_symbols_lists"] = ctx.files.exported_symbols_lists
else:
kwargs[" executable_name"] = bundle_name
@@ -1053,23 +1073,23 @@ apple_framework_packaging = rule( | |||
), | |||
"deps": attr.label_list( | |||
mandatory = True, | |||
cfg = apple_common.multi_arch_split, | |||
cfg = rules_apple_transition_support.apple_rule_transition, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible to add conditional assignment at the top of framework.bzl
or in some other file? e.g. :
if rules_apple_api_version_3:
apple_dep_transition = rules_apple_transition_support.apple_rule_transition
else:
apple_dep_transition = apple_common.multi_arch_split
Then - consuming it here:
cfg = apple_dep_transition
@@ -52,6 +53,7 @@ def _precompiled_apple_resource_bundle_impl(ctx): | |||
|
|||
platform_prerequisites = platform_support.platform_prerequisites( | |||
apple_fragment = ctx.fragments.apple, | |||
build_settings = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May or many not need fixing if it passes CI with 2.5 / LTS enabled
@@ -19,7 +19,7 @@ | |||
"""iOS test runner rule.""" | |||
|
|||
load( | |||
"@build_bazel_rules_apple//apple/testing:apple_test_rules.bzl", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need other way to load it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you conditionalize load statements? I didn't think so but maybe I'm wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure - we can unify the sims in a starlark file we load in “rules ios dependencies” - based on the api version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shims*
@jszumski last night I pulled this down and looked at at bit. It seems like there are 2 distinct issues here:
|
Submitting and end to end implementation of this. |
Changes
Uses new provider initialization pattern
This is now private API in rules_apple as of Move to new provider API initialization pattern bazelbuild/rules_apple#2184 but visibility was relaxed in Remove bzl visibility for now bazelbuild/rules_apple#2225 to avoid breaking us.
Drops support for i386 slices in xcframeworks
Dropped upstream in Removing any support for Xcode prior to 14 from the rules. bazelbuild/rules_apple#2155.
Passes through
minimum_os_version
to all test rulesRequired upstream in Require minimum_os_version bazelbuild/rules_apple#2124.
Uses new split transition
Core's
apple_common.multi_arch_split
was removed in Bazel 7 and replaced by rules_apple'sapple_platform_split_transition
: Replace apple_common.multi_arch_split with new transition bazelbuild/rules_apple#2034Remaining work
Update project generation rules