blob: 0d991132656479b2989e95a93ec566c14b036b4c [file] [log] [blame]
Alice Wangfb46ee12022-09-30 13:08:52 +00001package {
2 default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
Alan Stokesbcc2ec22022-10-31 17:02:50 +00005// The Rust implementation of the C API.
Ivan Lozano5441d7a2025-02-03 08:50:19 -08006rust_ffi {
7 name: "libvm_payload",
Alice Wangfb46ee12022-09-30 13:08:52 +00008 crate_name: "vm_payload",
Nikita Ioffeda1b2732023-09-04 13:46:56 +01009 defaults: ["avf_build_flags_rust"],
Alan Stokesf7601962023-11-09 14:28:40 +000010 srcs: ["src/lib.rs"],
Alice Wangfb46ee12022-09-30 13:08:52 +000011 include_dirs: ["include"],
12 prefer_rlib: true,
13 rustlibs: [
Alice Wang59a9e562022-10-04 15:24:10 +000014 "android.system.virtualization.payload-rust",
Alice Wangfb46ee12022-09-30 13:08:52 +000015 "libandroid_logger",
16 "libanyhow",
17 "libbinder_rs",
David Brazdil451cc962022-10-14 14:08:12 +010018 "liblibc",
Alice Wangfb46ee12022-09-30 13:08:52 +000019 "liblog_rust",
Alice Wang4e3015d2023-10-10 09:35:37 +000020 "libopenssl",
Alice Wang2be64f32022-10-13 14:37:35 +000021 "librpcbinder_rs",
Alice Wang4e3015d2023-10-10 09:35:37 +000022 "libvm_payload_status_bindgen",
David Brazdil73988ea2022-11-11 15:10:32 +000023 "libvsock",
Alice Wangfb46ee12022-09-30 13:08:52 +000024 ],
Ivan Lozano5441d7a2025-02-03 08:50:19 -080025 shared_libs: [
26 "libbinder_ndk",
27 "libbinder_rpc_unstable",
28 "liblog",
29 "libcrypto",
30 ],
31 no_full_install: true,
32 version_script: "libvm_payload.map.txt",
33 stubs: {
34 symbol_file: "libvm_payload.map.txt",
35 // Implementation is available inside a Microdroid VM.
36 implementation_installable: false,
37 },
38 visibility: ["//visibility:public"],
Alice Wangfb46ee12022-09-30 13:08:52 +000039}
Alice Wangbd569a02022-10-06 15:23:24 +000040
Alice Wang4e3015d2023-10-10 09:35:37 +000041rust_bindgen {
42 name: "libvm_payload_status_bindgen",
43 wrapper_src: "include/vm_payload.h",
44 crate_name: "vm_payload_status_bindgen",
45 defaults: ["avf_build_flags_rust"],
46 source_stem: "bindings",
47 bindgen_flags: [
48 "--default-enum-style rust",
Alice Wang1715f372024-02-14 10:51:52 +000049 "--allowlist-type=AVmAttestationStatus",
Shikha Panwar0c3a2fa2024-12-06 18:38:06 +000050 "--allowlist-type=AVmAccessRollbackProtectedSecretStatus",
Alice Wang4e3015d2023-10-10 09:35:37 +000051 ],
52 visibility: [":__subpackages__"],
53}
54
Alan Stokes9fd57b02024-05-28 09:50:22 +010055// Access to the C API for Rust code.
56// This shouldn't be used directly - prefer libvm_payload_rs (below)
Alice Wangbd569a02022-10-06 15:23:24 +000057rust_bindgen {
58 name: "libvm_payload_bindgen",
Alan Stokesd4ea5a82022-11-10 12:17:42 +000059 wrapper_src: "include-restricted/vm_payload_restricted.h",
Alice Wangbd569a02022-10-06 15:23:24 +000060 crate_name: "vm_payload_bindgen",
Nikita Ioffeda1b2732023-09-04 13:46:56 +010061 defaults: ["avf_build_flags_rust"],
Alice Wangbd569a02022-10-06 15:23:24 +000062 source_stem: "bindings",
63 apex_available: ["com.android.compos"],
Alice Wang4e3015d2023-10-10 09:35:37 +000064 bindgen_flags: [
65 "--default-enum-style rust",
66 ],
Alice Wangbd569a02022-10-06 15:23:24 +000067 shared_libs: [
Alan Stokesbcc2ec22022-10-31 17:02:50 +000068 "libvm_payload#current",
Alice Wangbd569a02022-10-06 15:23:24 +000069 ],
70}
Alan Stokes52d3c722022-10-04 17:27:13 +010071
Alan Stokes9fd57b02024-05-28 09:50:22 +010072// Wrapper library for the raw C API for use by Rust clients.
73// (Yes, this involves going Rust -> C -> Rust.)
74// This is not a stable API - we may change it in subsequent versions.
75// But it is made available as an rlib so it is linked into any
76// code using it, leaving only dependencies on stable APIs.
77// So code built with it should run unchanged on future versions.
78rust_library_rlib {
79 name: "libvm_payload_rs",
80 crate_name: "vm_payload",
81 defaults: ["avf_build_flags_rust"],
82 srcs: ["wrapper/lib.rs"],
83 rustlibs: [
84 "libbinder_rs",
85 "libstatic_assertions",
86 "libvm_payload_bindgen",
87 ],
88 apex_available: ["com.android.compos"],
89 visibility: ["//visibility:public"],
90}
91
Alan Stokesbcc2ec22022-10-31 17:02:50 +000092// Just the headers. Mostly useful for clients that only want the
93// declaration of AVmPayload_main().
Alan Stokes52d3c722022-10-04 17:27:13 +010094cc_library_headers {
95 name: "vm_payload_headers",
Nikita Ioffe38b9e712024-02-08 15:55:07 +000096 defaults: ["avf_build_flags_cc"],
Alan Stokesd4ea5a82022-11-10 12:17:42 +000097 apex_available: ["com.android.compos"],
Alan Stokes52d3c722022-10-04 17:27:13 +010098 export_include_dirs: ["include"],
Alan Stokesf5fc5f72024-05-15 15:06:10 +010099 visibility: ["//visibility:public"],
Alan Stokes52d3c722022-10-04 17:27:13 +0100100}
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000101
Alan Stokesbcc2ec22022-10-31 17:02:50 +0000102// Restricted headers for use by internal clients & associated tests.
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000103cc_library_headers {
104 name: "vm_payload_restricted_headers",
Nikita Ioffe38b9e712024-02-08 15:55:07 +0000105 defaults: ["avf_build_flags_cc"],
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000106 header_libs: ["vm_payload_headers"],
107 export_header_lib_headers: ["vm_payload_headers"],
108 export_include_dirs: ["include-restricted"],
109 apex_available: ["com.android.compos"],
110 visibility: ["//packages/modules/Virtualization:__subpackages__"],
111}