blob: 1ebbe396ec69b83ed31f4c157d23706ab15f19bf [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.
ELIYAZ MOMINca685fb2025-01-31 07:14:29 -08006rust_ffi_static {
7 name: "libvm_payload_impl",
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"],
ELIYAZ MOMINca685fb2025-01-31 07:14:29 -080010 visibility: ["//visibility:private"],
Alan Stokesf7601962023-11-09 14:28:40 +000011 srcs: ["src/lib.rs"],
Alice Wangfb46ee12022-09-30 13:08:52 +000012 include_dirs: ["include"],
13 prefer_rlib: true,
14 rustlibs: [
Alice Wang59a9e562022-10-04 15:24:10 +000015 "android.system.virtualization.payload-rust",
Alice Wangfb46ee12022-09-30 13:08:52 +000016 "libandroid_logger",
17 "libanyhow",
18 "libbinder_rs",
David Brazdil451cc962022-10-14 14:08:12 +010019 "liblibc",
Alice Wangfb46ee12022-09-30 13:08:52 +000020 "liblog_rust",
Alice Wang4e3015d2023-10-10 09:35:37 +000021 "libopenssl",
Alice Wang2be64f32022-10-13 14:37:35 +000022 "librpcbinder_rs",
Alice Wang4e3015d2023-10-10 09:35:37 +000023 "libvm_payload_status_bindgen",
David Brazdil73988ea2022-11-11 15:10:32 +000024 "libvsock",
Alice Wangfb46ee12022-09-30 13:08:52 +000025 ],
Alice Wangfb46ee12022-09-30 13:08:52 +000026}
Alice Wangbd569a02022-10-06 15:23:24 +000027
Alice Wang4e3015d2023-10-10 09:35:37 +000028rust_bindgen {
29 name: "libvm_payload_status_bindgen",
30 wrapper_src: "include/vm_payload.h",
31 crate_name: "vm_payload_status_bindgen",
32 defaults: ["avf_build_flags_rust"],
33 source_stem: "bindings",
34 bindgen_flags: [
35 "--default-enum-style rust",
Alice Wang1715f372024-02-14 10:51:52 +000036 "--allowlist-type=AVmAttestationStatus",
Shikha Panwar0c3a2fa2024-12-06 18:38:06 +000037 "--allowlist-type=AVmAccessRollbackProtectedSecretStatus",
Alice Wang4e3015d2023-10-10 09:35:37 +000038 ],
39 visibility: [":__subpackages__"],
40}
41
Alan Stokes9fd57b02024-05-28 09:50:22 +010042// Access to the C API for Rust code.
43// This shouldn't be used directly - prefer libvm_payload_rs (below)
Alice Wangbd569a02022-10-06 15:23:24 +000044rust_bindgen {
45 name: "libvm_payload_bindgen",
Alan Stokesd4ea5a82022-11-10 12:17:42 +000046 wrapper_src: "include-restricted/vm_payload_restricted.h",
Alice Wangbd569a02022-10-06 15:23:24 +000047 crate_name: "vm_payload_bindgen",
Nikita Ioffeda1b2732023-09-04 13:46:56 +010048 defaults: ["avf_build_flags_rust"],
Alice Wangbd569a02022-10-06 15:23:24 +000049 source_stem: "bindings",
50 apex_available: ["com.android.compos"],
Alice Wang4e3015d2023-10-10 09:35:37 +000051 bindgen_flags: [
52 "--default-enum-style rust",
53 ],
Alice Wangbd569a02022-10-06 15:23:24 +000054 shared_libs: [
Alan Stokesbcc2ec22022-10-31 17:02:50 +000055 "libvm_payload#current",
Alice Wangbd569a02022-10-06 15:23:24 +000056 ],
57}
Alan Stokes52d3c722022-10-04 17:27:13 +010058
Alan Stokes9fd57b02024-05-28 09:50:22 +010059// Wrapper library for the raw C API for use by Rust clients.
60// (Yes, this involves going Rust -> C -> Rust.)
61// This is not a stable API - we may change it in subsequent versions.
62// But it is made available as an rlib so it is linked into any
63// code using it, leaving only dependencies on stable APIs.
64// So code built with it should run unchanged on future versions.
65rust_library_rlib {
66 name: "libvm_payload_rs",
67 crate_name: "vm_payload",
68 defaults: ["avf_build_flags_rust"],
69 srcs: ["wrapper/lib.rs"],
70 rustlibs: [
71 "libbinder_rs",
72 "libstatic_assertions",
73 "libvm_payload_bindgen",
74 ],
75 apex_available: ["com.android.compos"],
76 visibility: ["//visibility:public"],
77}
78
ELIYAZ MOMINca685fb2025-01-31 07:14:29 -080079// Shared library for clients to link against.
80cc_library_shared {
81 name: "libvm_payload",
82 defaults: ["avf_build_flags_cc"],
83 shared_libs: [
84 "libbinder_ndk",
85 "libbinder_rpc_unstable",
86 "liblog",
87 "libcrypto",
88 ],
89 whole_static_libs: ["libvm_payload_impl"],
90 export_static_lib_headers: ["libvm_payload_impl"],
91 no_full_install: true,
92 version_script: "libvm_payload.map.txt",
93 stubs: {
94 symbol_file: "libvm_payload.map.txt",
95 // Implementation is available inside a Microdroid VM.
96 implementation_installable: false,
97 },
98 visibility: ["//visibility:public"],
99}
100
Alan Stokesbcc2ec22022-10-31 17:02:50 +0000101// Just the headers. Mostly useful for clients that only want the
102// declaration of AVmPayload_main().
Alan Stokes52d3c722022-10-04 17:27:13 +0100103cc_library_headers {
104 name: "vm_payload_headers",
Nikita Ioffe38b9e712024-02-08 15:55:07 +0000105 defaults: ["avf_build_flags_cc"],
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000106 apex_available: ["com.android.compos"],
Alan Stokes52d3c722022-10-04 17:27:13 +0100107 export_include_dirs: ["include"],
Alan Stokesf5fc5f72024-05-15 15:06:10 +0100108 visibility: ["//visibility:public"],
Alan Stokes52d3c722022-10-04 17:27:13 +0100109}
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000110
Alan Stokesbcc2ec22022-10-31 17:02:50 +0000111// Restricted headers for use by internal clients & associated tests.
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000112cc_library_headers {
113 name: "vm_payload_restricted_headers",
Nikita Ioffe38b9e712024-02-08 15:55:07 +0000114 defaults: ["avf_build_flags_cc"],
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000115 header_libs: ["vm_payload_headers"],
116 export_header_lib_headers: ["vm_payload_headers"],
117 export_include_dirs: ["include-restricted"],
118 apex_available: ["com.android.compos"],
119 visibility: ["//packages/modules/Virtualization:__subpackages__"],
120}