1// Copyright 2020, The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package { 16 // See: http://go/android-license-faq 17 // A large-scale-change added 'default_applicable_licenses' to import 18 // all of the 'license_kinds' from "system_security_license" 19 // to get the below license kinds: 20 // SPDX-license-identifier-Apache-2.0 21 default_applicable_licenses: ["system_security_license"], 22} 23 24rust_defaults { 25 name: "libkeystore2_defaults", 26 crate_name: "keystore2", 27 srcs: ["src/lib.rs"], 28 defaults: [ 29 "keymint_use_latest_hal_aidl_rust", 30 ], 31 32 rustlibs: [ 33 "android.hardware.security.secureclock-V1-rust", 34 "android.hardware.security.sharedsecret-V1-rust", 35 "android.os.permissions_aidl-rust", 36 "android.security.apc-rust", 37 "android.security.authorization-rust", 38 "android.security.compat-rust", 39 "android.security.maintenance-rust", 40 "android.security.metrics-rust", 41 "android.security.remoteprovisioning-rust", 42 "android.system.keystore2-V2-rust", 43 "libanyhow", 44 "libbinder_rs", 45 "libkeystore2_aaid-rust", 46 "libkeystore2_apc_compat-rust", 47 "libkeystore2_crypto_rust", 48 "libkeystore2_km_compat", 49 "libkeystore2_selinux", 50 "libkeystore2_vintf_rust", 51 "liblazy_static", 52 "liblibc", 53 "liblog_event_list", 54 "liblog_rust", 55 "librand", 56 "librustutils", 57 "libserde", 58 "libserde_cbor", 59 "libthiserror", 60 ], 61 shared_libs: [ 62 "libcutils", 63 ], 64 features: [ 65 "watchdog", 66 ], 67} 68 69rust_library { 70 name: "libkeystore2", 71 defaults: ["libkeystore2_defaults"], 72 rustlibs: [ 73 "liblibsqlite3_sys", 74 "librusqlite", 75 ], 76} 77 78rust_library { 79 name: "libkeystore2_test_utils", 80 crate_name: "keystore2_test_utils", 81 srcs: ["test_utils/lib.rs"], 82 defaults: ["keymint_use_latest_hal_aidl_rust"], 83 rustlibs: [ 84 "android.system.keystore2-V2-rust", 85 "libbinder_rs", 86 "libkeystore2_selinux", 87 "liblog_rust", 88 "libnix", 89 "librand", 90 "libserde", 91 "libserde_cbor", 92 ], 93} 94 95rust_library { 96 name: "libkeystore2_with_test_utils", 97 defaults: ["libkeystore2_defaults"], 98 features: [ 99 "keystore2_blob_test_utils", 100 ], 101 rustlibs: [ 102 "liblibsqlite3_sys", 103 "librusqlite", 104 "libkeystore2_test_utils", 105 ], 106} 107 108rust_test { 109 name: "keystore2_test_utils_test", 110 srcs: ["test_utils/lib.rs"], 111 defaults: ["keymint_use_latest_hal_aidl_rust"], 112 test_suites: ["general-tests"], 113 require_root: true, 114 auto_gen_config: true, 115 compile_multilib: "first", 116 rustlibs: [ 117 "android.system.keystore2-V2-rust", 118 "libbinder_rs", 119 "libkeystore2_selinux", 120 "liblog_rust", 121 "libnix", 122 "librand", 123 "libserde", 124 "libserde_cbor", 125 ], 126} 127 128rust_test { 129 name: "keystore2_test", 130 crate_name: "keystore2", 131 test_suites: ["general-tests"], 132 auto_gen_config: true, 133 compile_multilib: "first", 134 defaults: ["libkeystore2_defaults"], 135 rustlibs: [ 136 "libandroid_logger", 137 "libkeystore2_test_utils", 138 "liblibsqlite3_sys", 139 "libnix", 140 "librusqlite", 141 "libkeystore2_with_test_utils", 142 ], 143 // The test should always include watchdog. 144 features: [ 145 "watchdog", 146 "keystore2_blob_test_utils", 147 ], 148} 149 150rust_defaults { 151 name: "keystore2_defaults", 152 srcs: ["src/keystore2_main.rs"], 153 rustlibs: [ 154 "libandroid_logger", 155 "libbinder_rs", 156 "liblog_rust", 157 ], 158 init_rc: ["keystore2.rc"], 159 160 // In S, keystore2 is the only process using dynamically linked Rust from 161 // /system. As a result, the usual savings from sharing libraries don't 162 // apply. 163 // Remove `prefer_rlib: true` once we have several processes, once a space 164 // calculation shows net RAM savings, or once we have automatic variant 165 // selection available in the build system. 166 prefer_rlib: true, 167 168 vintf_fragments: ["android.system.keystore2-service.xml"], 169 170 required: ["keystore_cli_v2"], 171} 172 173rust_binary { 174 name: "keystore2", 175 defaults: ["keystore2_defaults"], 176 rustlibs: [ 177 "libkeystore2", 178 "liblegacykeystore-rust", 179 "librusqlite", 180 ], 181 afdo: true, 182} 183