Skip to content

Commit

Permalink
Add implementation_deps to _FRAMEWORK_PROVIDERS_ASPECT_ATTRS
Browse files Browse the repository at this point in the history
This allows the various framework rules to work correctly with the new-ish `implementation_deps` attribute of `objc_library`.

Signed-off-by: Brentley Jones <github@brentleyjones.com>
  • Loading branch information
brentleyjones committed Aug 1, 2024
1 parent dba22b7 commit 02b0b7f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
9 changes: 8 additions & 1 deletion apple/internal/aspects/framework_provider_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ load(
# these are supported by `objc_library` for frameworks that should be present in the bundle, but not
# linked against.
# TODO(b/120205406): Remove `runtime_deps` support to use objc_library/swift_library `data` instead.
_FRAMEWORK_PROVIDERS_ASPECT_ATTRS = ["deps", "frameworks", "private_deps", "runtime_deps", "data"]
_FRAMEWORK_PROVIDERS_ASPECT_ATTRS = [
"data",
"deps",
"frameworks",
"implementation_deps",
"private_deps",
"runtime_deps",
]

def _framework_provider_aspect_impl(target, ctx):
"""Implementation of the framework provider propagation aspect."""
Expand Down
15 changes: 13 additions & 2 deletions apple/internal/aspects/resource_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ def _apple_resource_aspect_impl(target, ctx):
apple_debug_infos = []
apple_dsym_bundle_infos = []
inherited_apple_resource_infos = []
provider_deps = ["deps", "private_deps", "implementation_deps"] + collect_args.get("res_attrs", [])
provider_deps = [
"deps",
"implementation_deps",
"private_deps",
] + collect_args.get("res_attrs", [])
for attr in provider_deps:
if hasattr(ctx.rule.attr, attr):
targets = getattr(ctx.rule.attr, attr)
Expand Down Expand Up @@ -354,7 +358,14 @@ def _apple_resource_aspect_impl(target, ctx):

apple_resource_aspect = aspect(
implementation = _apple_resource_aspect_impl,
attr_aspects = ["data", "deps", "private_deps", "implementation_deps", "resources", "structured_resources"],
attr_aspects = [
"data",
"deps",
"implementation_deps",
"private_deps",
"structured_resources",
"resources",
],
attrs = dicts.add(
apple_support.action_required_attrs(),
apple_toolchain_utils.shared_attrs(),
Expand Down
18 changes: 18 additions & 0 deletions test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_contains_implementation_deps_imported_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_implementation_deps_imported_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers (offset 24)",
],
tags = [name],
)

# Verify the correct XCFramework library was bundled and sliced for the required architecture.
binary_contents_test(
Expand Down
27 changes: 27 additions & 0 deletions test/starlark_tests/targets_under_test/ios/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,33 @@ int dynamic_xcframework_depending_lib_function() {
tags = common.fixture_tags,
)

# Objective-C app with implementation deps imported Objective-C XCFramework.
ios_application(
name = "app_with_implementation_deps_imported_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
tags = common.fixture_tags,
deps = [
":dynamic_xcframework_implemetation_deps_depending_lib",
"//test/starlark_tests/resources:objc_main_lib",
],
)

objc_library(
name = "dynamic_xcframework_implemetation_deps_depending_lib",
srcs = [":dynamic_xcframework_depending_lib_file"],
tags = common.fixture_tags,
implementation_deps = [":ios_imported_dynamic_xcframework"],
)

# Swift app with imported Objective-C XCFramework.
ios_application(
name = "swift_app_with_imported_objc_xcframework",
Expand Down

0 comments on commit 02b0b7f

Please sign in to comment.