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