Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 1 | package { |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 2 | default_visibility: [":__subpackages__"], |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 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 | srcs: ["src/lib.rs"], |
| 10 | static_libs: [ |
| 11 | "libopen_dice_cbor", |
| 12 | ], |
| 13 | vendor_available: true, |
| 14 | apex_available: [ |
| 15 | "//apex_available:platform", |
| 16 | "com.android.virt", |
| 17 | ], |
| 18 | } |
| 19 | |
| 20 | rust_library_rlib { |
| 21 | name: "libdiced_open_dice_nostd", |
| 22 | defaults: ["libdiced_open_dice_defaults"], |
| 23 | rustlibs: [ |
Alice Wang | 9c40eca | 2023-02-03 13:10:24 +0000 | [diff] [blame] | 24 | "libopen_dice_bcc_bindgen_nostd", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 25 | "libopen_dice_cbor_bindgen_nostd", |
Alice Wang | f4bd1c6 | 2023-02-08 08:38:44 +0000 | [diff] [blame] | 26 | "libzeroize_nostd", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 27 | ], |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 28 | whole_static_libs: [ |
Alice Wang | 24954b4 | 2023-02-06 10:03:45 +0000 | [diff] [blame] | 29 | "libopen_dice_cbor", |
| 30 | "libcrypto_baremetal", |
| 31 | ], |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 32 | visibility: [ |
| 33 | "//packages/modules/Virtualization:__subpackages__", |
| 34 | ], |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Alice Wang | 856d656 | 2023-02-03 13:51:08 +0000 | [diff] [blame] | 37 | rust_library { |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 38 | name: "libdiced_open_dice", |
| 39 | defaults: ["libdiced_open_dice_defaults"], |
| 40 | rustlibs: [ |
Alice Wang | 9c40eca | 2023-02-03 13:10:24 +0000 | [diff] [blame] | 41 | "libopen_dice_bcc_bindgen", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 42 | "libopen_dice_cbor_bindgen", |
Alice Wang | f4bd1c6 | 2023-02-08 08:38:44 +0000 | [diff] [blame] | 43 | "libzeroize", |
Alice Wang | 0b9e110 | 2023-02-02 09:57:06 +0000 | [diff] [blame] | 44 | ], |
| 45 | features: [ |
| 46 | "std", |
| 47 | ], |
Alice Wang | 147f604 | 2023-02-20 08:33:17 +0000 | [diff] [blame^] | 48 | shared_libs: [ |
| 49 | "libcrypto", |
| 50 | ], |
Alice Wang | 9c40eca | 2023-02-03 13:10:24 +0000 | [diff] [blame] | 51 | whole_static_libs: [ |
| 52 | "libopen_dice_bcc", |
| 53 | ], |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 54 | visibility: [ |
| 55 | "//system/security/diced:__subpackages__", |
| 56 | "//packages/modules/Virtualization:__subpackages__", |
Alice Wang | 5e8db6a | 2023-02-17 17:13:18 +0000 | [diff] [blame] | 57 | "//hardware/interfaces/security/dice/aidl:__subpackages__", |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 58 | ], |
Alice Wang | 24954b4 | 2023-02-06 10:03:45 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Alice Wang | ceb6642 | 2023-02-07 13:55:33 +0000 | [diff] [blame] | 61 | rust_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 | |
| 68 | rust_test { |
| 69 | name: "libdiced_open_dice.integration_test", |
| 70 | defaults: ["libdiced_open_dice_test_defaults"], |
| 71 | rustlibs: [ |
| 72 | "libdiced_open_dice", |
| 73 | ], |
| 74 | } |
| 75 | |
| 76 | rust_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 Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 83 | |
| 84 | rust_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 | |
| 110 | rust_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 | |
| 121 | rust_defaults { |
| 122 | name: "libopen_dice_cbor_bindgen.rust_defaults", |
| 123 | defaults: ["libopen_dice.rust_defaults"], |
| 124 | wrapper_src: "bindgen/dice.h", |
| 125 | crate_name: "open_dice_cbor_bindgen", |
| 126 | source_stem: "bindings", |
| 127 | bindgen_flags: [ |
| 128 | "--size_t-is-usize", |
| 129 | "--rustified-enum DiceConfigType", |
| 130 | "--rustified-enum DiceMode", |
| 131 | "--rustified-enum DiceResult", |
| 132 | |
| 133 | // By generating only essential functions, we can make bindings concise and |
| 134 | // optimize compilation time. |
| 135 | "--allowlist-function=DiceDeriveCdiPrivateKeySeed", |
| 136 | "--allowlist-function=DiceDeriveCdiCertificateId", |
| 137 | "--allowlist-function=DiceMainFlow", |
| 138 | "--allowlist-function=DiceHash", |
| 139 | "--allowlist-function=DiceKdf", |
| 140 | "--allowlist-function=DiceKeypairFromSeed", |
| 141 | "--allowlist-function=DiceSign", |
| 142 | "--allowlist-function=DiceVerify", |
| 143 | "--allowlist-function=DiceGenerateCertificate", |
| 144 | |
| 145 | // We also need some constants in addition to the functions. |
| 146 | "--allowlist-var=DICE_CDI_SIZE", |
| 147 | "--allowlist-var=DICE_HASH_SIZE", |
| 148 | "--allowlist-var=DICE_HIDDEN_SIZE", |
| 149 | "--allowlist-var=DICE_INLINE_CONFIG_SIZE", |
| 150 | "--allowlist-var=DICE_PRIVATE_KEY_SEED_SIZE", |
| 151 | "--allowlist-var=DICE_ID_SIZE", |
| 152 | "--allowlist-var=DICE_PUBLIC_KEY_SIZE", |
| 153 | "--allowlist-var=DICE_PRIVATE_KEY_SIZE", |
| 154 | "--allowlist-var=DICE_SIGNATURE_SIZE", |
| 155 | ], |
| 156 | } |
| 157 | |
| 158 | rust_bindgen { |
| 159 | name: "libopen_dice_cbor_bindgen", |
| 160 | defaults: ["libopen_dice_cbor_bindgen.rust_defaults"], |
| 161 | whole_static_libs: ["libopen_dice_cbor"], |
Alice Wang | 988df59 | 2023-02-16 12:05:42 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | rust_bindgen { |
| 165 | name: "libopen_dice_cbor_bindgen_nostd", |
| 166 | defaults: [ |
| 167 | "libopen_dice_cbor_bindgen.rust_defaults", |
| 168 | "libopen_dice_bindgen_nostd.rust_defaults", |
| 169 | ], |
| 170 | whole_static_libs: ["libopen_dice_cbor_baremetal"], |
| 171 | } |
| 172 | |
| 173 | rust_defaults { |
| 174 | name: "libopen_dice_bcc_bindgen.rust_defaults", |
| 175 | defaults: ["libopen_dice.rust_defaults"], |
| 176 | wrapper_src: "bindgen/android/bcc.h", |
| 177 | crate_name: "open_dice_bcc_bindgen", |
| 178 | source_stem: "bindings", |
| 179 | bindgen_flags: [ |
| 180 | "--size_t-is-usize", |
| 181 | |
| 182 | // By generating only essential functions, we can make bindings concise and |
| 183 | // optimize compilation time. |
| 184 | "--allowlist-function=BccFormatConfigDescriptor", |
| 185 | "--allowlist-function=BccMainFlow", |
| 186 | "--allowlist-function=BccHandoverMainFlow", |
| 187 | "--allowlist-function=BccHandoverParse", |
| 188 | |
| 189 | // We also need some constants in addition to the functions. |
| 190 | "--allowlist-var=BCC_INPUT_COMPONENT_NAME", |
| 191 | "--allowlist-var=BCC_INPUT_COMPONENT_VERSION", |
| 192 | "--allowlist-var=BCC_INPUT_RESETTABLE", |
| 193 | |
| 194 | // Prevent DiceInputValues from being generated a second time and |
| 195 | // import it instead from open_dice_cbor_bindgen. |
| 196 | "--blocklist-type=DiceInputValues_", |
| 197 | "--blocklist-type=DiceInputValues", |
| 198 | "--raw-line", |
| 199 | "pub use open_dice_cbor_bindgen::DiceInputValues;", |
| 200 | |
| 201 | // Prevent DiceResult from being generated a second time and |
| 202 | // import it instead from open_dice_cbor_bindgen. |
| 203 | "--blocklist-type=DiceResult", |
| 204 | "--raw-line", |
| 205 | "pub use open_dice_cbor_bindgen::DiceResult;", |
| 206 | ], |
| 207 | |
| 208 | } |
| 209 | |
| 210 | rust_bindgen { |
| 211 | name: "libopen_dice_bcc_bindgen", |
| 212 | defaults: ["libopen_dice_bcc_bindgen.rust_defaults"], |
| 213 | rustlibs: [ |
| 214 | "libopen_dice_cbor_bindgen", |
| 215 | ], |
| 216 | whole_static_libs: ["libopen_dice_bcc"], |
| 217 | } |
| 218 | |
| 219 | rust_bindgen { |
| 220 | name: "libopen_dice_bcc_bindgen_nostd", |
| 221 | defaults: [ |
| 222 | "libopen_dice_bcc_bindgen.rust_defaults", |
| 223 | "libopen_dice_bindgen_nostd.rust_defaults", |
| 224 | ], |
| 225 | rustlibs: [ |
| 226 | "libopen_dice_cbor_bindgen_nostd", |
| 227 | ], |
| 228 | whole_static_libs: ["libopen_dice_bcc_baremetal"], |
| 229 | } |
| 230 | |
| 231 | rust_test { |
| 232 | name: "libopen_dice_cbor_bindgen_test", |
| 233 | srcs: [ |
| 234 | ":libopen_dice_cbor_bindgen", |
| 235 | ], |
| 236 | crate_name: "open_dice_cbor_bindgen_test", |
| 237 | test_suites: ["general-tests"], |
| 238 | auto_gen_config: true, |
| 239 | clippy_lints: "none", |
| 240 | lints: "none", |
| 241 | } |
| 242 | |
| 243 | rust_test { |
| 244 | name: "libopen_dice_bcc_bindgen_test", |
| 245 | srcs: [ |
| 246 | ":libopen_dice_bcc_bindgen", |
| 247 | ], |
| 248 | crate_name: "open_dice_bcc_bindgen_test", |
| 249 | rustlibs: [ |
| 250 | "libopen_dice_cbor_bindgen", |
| 251 | ], |
| 252 | test_suites: ["general-tests"], |
| 253 | auto_gen_config: true, |
| 254 | clippy_lints: "none", |
| 255 | lints: "none", |
| 256 | } |