Skip to content
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

Fix rules_swift 2 compatibility issues #903

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def _create_swiftmodule(attrs):
**kwargs
)

def _copy_swiftmodule(ctx, framework_files):
def _copy_swiftmodule(ctx, framework_files, virtualize_frameworks):
inputs = framework_files.inputs
outputs = framework_files.outputs

Expand All @@ -578,18 +578,38 @@ def _copy_swiftmodule(ctx, framework_files):
# original swift module/doc, so that swift can find it.
swift_module = _create_swiftmodule(inputs)

# Setup the `clang` attr of the Swift module for non-vfs case this is required to have it locate the modulemap
# and headers correctly.
clang = None
if not virtualize_frameworks:
module_map = outputs.modulemaps[0] if outputs.modulemaps else None
clang = swift_common.create_clang_module(
module_map = module_map,
compilation_context = cc_common.create_compilation_context(
headers = depset(_compact(
outputs.headers +
outputs.private_headers +
[module_map],
)),
),
)

return [
# only add the swift module, the objc modulemap is already listed as a header,
# and it will be discovered via the framework search path
swift_common.create_module(name = swiftmodule_name, swift = swift_module),
swift_common.create_module(
name = swiftmodule_name,
clang = clang,
swift = swift_module,
),
]

def _get_merged_swift_info(ctx, framework_files, transitive_deps):
def _get_merged_swift_info(ctx, framework_files, transitive_deps, virtualize_frameworks):
swift_info_fields = {
"swift_infos": [dep[SwiftInfo] for dep in transitive_deps if SwiftInfo in dep],
}
if framework_files.outputs.swiftmodule:
swift_info_fields["modules"] = _copy_swiftmodule(ctx, framework_files)
swift_info_fields["modules"] = _copy_swiftmodule(ctx, framework_files, virtualize_frameworks)
return swift_common.create_swift_info(**swift_info_fields)

def _merge_root_infoplists(ctx):
Expand Down Expand Up @@ -1084,7 +1104,7 @@ def _apple_framework_packaging_impl(ctx):
else:
bundle_outs = _bundle_static_framework(ctx, is_extension_safe = is_extension_safe, current_apple_platform = current_apple_platform, outputs = outputs)
avoid_deps_info = AvoidDepsInfo(libraries = depset(avoid_deps).to_list(), link_dynamic = False)
swift_info = _get_merged_swift_info(ctx, framework_files, transitive_deps)
swift_info = _get_merged_swift_info(ctx, framework_files, transitive_deps, virtualize_frameworks)

# Build out the default info provider
out_files = _compact([outputs.binary, outputs.swiftmodule, outputs.infoplist])
Expand Down
Loading