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
29    rustlibs: [
30        "android.hardware.security.keymint-V1-rust",
31        "android.hardware.security.secureclock-V1-rust",
32        "android.hardware.security.sharedsecret-V1-rust",
33        "android.os.permissions_aidl-rust",
34        "android.security.apc-rust",
35        "android.security.authorization-rust",
36        "android.security.compat-rust",
37        "android.security.maintenance-rust",
38        "android.security.metrics-rust",
39        "android.security.remoteprovisioning-rust",
40        "android.system.keystore2-V1-rust",
41        "libanyhow",
42        "libbinder_rs",
43        "libcutils_bindgen",
44        "libkeystore2_aaid-rust",
45        "libkeystore2_apc_compat-rust",
46        "libkeystore2_crypto_rust",
47        "libkeystore2_km_compat",
48        "libkeystore2_selinux",
49        "libkeystore2_system_property-rust",
50        "libkeystore2_vintf_rust",
51        "liblazy_static",
52        "liblibc",
53        "liblibsqlite3_sys",
54        "liblog_event_list",
55        "liblog_rust",
56        "librand",
57        "librusqlite",
58        "libthiserror",
59    ],
60    shared_libs: [
61        "libcutils",
62    ],
63    features: [
64        "watchdog",
65    ],
66}
67
68rust_library {
69    name: "libkeystore2",
70    defaults: ["libkeystore2_defaults"],
71}
72
73rust_library {
74    name: "libkeystore2_test_utils",
75    crate_name: "keystore2_test_utils",
76    srcs: ["test_utils/lib.rs"],
77    rustlibs: [
78        "liblog_rust",
79        "librand",
80    ],
81}
82
83rust_test {
84    name: "keystore2_test",
85    crate_name: "keystore2",
86    test_suites: ["general-tests"],
87    auto_gen_config: true,
88    compile_multilib: "first",
89    defaults: ["libkeystore2_defaults"],
90    rustlibs: [
91        "libandroid_logger",
92        "libkeystore2_test_utils",
93        "libnix",
94    ],
95    // The test should always include watchdog.
96    features: [
97        "watchdog",
98    ],
99}
100
101rust_binary {
102    name: "keystore2",
103    srcs: ["src/keystore2_main.rs"],
104    rustlibs: [
105        "libandroid_logger",
106        "libbinder_rs",
107        "libkeystore2",
108        "liblog_rust",
109        "liblegacykeystore-rust",
110    ],
111    init_rc: ["keystore2.rc"],
112
113    // In S, keystore2 is the only process using dynamically linked Rust from
114    // /system. As a result, the usual savings from sharing libraries don't
115    // apply.
116    // Remove `prefer_rlib: true` once we have several processes, once a space
117    // calculation shows net RAM savings, or once we have automatic variant
118    // selection available in the build system.
119    prefer_rlib: true,
120
121    // TODO(b/187412695)
122    // This is a hack to work around the build system not installing
123    // dynamic dependencies of rlibs to the device. This section should
124    // be removed once that works correctly.
125    shared_libs: [
126        "android.hardware.confirmationui@1.0",
127        "android.hardware.security.sharedsecret-V1-ndk_platform",
128        "android.security.compat-ndk_platform",
129        "libc",
130        "libdl_android",
131        "libdl",
132        "libandroidicu",
133        "libkeymint",
134        "libkeystore2_aaid",
135        "libkeystore2_apc_compat",
136        "libkeystore2_crypto",
137        "libkeystore2_vintf_cpp",
138        "libkm_compat_service",
139        "libkm_compat",
140        "libm",
141        "libstatspull",
142        "libstatssocket",
143    ],
144
145    vintf_fragments: ["android.system.keystore2-service.xml"],
146
147    required: ["keystore_cli_v2"],
148}
149