Skip to content

Commit

Permalink
Update the swift dynamic framework aspect for lack of intermediary li…
Browse files Browse the repository at this point in the history
…nkopts target
  • Loading branch information
segiddins committed Jun 11, 2021
1 parent 4c428ad commit 83a1246
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
7 changes: 2 additions & 5 deletions apple/internal/aspects/swift_dynamic_framework_aspect.bzl
Expand Up @@ -82,11 +82,8 @@ framework module {module_name} {{
def _swift_dynamic_framework_aspect_impl(target, ctx):
"""Aspect implementation for Swift dynamic framework support."""

if not hasattr(ctx.rule.attr, "deps"):
return []

swiftdeps = [x for x in ctx.rule.attr.deps if SwiftInfo in x]
ccinfos = [x for x in ctx.rule.attr.deps if CcInfo in x]
swiftdeps = [x for x in [target] if SwiftInfo in x]
ccinfos = [x for x in [target] if CcInfo in x]

# If there are no Swift dependencies, return nothing.
if not swiftdeps:
Expand Down
7 changes: 3 additions & 4 deletions apple/internal/ios_rules.bzl
Expand Up @@ -1013,17 +1013,16 @@ def _ios_extension_impl(ctx):
def _ios_dynamic_framework_impl(ctx):
"""Experimental implementation of ios_dynamic_framework."""

# This rule should only have one swift_library dependency. This means len(ctx.attr.deps) should be 2
# because of the swift_runtime_linkopts dep that comes with the swift_libray
# This rule should only have one swift_library dependency. This means len(ctx.attr.deps) should be 1
swiftdeps = [x for x in ctx.attr.deps if SwiftInfo in x]
if len(swiftdeps) != 1 or len(ctx.attr.deps) > 2:
if len(swiftdeps) != 1 or len(ctx.attr.deps) > 1:
fail(
"""\
error: Swift dynamic frameworks expect a single swift_library dependency.
""",
)

binary_target = [deps for deps in ctx.attr.deps if deps.label.name.endswith("swift_runtime_linkopts")][0]
binary_target = ctx.attr.deps[0]
extra_linkopts = []
if ctx.attr.extension_safe:
extra_linkopts.append("-fapplication-extension")
Expand Down
7 changes: 3 additions & 4 deletions apple/internal/tvos_rules.bzl
Expand Up @@ -302,17 +302,16 @@ def _tvos_application_impl(ctx):
def _tvos_dynamic_framework_impl(ctx):
"""Experimental implementation of tvos_dynamic_framework."""

# This rule should only have one swift_library dependency. This means len(ctx.attr.deps) should be 2
# because of the swift_runtime_linkopts dep that comes with the swift_libray
# This rule should only have one swift_library dependency. This means len(ctx.attr.deps) should be 1
swiftdeps = [x for x in ctx.attr.deps if SwiftInfo in x]
if len(swiftdeps) != 1 or len(ctx.attr.deps) > 2:
if len(swiftdeps) != 1 or len(ctx.attr.deps) > 1:
fail(
"""\
error: Swift dynamic frameworks expect a single swift_library dependency.
""",
)

binary_target = [deps for deps in ctx.attr.deps if deps.label.name.endswith("swift_runtime_linkopts")][0]
binary_target = ctx.attr.deps[0]
link_result = linking_support.register_linking_action(
ctx,
stamp = ctx.attr.stamp,
Expand Down
7 changes: 3 additions & 4 deletions apple/internal/watchos_rules.bzl
Expand Up @@ -94,17 +94,16 @@ load(
def _watchos_dynamic_framework_impl(ctx):
"""Experimental implementation of watchos_dynamic_framework."""

# This rule should only have one swift_library dependency. This means len(ctx.attr.deps) should be 2
# because of the swift_runtime_linkopts dep that comes with the swift_libray
# This rule should only have one swift_library dependency. This means len(ctx.attr.deps) should be 1
swiftdeps = [x for x in ctx.attr.deps if SwiftInfo in x]
if len(swiftdeps) != 1 or len(ctx.attr.deps) > 2:
if len(swiftdeps) != 1 or len(ctx.attr.deps) > 1:
fail(
"""\
error: Swift dynamic frameworks expect a single swift_library dependency.
""",
)

binary_target = [deps for deps in ctx.attr.deps if deps.label.name.endswith("swift_runtime_linkopts")][0]
binary_target = ctx.attr.deps[0]
extra_linkopts = []
if ctx.attr.extension_safe:
extra_linkopts.append("-fapplication-extension")
Expand Down

0 comments on commit 83a1246

Please sign in to comment.