blob: ea94ebf630d791319cd844ccc08a112d229664d9 [file] [log] [blame]
Alice Wang94a06352023-10-16 07:19:10 +00001package {
2 default_visibility: [":__subpackages__"],
3 default_applicable_licenses: ["Android-Apache-2.0"],
4}
5
6rust_defaults {
7 name: "libdiced_open_dice_defaults",
8 crate_name: "diced_open_dice",
9 defaults: ["avf_build_flags_rust"],
10 srcs: ["src/lib.rs"],
11}
12
13rust_library_rlib {
14 name: "libdiced_open_dice_nostd",
15 defaults: ["libdiced_open_dice_defaults"],
16 rustlibs: [
17 "libopen_dice_android_bindgen_nostd",
18 "libopen_dice_cbor_bindgen_nostd",
19 "libzeroize_nostd",
20 ],
21 features: [
22 "alloc",
23 ],
24 whole_static_libs: [
25 "libopen_dice_cbor",
26 "libcrypto_baremetal",
27 ],
28 visibility: [
29 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000030 "//system/authgraph/tests:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000031 ],
32}
33
34rust_library {
35 name: "libdiced_open_dice",
36 defaults: ["libdiced_open_dice_defaults"],
Hasini Gunasingheb39fc152023-12-14 11:13:51 +000037 host_supported: true,
Alice Wang94a06352023-10-16 07:19:10 +000038 vendor_available: true,
39 rustlibs: [
40 "libopen_dice_android_bindgen",
41 "libopen_dice_cbor_bindgen",
42 "libzeroize",
43 ],
44 features: [
45 "alloc",
46 "std",
47 ],
48 shared_libs: [
49 "libcrypto",
50 ],
51 static_libs: [
52 "libopen_dice_cbor",
53 ],
54 whole_static_libs: [
55 "libopen_dice_android",
56 ],
57 visibility: [
58 "//packages/modules/Virtualization:__subpackages__",
Hasini Gunasinghe19234c42023-12-13 14:47:47 +000059 "//system/authgraph/tests:__subpackages__",
Shikha Panwar0ebd67e2023-12-22 23:58:31 +000060 "//system/secretkeeper/client:__subpackages__",
Alice Wang94a06352023-10-16 07:19:10 +000061 ],
62 apex_available: [
63 "//apex_available:platform",
64 "com.android.virt",
65 ],
66}
67
68rust_defaults {
69 name: "libdiced_open_dice_test_defaults",
70 crate_name: "diced_open_dice_test",
71 srcs: ["tests/*.rs"],
72 test_suites: ["general-tests"],
73}
74
75rust_test {
76 name: "libdiced_open_dice.integration_test",
77 defaults: ["libdiced_open_dice_test_defaults"],
78 rustlibs: [
79 "libdiced_open_dice",
80 ],
81}
82
83rust_test {
84 name: "libdiced_open_dice_nostd.integration_test",
85 defaults: ["libdiced_open_dice_test_defaults"],
86 rustlibs: [
87 "libdiced_open_dice_nostd",
88 ],
89}
90
91rust_defaults {
92 name: "libopen_dice_bindgen_nostd.rust_defaults",
93 bindgen_flags: [
94 "--use-core",
95 "--ctypes-prefix=core::ffi",
96 "--raw-line=#![no_std]",
97 ],
98 no_stdlibs: true,
99 prefer_rlib: true,
100 stdlibs: [
101 "libcore.rust_sysroot",
102 "libcompiler_builtins.rust_sysroot",
103 ],
104 target: {
105 musl: {
106 enabled: false,
107 },
108 glibc: {
109 enabled: false,
110 },
111 darwin: {
112 enabled: false,
113 },
114 },
115}
116
117rust_defaults {
118 name: "libopen_dice.rust_defaults",
119 host_supported: true,
120 vendor_available: true,
121 apex_available: [
122 "//apex_available:platform",
123 "com.android.compos",
124 "com.android.virt",
125 ],
126}
127
128rust_defaults {
129 name: "libopen_dice_cbor_bindgen.rust_defaults",
130 wrapper_src: "bindgen/dice.h",
131 crate_name: "open_dice_cbor_bindgen",
132 source_stem: "bindings",
133 bindgen_flags: [
134 "--rustified-enum DiceConfigType",
135 "--rustified-enum DiceMode",
136 "--rustified-enum DiceResult",
137
138 // By generating only essential functions, we can make bindings concise and
139 // optimize compilation time.
140 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
141 "--allowlist-function=DiceDeriveCdiCertificateId",
142 "--allowlist-function=DiceMainFlow",
143 "--allowlist-function=DiceHash",
144 "--allowlist-function=DiceKdf",
145 "--allowlist-function=DiceKeypairFromSeed",
146 "--allowlist-function=DiceSign",
147 "--allowlist-function=DiceVerify",
148 "--allowlist-function=DiceGenerateCertificate",
149
150 // We also need some constants in addition to the functions.
151 "--allowlist-var=DICE_CDI_SIZE",
152 "--allowlist-var=DICE_HASH_SIZE",
153 "--allowlist-var=DICE_HIDDEN_SIZE",
154 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
155 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
156 "--allowlist-var=DICE_ID_SIZE",
157 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
158 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
159 "--allowlist-var=DICE_SIGNATURE_SIZE",
160 ],
161}
162
163rust_bindgen {
164 name: "libopen_dice_cbor_bindgen",
165 defaults: [
166 "libopen_dice.rust_defaults",
167 "libopen_dice_cbor_bindgen.rust_defaults",
168 ],
169 whole_static_libs: ["libopen_dice_cbor"],
170}
171
172rust_bindgen {
173 name: "libopen_dice_cbor_bindgen_nostd",
174 defaults: [
175 "libopen_dice_cbor_bindgen.rust_defaults",
176 "libopen_dice_bindgen_nostd.rust_defaults",
177 ],
178 whole_static_libs: ["libopen_dice_cbor_baremetal"],
179}
180
181rust_defaults {
182 name: "libopen_dice_android_bindgen.rust_defaults",
183 wrapper_src: "bindgen/android.h",
184 crate_name: "open_dice_android_bindgen",
185 source_stem: "bindings",
186 bindgen_flags: [
187 // By generating only essential functions, we can make bindings concise and
188 // optimize compilation time.
189 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
190 "--allowlist-function=DiceAndroidMainFlow",
191 "--allowlist-function=DiceAndroidHandoverMainFlow",
192 "--allowlist-function=DiceAndroidHandoverParse",
193
194 // We also need some constants in addition to the functions.
195 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
196
197 // Prevent DiceInputValues from being generated a second time and
198 // import it instead from open_dice_cbor_bindgen.
199 "--blocklist-type=DiceInputValues_",
200 "--blocklist-type=DiceInputValues",
201 "--raw-line",
202 "pub use open_dice_cbor_bindgen::DiceInputValues;",
203
204 // Prevent DiceResult from being generated a second time and
205 // import it instead from open_dice_cbor_bindgen.
206 "--blocklist-type=DiceResult",
207 "--raw-line",
208 "pub use open_dice_cbor_bindgen::DiceResult;",
209 ],
210
211}
212
213rust_bindgen {
214 name: "libopen_dice_android_bindgen",
215 defaults: [
216 "libopen_dice.rust_defaults",
217 "libopen_dice_android_bindgen.rust_defaults",
218 ],
219 rustlibs: [
220 "libopen_dice_cbor_bindgen",
221 ],
222 whole_static_libs: ["libopen_dice_android"],
223}
224
225rust_bindgen {
226 name: "libopen_dice_android_bindgen_nostd",
227 defaults: [
228 "libopen_dice_android_bindgen.rust_defaults",
229 "libopen_dice_bindgen_nostd.rust_defaults",
230 ],
231 rustlibs: [
232 "libopen_dice_cbor_bindgen_nostd",
233 ],
234 whole_static_libs: ["libopen_dice_android_baremetal"],
235}
236
237rust_test {
238 name: "libopen_dice_cbor_bindgen_test",
239 srcs: [
240 ":libopen_dice_cbor_bindgen",
241 ],
242 crate_name: "open_dice_cbor_bindgen_test",
243 test_suites: ["general-tests"],
244 auto_gen_config: true,
245 clippy_lints: "none",
246 lints: "none",
247}
248
249rust_test {
250 name: "libopen_dice_android_bindgen_test",
251 srcs: [
252 ":libopen_dice_android_bindgen",
253 ],
254 crate_name: "open_dice_android_bindgen_test",
255 rustlibs: [
256 "libopen_dice_cbor_bindgen",
257 ],
258 test_suites: ["general-tests"],
259 auto_gen_config: true,
260 clippy_lints: "none",
261 lints: "none",
262}