From c21ec37f92819c4ac85a68f426b296b05be064e3 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Mon, 26 Aug 2024 12:10:56 -0400 Subject: [PATCH] Add clang attr to merged swift info in framework.bzl --- rules/framework.bzl | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/rules/framework.bzl b/rules/framework.bzl index e287b0bd..ba8fdb27 100644 --- a/rules/framework.bzl +++ b/rules/framework.bzl @@ -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]), @@ -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, @@ -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, @@ -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, ) @@ -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): @@ -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 = [], @@ -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, ) @@ -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()))