xref: /aosp_15_r20/external/crosvm/Android.bp (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1// This file is generated by cargo_embargo.
2// Do not modify this file after the first "rust_*" or "genrule" module
3// because the changes will be overridden on upgrade.
4// Content before the first "rust_*" or "genrule" module is preserved.
5
6package {
7    default_applicable_licenses: ["external_crosvm_license"],
8}
9
10// Added automatically by a large-scale-change that took the approach of
11// 'apply every license found to every target'. While this makes sure we respect
12// every license restriction, it may not be entirely correct.
13//
14// e.g. GPL in an MIT project might only apply to the contrib/ directory.
15//
16// Please consider splitting the single license below into multiple licenses,
17// taking care not to lose any license_kind information, and overriding the
18// default license using the 'licenses: [...]' property on targets as needed.
19//
20// For unused files, consider creating a 'fileGroup' with "//visibility:private"
21// to attach the license to, and including a comment whether the files may be
22// used in the current project.
23// See: http://go/android-license-faq
24license {
25    name: "external_crosvm_license",
26    visibility: [":__subpackages__"],
27    license_kinds: [
28        "SPDX-license-identifier-Apache-2.0",
29        "SPDX-license-identifier-BSD",
30        "SPDX-license-identifier-MIT",
31    ],
32    license_text: [
33        "LICENSE",
34    ],
35}
36
37rust_binary {
38    name: "crosvm",
39    defaults: ["crosvm_inner_defaults"],
40    host_supported: true,
41    prefer_rlib: true,
42    crate_name: "crosvm",
43    cargo_env_compat: true,
44    cargo_pkg_version: "0.1.0",
45    crate_root: "src/main.rs",
46    edition: "2021",
47    features: [
48        "android-sparse",
49        "android_display",
50        "android_display_stub",
51        "audio",
52        "audio_aaudio",
53        "balloon",
54        "config-file",
55        "fs_runtime_ugid_map",
56        "gdb",
57        "gdbstub",
58        "gdbstub_arch",
59        "geniezone",
60        "gfxstream",
61        "gpu",
62        "gpu_display",
63        "gunyah",
64        "libaaudio_stub",
65        "net",
66        "qcow",
67        "usb",
68        "virgl_renderer",
69    ],
70    rustlibs: [
71        "libacpi_tables",
72        "libandroid_audio",
73        "libanyhow",
74        "libarch",
75        "libargh",
76        "libaudio_streams",
77        "libbase_rust",
78        "libbit_field_crosvm",
79        "libbroker_ipc",
80        "libcfg_if",
81        "libcros_async",
82        "libcros_tracing",
83        "libcrosvm_cli",
84        "libdevices",
85        "libdisk",
86        "libext2",
87        "libgdbstub",
88        "libgdbstub_arch",
89        "libhypervisor",
90        "libjail",
91        "libkernel_cmdline",
92        "libkernel_loader",
93        "liblibc",
94        "liblibcras",
95        "liblog_rust",
96        "libmerge",
97        "libmetrics",
98        "libmetrics_events",
99        "libminijail_rust",
100        "libnet_util",
101        "libonce_cell",
102        "libp9",
103        "libresources",
104        "librutabaga_gfx",
105        "libserde",
106        "libserde_json",
107        "libserde_keyvalue",
108        "libsmallvec",
109        "libstatic_assertions",
110        "libswap",
111        "libsync_rust",
112        "libthiserror",
113        "libuuid",
114        "libvhost",
115        "libvm_control",
116        "libvm_memory",
117        "libvmm_vhost",
118        "libzerocopy",
119    ],
120    proc_macros: [
121        "libargh_helpers",
122        "libenumn",
123        "libremain",
124    ],
125    visibility: ["//visibility:public"],
126    arch: {
127        x86_64: {
128            rustlibs: ["libx86_64_rust"],
129        },
130        arm64: {
131            rustlibs: ["libaarch64"],
132        },
133        riscv64: {
134            rustlibs: ["libriscv64"],
135        },
136    },
137    target: {
138        host: {
139            strip: {
140                keep_symbols_and_debug_frame: true,
141            },
142        },
143        android: {
144            shared_libs: [
145                // TODO(b/332677108): remove libc++ when display service is rewritten in rust.
146                "libc++",
147                "libbinder_ndk",
148                "libnativewindow",
149                "libprocessgroup",
150            ],
151        },
152        host_linux: {
153            shared_libs: [
154                "libprocessgroup",
155            ],
156        },
157        linux_bionic_arm64: {
158            relative_install_path: "aarch64-linux-bionic",
159        },
160        linux_glibc_x86_64: {
161            relative_install_path: "x86_64-linux-gnu",
162        },
163        linux_musl_x86_64: {
164            relative_install_path: "x86_64-linux-musl",
165        },
166        linux_musl_arm64: {
167            relative_install_path: "aarch64-linux-musl",
168        },
169    },
170    ld_flags: [
171        "-Wl,--rpath,\\$$ORIGIN",
172        "-Wl,--rpath,\\$$ORIGIN/../../lib64",
173    ],
174
175}
176
177rust_test {
178    name: "crosvm_test_src_main",
179    defaults: ["crosvm_inner_defaults"],
180    host_supported: true,
181    crate_name: "crosvm",
182    cargo_env_compat: true,
183    cargo_pkg_version: "0.1.0",
184    crate_root: "src/main.rs",
185    test_suites: ["general-tests"],
186    auto_gen_config: true,
187    test_options: {
188        unit_test: false,
189    },
190    edition: "2021",
191    features: [
192        "android-sparse",
193        "android_display",
194        "android_display_stub",
195        "audio",
196        "audio_aaudio",
197        "balloon",
198        "config-file",
199        "fs_runtime_ugid_map",
200        "gdb",
201        "gdbstub",
202        "gdbstub_arch",
203        "geniezone",
204        "gfxstream",
205        "gpu",
206        "gpu_display",
207        "gunyah",
208        "libaaudio_stub",
209        "net",
210        "qcow",
211        "usb",
212        "virgl_renderer",
213    ],
214    rustlibs: [
215        "libacpi_tables",
216        "libandroid_audio",
217        "libanyhow",
218        "libarch",
219        "libargh",
220        "libaudio_streams",
221        "libbase_rust",
222        "libbit_field_crosvm",
223        "libbroker_ipc",
224        "libcfg_if",
225        "libcros_async",
226        "libcros_tracing",
227        "libcrosvm_cli",
228        "libdevices",
229        "libdisk",
230        "libext2",
231        "libgdbstub",
232        "libgdbstub_arch",
233        "libhypervisor",
234        "libjail",
235        "libkernel_cmdline",
236        "libkernel_loader",
237        "liblibc",
238        "liblibcras",
239        "liblog_rust",
240        "libmerge",
241        "libmetrics",
242        "libmetrics_events",
243        "libminijail_rust",
244        "libnet_util",
245        "libonce_cell",
246        "libp9",
247        "librand",
248        "libresources",
249        "librutabaga_gfx",
250        "libserde",
251        "libserde_json",
252        "libserde_keyvalue",
253        "libsmallvec",
254        "libstatic_assertions",
255        "libswap",
256        "libsync_rust",
257        "libtempfile",
258        "libthiserror",
259        "libuuid",
260        "libvhost",
261        "libvm_control",
262        "libvm_memory",
263        "libvmm_vhost",
264        "libzerocopy",
265    ],
266    proc_macros: [
267        "libargh_helpers",
268        "libenumn",
269        "libremain",
270    ],
271    arch: {
272        x86_64: {
273            rustlibs: ["libx86_64_rust"],
274        },
275        arm64: {
276            rustlibs: ["libaarch64"],
277        },
278        riscv64: {
279            rustlibs: ["libriscv64"],
280        },
281    },
282    target: {
283        host: {
284            strip: {
285                keep_symbols_and_debug_frame: true,
286            },
287        },
288        android: {
289            shared_libs: [
290                "libprocessgroup",
291            ],
292        },
293        host_linux: {
294            shared_libs: [
295                "libprocessgroup",
296            ],
297        },
298    },
299    ld_flags: [
300        "-Wl,--rpath,\\$$ORIGIN",
301        "-Wl,--rpath,\\$$ORIGIN/../../lib64",
302    ],
303
304}
305
306rust_defaults {
307    name: "crosvm_defaults",
308    edition: "2018",
309    enabled: false,
310    target: {
311        linux_glibc_x86_64: {
312            enabled: true,
313        },
314        linux_musl_x86_64: {
315            enabled: true,
316        },
317        android64: {
318            compile_multilib: "64",
319            enabled: true,
320        },
321        linux_bionic_arm64: {
322            enabled: true,
323        },
324        linux_musl_arm64: {
325            enabled: true,
326        },
327        darwin: {
328            enabled: false,
329        },
330    },
331    apex_available: [
332        "com.android.virt",
333    ],
334    defaults_visibility: [
335        "//external/crosvm:__subpackages__",
336        "//packages/modules/Virtualization/guest/authfs",
337        "//packages/modules/Virtualization/tests/authfs",
338        // For QCOM's crosvm fork.
339        "//vendor:__subpackages__",
340    ],
341}
342
343// "crosvm_defaults" is being used outside of external/crosvm, so we need a
344// layer of indirection to add options that would break those users.
345//
346// TODO(b/238324526): move others off of "crosvm_defaults"
347rust_defaults {
348    name: "crosvm_inner_defaults",
349    defaults: ["crosvm_defaults"],
350    defaults_visibility: ["//external/crosvm:__subpackages__"],
351    visibility: ["//external/crosvm:__subpackages__"],
352}
353