From 83a1246166923a9a6add5b3e6ab9ebc62a007631 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Thu, 10 Jun 2021 15:01:06 -0700 Subject: [PATCH] Update the swift dynamic framework aspect for lack of intermediary linkopts target --- apple/internal/aspects/swift_dynamic_framework_aspect.bzl | 7 ++----- apple/internal/ios_rules.bzl | 7 +++---- apple/internal/tvos_rules.bzl | 7 +++---- apple/internal/watchos_rules.bzl | 7 +++---- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/apple/internal/aspects/swift_dynamic_framework_aspect.bzl b/apple/internal/aspects/swift_dynamic_framework_aspect.bzl index 51a566e67f..d146f8fd84 100644 --- a/apple/internal/aspects/swift_dynamic_framework_aspect.bzl +++ b/apple/internal/aspects/swift_dynamic_framework_aspect.bzl @@ -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: diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index 3e8c058cb5..62a57fc14b 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -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") diff --git a/apple/internal/tvos_rules.bzl b/apple/internal/tvos_rules.bzl index f38b165e6f..457f23cac9 100644 --- a/apple/internal/tvos_rules.bzl +++ b/apple/internal/tvos_rules.bzl @@ -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, diff --git a/apple/internal/watchos_rules.bzl b/apple/internal/watchos_rules.bzl index 54c0710813..ba34bcd344 100644 --- a/apple/internal/watchos_rules.bzl +++ b/apple/internal/watchos_rules.bzl @@ -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")