Skip to content

Commit 0cdfdb0

Browse files
committed
have cc_static_library return merged CcInfo
1 parent e58e628 commit 0cdfdb0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

cc/cc_static_library.bzl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,31 @@ def _cc_static_library_impl(ctx):
9393
)
9494
_run_ar_mri(ctx, cc_toolchain, script_file, output_lib, libs)
9595

96+
cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep]
97+
merged_cc_info = cc_common.merge_cc_infos(cc_infos = cc_infos)
98+
99+
library_to_link = cc_common.create_library_to_link(
100+
actions = ctx.actions,
101+
static_library = output_lib,
102+
)
103+
linker_input = cc_common.create_linker_input(
104+
owner = ctx.label,
105+
libraries = depset([library_to_link]),
106+
)
107+
linking_context = cc_common.create_linking_context(
108+
linker_inputs = depset([linker_input])
109+
)
110+
111+
final_cc_info = CcInfo(
112+
compilation_context = merged_cc_info.compilation_context,
113+
linking_context = cc_common.merge_linking_contexts(
114+
linking_contexts = [merged_cc_info.linking_context, linking_context]
115+
),
116+
)
117+
96118
return [
97119
DefaultInfo(files = depset([output_lib])),
120+
final_cc_info,
98121
]
99122

100123
cc_static_library = rule(

0 commit comments

Comments
 (0)