xref: /aosp_15_r20/system/keymint/wire/Android.bp (revision 9860b7637a5f185913c70aa0caabe3ecb78441e4)
1// Copyright 2022, 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    default_applicable_licenses: ["system_keymint_license"],
17}
18
19rust_library {
20    name: "libkmr_wire",
21    crate_name: "kmr_wire",
22    srcs: ["src/lib.rs"],
23    host_supported: true,
24    vendor_available: true,
25    edition: "2021",
26    lints: "android",
27    // Default target includes support for all versions of the KeyMint HAL.
28    features: [
29        "hal_v2",
30        "hal_v3",
31        "hal_v4",
32    ],
33    rustlibs: [
34        "libciborium",
35        "libciborium_io",
36        "libcoset",
37        "liblog_rust",
38        "libzeroize",
39    ],
40    proc_macros: [
41        "libenumn",
42        "libkmr_derive",
43    ],
44}
45
46// Variant of the library that only includes support for the KeyMint v3 HAL types.
47rust_library {
48    name: "libkmr_wire_hal_v3",
49    crate_name: "kmr_wire",
50    srcs: ["src/lib.rs"],
51    host_supported: true,
52    vendor_available: true,
53    edition: "2021",
54    lints: "android",
55    features: [
56        "hal_v3",
57        "hal_v2",
58    ],
59    rustlibs: [
60        "libciborium",
61        "libciborium_io",
62        "libcoset",
63        "liblog_rust",
64        "libzeroize",
65    ],
66    proc_macros: [
67        "libenumn",
68        "libkmr_derive",
69    ],
70}
71
72// Variant of the library that only includes support for the KeyMint v2 HAL types.
73rust_library {
74    name: "libkmr_wire_hal_v2",
75    crate_name: "kmr_wire",
76    srcs: ["src/lib.rs"],
77    host_supported: true,
78    vendor_available: true,
79    edition: "2021",
80    lints: "android",
81    features: [
82        "hal_v2",
83    ],
84    rustlibs: [
85        "libciborium",
86        "libciborium_io",
87        "libcoset",
88        "liblog_rust",
89        "libzeroize",
90    ],
91    proc_macros: [
92        "libenumn",
93        "libkmr_derive",
94    ],
95}
96
97// Variant of the library that only includes support for the KeyMint v1 HAL types.
98rust_library {
99    name: "libkmr_wire_hal_v1",
100    crate_name: "kmr_wire",
101    srcs: ["src/lib.rs"],
102    host_supported: true,
103    vendor_available: true,
104    edition: "2021",
105    lints: "android",
106    rustlibs: [
107        "libciborium",
108        "libciborium_io",
109        "libcoset",
110        "liblog_rust",
111        "libzeroize",
112    ],
113    proc_macros: [
114        "libenumn",
115        "libkmr_derive",
116    ],
117}
118
119rust_library_rlib {
120    name: "libkmr_wire_nostd",
121    crate_name: "kmr_wire",
122    srcs: ["src/lib.rs"],
123    vendor_available: true,
124    edition: "2021",
125    lints: "android",
126    features: [
127        "hal_v2",
128        "hal_v3",
129        "hal_v4",
130    ],
131    rustlibs: [
132        "libciborium_nostd",
133        "libciborium_io_nostd",
134        "libcoset_nostd",
135        "liblog_rust_nostd",
136        "libzeroize_nostd",
137    ],
138    proc_macros: [
139        "libenumn",
140        "libkmr_derive",
141    ],
142    prefer_rlib: true,
143    no_stdlibs: true,
144    stdlibs: [
145        "libcompiler_builtins.rust_sysroot",
146        "libcore.rust_sysroot",
147    ],
148}
149
150rust_test_host {
151    name: "libkmr_wire_test",
152    crate_name: "kmr_wire_test",
153    srcs: ["src/lib.rs"],
154    rustlibs: [
155        "libciborium",
156        "libciborium_io",
157        "libcoset",
158        "libhex",
159        "liblog_rust",
160        "libzeroize",
161    ],
162    proc_macros: [
163        "libenumn",
164        "libkmr_derive",
165    ],
166    test_suites: ["general-tests"],
167}
168
169rust_fuzz {
170    name: "libkmr_wire_fuzz_message",
171    srcs: ["fuzz/fuzz_targets/message.rs"],
172    rustlibs: ["libkmr_wire"],
173    host_supported: true,
174    fuzz_config: {
175        cc: [
176            "[email protected]",
177            "[email protected]",
178        ],
179        componentid: 1084733,
180        hotlists: ["4271696"],
181        fuzz_on_haiku_device: true,
182        fuzz_on_haiku_host: true,
183    },
184}
185
186rust_fuzz {
187    name: "libkmr_wire_fuzz_legacy_message",
188    srcs: ["fuzz/fuzz_targets/legacy_message.rs"],
189    rustlibs: ["libkmr_wire"],
190    host_supported: true,
191    fuzz_config: {
192        cc: [
193            "[email protected]",
194            "[email protected]",
195        ],
196        componentid: 1084733,
197        hotlists: ["4271696"],
198        fuzz_on_haiku_device: true,
199        fuzz_on_haiku_host: true,
200    },
201}
202