blob: 606180fddd5aeff4911c0a7b02c8b0085ff3dc88 [file] [log] [blame]
Tim Windelschmidt2da91b92025-04-15 21:10:12 +02001load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
2
3# This is a workaround for the linux kernel build, as it requires static
4# linked libraries but also their headers. This is fairly cursed and should
5# be removed as fast as possible.
6def cc_static_library_with_headers(name, dep):
7 # The artifact name has to be the same as the name of the
8 # static library, so that the linker can find it.
9 artifact_name = Label(dep).name
10 native.cc_static_library(
11 name = artifact_name,
12 deps = [dep],
13 )
14
15 _cc_static_library_wrapper(
16 name = name,
17 static_library = artifact_name,
18 library = dep,
19 )
20
21def _cc_static_library_wrapper_impl(ctx):
22 return [
23 ctx.attr.static_library[DefaultInfo],
24 ctx.attr.static_library[OutputGroupInfo],
25 ctx.attr.library[CcInfo],
26 ]
27
28_cc_static_library_wrapper = rule(
29 implementation = _cc_static_library_wrapper_impl,
30 attrs = {
31 "static_library": attr.label(),
32 "library": attr.label(),
33 },
34)