-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcc_export.bzl
More file actions
93 lines (84 loc) · 2.5 KB
/
cc_export.bzl
File metadata and controls
93 lines (84 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""Export a library from an output group."""
def cc_export_shared_library(
name = None,
srcs = [],
shared_library = None,
visibility = None):
"""Export shared library from output group.
Args:
name: Name of this target.
srcs: List of labels. See filegroups.
shared_library: Library to export.
visibility: The visibility attribute on the target.
"""
filegroup_name = name + "_fg"
native.filegroup(
name = filegroup_name,
srcs = srcs,
output_group = shared_library,
visibility = ["//visibility:private"],
)
native.cc_import(
name = name,
shared_library = filegroup_name,
visibility = visibility,
)
def cc_export_static_library(
name = None,
srcs = [],
static_library = None,
visibility = None):
"""Export static library from output group.
Args:
name: Name of this target.
srcs: List of labels. See filegroups.
static_library: Library to export.
visibility: The visibility attribute on the target.
"""
filegroup_name = name + "_fg"
native.filegroup(
name = filegroup_name,
srcs = srcs,
output_group = static_library,
visibility = ["//visibility:private"],
)
native.cc_import(
name = name,
static_library = filegroup_name,
alwayslink = 1,
visibility = visibility,
)
def cc_export_library(
name = None,
srcs = [],
shared_library = None,
static_library = None,
visibility = None):
"""Export shared and static library from output group.
Args:
name: Name of this target.
srcs: List of labels. See filegroups.
shared_library: Library to export.
static_library: Library to export.
visibility: The visibility attribute on the target.
"""
shared_filegroup_name = name + "_fg_shared"
native.filegroup(
name = shared_filegroup_name,
srcs = srcs,
output_group = shared_library,
visibility = ["//visibility:private"],
)
static_filegroup_name = name + "_fg_static"
native.filegroup(
name = static_filegroup_name,
srcs = srcs,
output_group = static_library,
visibility = ["//visibility:private"],
)
native.cc_import(
name = name,
shared_library = shared_filegroup_name,
static_library = static_filegroup_name,
visibility = visibility,
)