• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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        "keystore2_use_latest_aidl_rust",
31    ],
32
33    rustlibs: [
34        "android.hardware.security.secureclock-V1-rust",
35        "android.hardware.security.sharedsecret-V1-rust",
36        "android.os.permissions_aidl-rust",
37        "android.security.apc-rust",
38        "android.security.authorization-rust",
39        "android.security.compat-rust",
40        "android.security.maintenance-rust",
41        "android.security.metrics-rust",
42        "android.security.rkp_aidl-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        "libtokio",
61    ],
62    shared_libs: [
63        "libcutils",
64    ],
65    features: [
66        "watchdog",
67    ],
68}
69
70rust_library {
71    name: "libkeystore2",
72    defaults: ["libkeystore2_defaults"],
73    rustlibs: [
74        "liblibsqlite3_sys",
75        "librusqlite",
76    ],
77}
78
79rust_library {
80    name: "libkeystore2_test_utils",
81    crate_name: "keystore2_test_utils",
82    srcs: ["test_utils/lib.rs"],
83    defaults: [
84        "keymint_use_latest_hal_aidl_rust",
85        "keystore2_use_latest_aidl_rust",
86    ],
87    rustlibs: [
88        "libbinder_rs",
89        "libkeystore2_selinux",
90        "liblog_rust",
91        "libnix",
92        "librand",
93        "libserde",
94        "libserde_cbor",
95        "libthiserror",
96        "libanyhow",
97    ],
98}
99
100rust_library {
101    name: "libkeystore2_with_test_utils",
102    defaults: ["libkeystore2_defaults"],
103    features: [
104        "keystore2_blob_test_utils",
105    ],
106    rustlibs: [
107        "liblibsqlite3_sys",
108        "librusqlite",
109        "libkeystore2_test_utils",
110    ],
111}
112
113rust_test {
114    name: "keystore2_test_utils_test",
115    srcs: ["test_utils/lib.rs"],
116    defaults: [
117        "keymint_use_latest_hal_aidl_rust",
118        "keystore2_use_latest_aidl_rust",
119    ],
120    test_suites: ["general-tests"],
121    require_root: true,
122    auto_gen_config: true,
123    compile_multilib: "first",
124    rustlibs: [
125        "libbinder_rs",
126        "libkeystore2_selinux",
127        "liblog_rust",
128        "libnix",
129        "librand",
130        "libserde",
131        "libserde_cbor",
132        "libthiserror",
133        "libanyhow",
134    ],
135}
136
137rust_test {
138    name: "keystore2_test",
139    crate_name: "keystore2",
140    test_suites: ["general-tests"],
141    auto_gen_config: true,
142    compile_multilib: "first",
143    defaults: ["libkeystore2_defaults"],
144    rustlibs: [
145        "libandroid_logger",
146        "libkeystore2_test_utils",
147        "liblibsqlite3_sys",
148        "libnix",
149        "librusqlite",
150        "libkeystore2_with_test_utils",
151    ],
152    // The test should always include watchdog.
153    features: [
154        "watchdog",
155        "keystore2_blob_test_utils",
156    ],
157    require_root: true,
158}
159
160rust_defaults {
161    name: "keystore2_defaults",
162    srcs: ["src/keystore2_main.rs"],
163    rustlibs: [
164        "libandroid_logger",
165        "libbinder_rs",
166        "liblog_rust",
167    ],
168    init_rc: ["keystore2.rc"],
169
170    // In S, keystore2 is the only process using dynamically linked Rust from
171    // /system. As a result, the usual savings from sharing libraries don't
172    // apply.
173    // Remove `prefer_rlib: true` once we have several processes, once a space
174    // calculation shows net RAM savings, or once we have automatic variant
175    // selection available in the build system.
176    prefer_rlib: true,
177
178    vintf_fragments: ["android.system.keystore2-service.xml"],
179
180    required: ["keystore_cli_v2"],
181}
182
183rust_binary {
184    name: "keystore2",
185    defaults: ["keystore2_defaults"],
186    rustlibs: [
187        "libkeystore2",
188        "liblegacykeystore-rust",
189        "librusqlite",
190    ],
191    afdo: true,
192}
193