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