Skip to content

Commit

Permalink
Add clang attr to merged swift info in framework.bzl
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Aug 26, 2024
1 parent e526f2e commit c21ec37
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _get_virtual_framework_info(ctx, framework_files, compilation_context_fields
vfs = make_vfsoverlay(
ctx,
hdrs = outputs.headers,
module_map = outputs.modulemaps,
module_map = outputs.modulemap,
# We might need to pass in .swiftinterface files here as well
# esp. if the error is `swift declaration not found` for some module
swiftmodules = _compact([outputs.swiftmodule, outputs.swiftdoc]),
Expand Down Expand Up @@ -459,7 +459,7 @@ def _get_framework_files(ctx, deps):
headers = headers_out,
infoplist = infoplist_out,
private_headers = private_headers_out,
modulemaps = [modulemap_out] if modulemap_out else [],
modulemap = modulemap_out,
swiftmodule = swiftmodule_out,
swiftdoc = swiftdoc_out,
swiftinterface = swiftinterface_out,
Expand All @@ -471,7 +471,7 @@ def _get_framework_files(ctx, deps):
binaries = binaries_in,
headers = headers_in,
private_headers = private_headers_in,
modulemaps = [modulemap_in] if modulemap_in else [],
modulemap = modulemap_in,
swiftmodule = swiftmodule_in,
swiftdoc = swiftdoc_in,
swiftinterface = swiftinterface_in,
Expand All @@ -498,10 +498,10 @@ def _get_symlinked_framework_clean_action(ctx, framework_files, compilation_cont
framework_contents = _compact(
[
outputs.binary,
outputs.swiftmodule,
outputs.modulemap,
outputs.swiftdoc,
outputs.swiftmodule,
] +
outputs.modulemaps +
outputs.headers +
outputs.private_headers,
)
Expand Down Expand Up @@ -581,7 +581,16 @@ def _copy_swiftmodule(ctx, framework_files):
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 = swift_common.create_clang_module(
module_map = outputs.modulemap,
compilation_context = cc_common.create_compilation_context(
headers = depset(outputs.headers + outputs.private_headers + ([outputs.modulemap] if outputs.modulemap else [])),
)
),
swift = swift_module
),
]

def _get_merged_swift_info(ctx, framework_files, transitive_deps):
Expand Down Expand Up @@ -1015,12 +1024,12 @@ def _apple_framework_packaging_impl(ctx):
# Perform a basic merging of compilation context fields
compilation_context_fields = {}
objc_provider_utils.add_to_dict_if_present(compilation_context_fields, "headers", depset(
direct = outputs.headers + outputs.private_headers + outputs.modulemaps,
direct = outputs.headers + outputs.private_headers + ([outputs.modulemap] if outputs.modulemap else []),
))
objc_provider_utils.add_to_dict_if_present(
compilation_context_fields,
"direct_public_headers",
outputs.headers + outputs.modulemaps,
outputs.headers + ([outputs.modulemap] if outputs.modulemap else []),
)
objc_provider_utils.add_to_dict_if_present(compilation_context_fields, "defines", depset(
direct = [],
Expand All @@ -1043,7 +1052,7 @@ def _apple_framework_packaging_impl(ctx):
framework_info = FrameworkInfo(
headers = outputs.headers,
private_headers = outputs.private_headers,
modulemap = outputs.modulemaps,
modulemap = outputs.modulemap,
swiftmodule = outputs.swiftmodule,
swiftdoc = outputs.swiftdoc,
)
Expand Down Expand Up @@ -1090,7 +1099,7 @@ def _apple_framework_packaging_impl(ctx):
out_files = _compact([outputs.binary, outputs.swiftmodule, outputs.infoplist])
out_files.extend(outputs.headers)
out_files.extend(outputs.private_headers)
out_files.extend(outputs.modulemaps)
out_files.extend([outputs.modulemap] if outputs.modulemap else [])

default_info = DefaultInfo(files = depset(out_files + bundle_outs.files.to_list()))

Expand Down

0 comments on commit c21ec37

Please sign in to comment.