blob: c59419ba960011e6d4da6a35b497ca8500a22881 [file] [log] [blame]
Alice Wang0b9e1102023-02-02 09:57:06 +00001package {
Alice Wang988df592023-02-16 12:05:42 +00002 default_visibility: [":__subpackages__"],
Alice Wang0b9e1102023-02-02 09:57:06 +00003 default_applicable_licenses: ["Android-Apache-2.0"],
4}
5
6rust_defaults {
7 name: "libdiced_open_dice_defaults",
8 crate_name: "diced_open_dice",
9 srcs: ["src/lib.rs"],
Alice Wang0b9e1102023-02-02 09:57:06 +000010}
11
12rust_library_rlib {
13 name: "libdiced_open_dice_nostd",
14 defaults: ["libdiced_open_dice_defaults"],
15 rustlibs: [
Alice Wang9c40eca2023-02-03 13:10:24 +000016 "libopen_dice_bcc_bindgen_nostd",
Alice Wang0b9e1102023-02-02 09:57:06 +000017 "libopen_dice_cbor_bindgen_nostd",
Alice Wangf4bd1c62023-02-08 08:38:44 +000018 "libzeroize_nostd",
Alice Wang0b9e1102023-02-02 09:57:06 +000019 ],
Alice Wang988df592023-02-16 12:05:42 +000020 whole_static_libs: [
Alice Wang24954b42023-02-06 10:03:45 +000021 "libopen_dice_cbor",
22 "libcrypto_baremetal",
23 ],
Alice Wang988df592023-02-16 12:05:42 +000024 visibility: [
25 "//packages/modules/Virtualization:__subpackages__",
26 ],
Alice Wang0b9e1102023-02-02 09:57:06 +000027}
28
Alice Wang856d6562023-02-03 13:51:08 +000029rust_library {
Alice Wang0b9e1102023-02-02 09:57:06 +000030 name: "libdiced_open_dice",
31 defaults: ["libdiced_open_dice_defaults"],
Pierre-Clément Tosida662b02023-07-27 17:03:53 +010032 vendor_available: true,
Alice Wang0b9e1102023-02-02 09:57:06 +000033 rustlibs: [
Alice Wang9c40eca2023-02-03 13:10:24 +000034 "libopen_dice_bcc_bindgen",
Alice Wang0b9e1102023-02-02 09:57:06 +000035 "libopen_dice_cbor_bindgen",
Alice Wangf4bd1c62023-02-08 08:38:44 +000036 "libzeroize",
Alice Wang0b9e1102023-02-02 09:57:06 +000037 ],
38 features: [
39 "std",
40 ],
Alice Wang147f6042023-02-20 08:33:17 +000041 shared_libs: [
42 "libcrypto",
43 ],
Pierre-Clément Tosida662b02023-07-27 17:03:53 +010044 static_libs: [
45 "libopen_dice_cbor",
46 ],
Alice Wang9c40eca2023-02-03 13:10:24 +000047 whole_static_libs: [
48 "libopen_dice_bcc",
49 ],
Alice Wang988df592023-02-16 12:05:42 +000050 visibility: [
51 "//system/security/diced:__subpackages__",
52 "//packages/modules/Virtualization:__subpackages__",
Alice Wang5e8db6a2023-02-17 17:13:18 +000053 "//hardware/interfaces/security/dice/aidl:__subpackages__",
Alice Wang988df592023-02-16 12:05:42 +000054 ],
Pierre-Clément Tosida662b02023-07-27 17:03:53 +010055 apex_available: [
56 "//apex_available:platform",
57 "com.android.virt",
58 ],
Alice Wang24954b42023-02-06 10:03:45 +000059}
60
Alice Wangceb66422023-02-07 13:55:33 +000061rust_defaults {
62 name: "libdiced_open_dice_test_defaults",
63 crate_name: "diced_open_dice_test",
64 srcs: ["tests/*.rs"],
65 test_suites: ["general-tests"],
66}
67
68rust_test {
69 name: "libdiced_open_dice.integration_test",
70 defaults: ["libdiced_open_dice_test_defaults"],
71 rustlibs: [
72 "libdiced_open_dice",
73 ],
74}
75
76rust_test {
77 name: "libdiced_open_dice_nostd.integration_test",
78 defaults: ["libdiced_open_dice_test_defaults"],
79 rustlibs: [
80 "libdiced_open_dice_nostd",
81 ],
82}
Alice Wang988df592023-02-16 12:05:42 +000083
84rust_defaults {
85 name: "libopen_dice_bindgen_nostd.rust_defaults",
86 bindgen_flags: [
87 "--use-core",
88 "--ctypes-prefix=core::ffi",
89 "--raw-line=#![no_std]",
90 ],
91 no_stdlibs: true,
92 prefer_rlib: true,
93 stdlibs: [
94 "libcore.rust_sysroot",
95 "libcompiler_builtins.rust_sysroot",
96 ],
97 target: {
98 musl: {
99 enabled: false,
100 },
101 glibc: {
102 enabled: false,
103 },
104 darwin: {
105 enabled: false,
106 },
107 },
108}
109
110rust_defaults {
111 name: "libopen_dice.rust_defaults",
112 host_supported: true,
113 vendor_available: true,
114 apex_available: [
115 "//apex_available:platform",
116 "com.android.compos",
117 "com.android.virt",
118 ],
119}
120
121rust_defaults {
122 name: "libopen_dice_cbor_bindgen.rust_defaults",
Alice Wang988df592023-02-16 12:05:42 +0000123 wrapper_src: "bindgen/dice.h",
124 crate_name: "open_dice_cbor_bindgen",
125 source_stem: "bindings",
126 bindgen_flags: [
Alice Wang988df592023-02-16 12:05:42 +0000127 "--rustified-enum DiceConfigType",
128 "--rustified-enum DiceMode",
129 "--rustified-enum DiceResult",
130
131 // By generating only essential functions, we can make bindings concise and
132 // optimize compilation time.
133 "--allowlist-function=DiceDeriveCdiPrivateKeySeed",
134 "--allowlist-function=DiceDeriveCdiCertificateId",
135 "--allowlist-function=DiceMainFlow",
136 "--allowlist-function=DiceHash",
137 "--allowlist-function=DiceKdf",
138 "--allowlist-function=DiceKeypairFromSeed",
139 "--allowlist-function=DiceSign",
140 "--allowlist-function=DiceVerify",
141 "--allowlist-function=DiceGenerateCertificate",
142
143 // We also need some constants in addition to the functions.
144 "--allowlist-var=DICE_CDI_SIZE",
145 "--allowlist-var=DICE_HASH_SIZE",
146 "--allowlist-var=DICE_HIDDEN_SIZE",
147 "--allowlist-var=DICE_INLINE_CONFIG_SIZE",
148 "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE",
149 "--allowlist-var=DICE_ID_SIZE",
150 "--allowlist-var=DICE_PUBLIC_KEY_SIZE",
151 "--allowlist-var=DICE_PRIVATE_KEY_SIZE",
152 "--allowlist-var=DICE_SIGNATURE_SIZE",
153 ],
154}
155
156rust_bindgen {
157 name: "libopen_dice_cbor_bindgen",
Pierre-Clément Tosida662b02023-07-27 17:03:53 +0100158 defaults: [
159 "libopen_dice.rust_defaults",
160 "libopen_dice_cbor_bindgen.rust_defaults",
161 ],
Alice Wang988df592023-02-16 12:05:42 +0000162 whole_static_libs: ["libopen_dice_cbor"],
Alice Wang988df592023-02-16 12:05:42 +0000163}
164
165rust_bindgen {
166 name: "libopen_dice_cbor_bindgen_nostd",
167 defaults: [
168 "libopen_dice_cbor_bindgen.rust_defaults",
169 "libopen_dice_bindgen_nostd.rust_defaults",
170 ],
171 whole_static_libs: ["libopen_dice_cbor_baremetal"],
172}
173
174rust_defaults {
175 name: "libopen_dice_bcc_bindgen.rust_defaults",
Alice Wang988df592023-02-16 12:05:42 +0000176 wrapper_src: "bindgen/android/bcc.h",
177 crate_name: "open_dice_bcc_bindgen",
178 source_stem: "bindings",
179 bindgen_flags: [
Alice Wang988df592023-02-16 12:05:42 +0000180 // By generating only essential functions, we can make bindings concise and
181 // optimize compilation time.
182 "--allowlist-function=BccFormatConfigDescriptor",
183 "--allowlist-function=BccMainFlow",
184 "--allowlist-function=BccHandoverMainFlow",
185 "--allowlist-function=BccHandoverParse",
186
187 // We also need some constants in addition to the functions.
188 "--allowlist-var=BCC_INPUT_COMPONENT_NAME",
189 "--allowlist-var=BCC_INPUT_COMPONENT_VERSION",
190 "--allowlist-var=BCC_INPUT_RESETTABLE",
191
192 // Prevent DiceInputValues from being generated a second time and
193 // import it instead from open_dice_cbor_bindgen.
194 "--blocklist-type=DiceInputValues_",
195 "--blocklist-type=DiceInputValues",
196 "--raw-line",
197 "pub use open_dice_cbor_bindgen::DiceInputValues;",
198
199 // Prevent DiceResult from being generated a second time and
200 // import it instead from open_dice_cbor_bindgen.
201 "--blocklist-type=DiceResult",
202 "--raw-line",
203 "pub use open_dice_cbor_bindgen::DiceResult;",
204 ],
205
206}
207
208rust_bindgen {
209 name: "libopen_dice_bcc_bindgen",
Pierre-Clément Tosida662b02023-07-27 17:03:53 +0100210 defaults: [
211 "libopen_dice.rust_defaults",
212 "libopen_dice_bcc_bindgen.rust_defaults",
213 ],
Alice Wang988df592023-02-16 12:05:42 +0000214 rustlibs: [
215 "libopen_dice_cbor_bindgen",
216 ],
217 whole_static_libs: ["libopen_dice_bcc"],
218}
219
220rust_bindgen {
221 name: "libopen_dice_bcc_bindgen_nostd",
222 defaults: [
223 "libopen_dice_bcc_bindgen.rust_defaults",
224 "libopen_dice_bindgen_nostd.rust_defaults",
225 ],
226 rustlibs: [
227 "libopen_dice_cbor_bindgen_nostd",
228 ],
229 whole_static_libs: ["libopen_dice_bcc_baremetal"],
230}
231
232rust_test {
233 name: "libopen_dice_cbor_bindgen_test",
234 srcs: [
235 ":libopen_dice_cbor_bindgen",
236 ],
237 crate_name: "open_dice_cbor_bindgen_test",
238 test_suites: ["general-tests"],
239 auto_gen_config: true,
240 clippy_lints: "none",
241 lints: "none",
242}
243
244rust_test {
245 name: "libopen_dice_bcc_bindgen_test",
246 srcs: [
247 ":libopen_dice_bcc_bindgen",
248 ],
249 crate_name: "open_dice_bcc_bindgen_test",
250 rustlibs: [
251 "libopen_dice_cbor_bindgen",
252 ],
253 test_suites: ["general-tests"],
254 auto_gen_config: true,
255 clippy_lints: "none",
256 lints: "none",
257}