blob: 2d0f52c772452aa3c0adc6941ded8fb97fc888fd [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__",
Alice Wang94a06352023-10-16 07:19:10 +000060 ],
61 apex_available: [
62 "//apex_available:platform",
63 "com.android.virt",
64 ],
65}
66
67rust_defaults {
68 name: "libdiced_open_dice_test_defaults",
69 crate_name: "diced_open_dice_test",
70 srcs: ["tests/*.rs"],
71 test_suites: ["general-tests"],
72}
73
74rust_test {
75 name: "libdiced_open_dice.integration_test",
76 defaults: ["libdiced_open_dice_test_defaults"],
77 rustlibs: [
78 "libdiced_open_dice",
79 ],
80}
81
82rust_test {
83 name: "libdiced_open_dice_nostd.integration_test",
84 defaults: ["libdiced_open_dice_test_defaults"],
85 rustlibs: [
86 "libdiced_open_dice_nostd",
87 ],
88}
89
90rust_defaults {
91 name: "libopen_dice_bindgen_nostd.rust_defaults",
92 bindgen_flags: [
93 "--use-core",
94 "--ctypes-prefix=core::ffi",
95 "--raw-line=#![no_std]",
96 ],
97 no_stdlibs: true,
98 prefer_rlib: true,
99 stdlibs: [
100 "libcore.rust_sysroot",
101 "libcompiler_builtins.rust_sysroot",
102 ],
103 target: {
104 musl: {
105 enabled: false,
106 },
107 glibc: {
108 enabled: false,
109 },
110 darwin: {
111 enabled: false,
112 },
113 },
114}
115
116rust_defaults {
117 name: "libopen_dice.rust_defaults",
118 host_supported: true,
119 vendor_available: true,
120 apex_available: [
121 "//apex_available:platform",
122 "com.android.compos",
123 "com.android.virt",
124 ],
125}
126
127rust_defaults {
128 name: "libopen_dice_cbor_bindgen.rust_defaults",
129 wrapper_src: "bindgen/dice.h",
130 crate_name: "open_dice_cbor_bindgen",
131 source_stem: "bindings",
132 bindgen_flags: [
133 "--rustified-enum DiceConfigType",
134 "--rustified-enum DiceMode",
135 "--rustified-enum DiceResult",
136
137 // By generating only essential functions, we can make bindings concise and
138 // optimize compilation time.
139 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
140 "--allowlist-function=DiceDeriveCdiCertificateId",
141 "--allowlist-function=DiceMainFlow",
142 "--allowlist-function=DiceHash",
143 "--allowlist-function=DiceKdf",
144 "--allowlist-function=DiceKeypairFromSeed",
145 "--allowlist-function=DiceSign",
146 "--allowlist-function=DiceVerify",
147 "--allowlist-function=DiceGenerateCertificate",
148
149 // We also need some constants in addition to the functions.
150 "--allowlist-var=DICE_CDI_SIZE",
151 "--allowlist-var=DICE_HASH_SIZE",
152 "--allowlist-var=DICE_HIDDEN_SIZE",
153 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
154 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
155 "--allowlist-var=DICE_ID_SIZE",
156 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
157 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
158 "--allowlist-var=DICE_SIGNATURE_SIZE",
159 ],
160}
161
162rust_bindgen {
163 name: "libopen_dice_cbor_bindgen",
164 defaults: [
165 "libopen_dice.rust_defaults",
166 "libopen_dice_cbor_bindgen.rust_defaults",
167 ],
168 whole_static_libs: ["libopen_dice_cbor"],
169}
170
171rust_bindgen {
172 name: "libopen_dice_cbor_bindgen_nostd",
173 defaults: [
174 "libopen_dice_cbor_bindgen.rust_defaults",
175 "libopen_dice_bindgen_nostd.rust_defaults",
176 ],
177 whole_static_libs: ["libopen_dice_cbor_baremetal"],
178}
179
180rust_defaults {
181 name: "libopen_dice_android_bindgen.rust_defaults",
182 wrapper_src: "bindgen/android.h",
183 crate_name: "open_dice_android_bindgen",
184 source_stem: "bindings",
185 bindgen_flags: [
186 // By generating only essential functions, we can make bindings concise and
187 // optimize compilation time.
188 "--allowlist-function=DiceAndroidFormatConfigDescriptor",
189 "--allowlist-function=DiceAndroidMainFlow",
190 "--allowlist-function=DiceAndroidHandoverMainFlow",
191 "--allowlist-function=DiceAndroidHandoverParse",
192
193 // We also need some constants in addition to the functions.
194 "--allowlist-var=DICE_ANDROID_CONFIG_.*",
195
196 // Prevent DiceInputValues from being generated a second time and
197 // import it instead from open_dice_cbor_bindgen.
198 "--blocklist-type=DiceInputValues_",
199 "--blocklist-type=DiceInputValues",
200 "--raw-line",
201 "pub use open_dice_cbor_bindgen::DiceInputValues;",
202
203 // Prevent DiceResult from being generated a second time and
204 // import it instead from open_dice_cbor_bindgen.
205 "--blocklist-type=DiceResult",
206 "--raw-line",
207 "pub use open_dice_cbor_bindgen::DiceResult;",
208 ],
209
210}
211
212rust_bindgen {
213 name: "libopen_dice_android_bindgen",
214 defaults: [
215 "libopen_dice.rust_defaults",
216 "libopen_dice_android_bindgen.rust_defaults",
217 ],
218 rustlibs: [
219 "libopen_dice_cbor_bindgen",
220 ],
221 whole_static_libs: ["libopen_dice_android"],
222}
223
224rust_bindgen {
225 name: "libopen_dice_android_bindgen_nostd",
226 defaults: [
227 "libopen_dice_android_bindgen.rust_defaults",
228 "libopen_dice_bindgen_nostd.rust_defaults",
229 ],
230 rustlibs: [
231 "libopen_dice_cbor_bindgen_nostd",
232 ],
233 whole_static_libs: ["libopen_dice_android_baremetal"],
234}
235
236rust_test {
237 name: "libopen_dice_cbor_bindgen_test",
238 srcs: [
239 ":libopen_dice_cbor_bindgen",
240 ],
241 crate_name: "open_dice_cbor_bindgen_test",
242 test_suites: ["general-tests"],
243 auto_gen_config: true,
244 clippy_lints: "none",
245 lints: "none",
246}
247
248rust_test {
249 name: "libopen_dice_android_bindgen_test",
250 srcs: [
251 ":libopen_dice_android_bindgen",
252 ],
253 crate_name: "open_dice_android_bindgen_test",
254 rustlibs: [
255 "libopen_dice_cbor_bindgen",
256 ],
257 test_suites: ["general-tests"],
258 auto_gen_config: true,
259 clippy_lints: "none",
260 lints: "none",
261}