blob: bb917378f68f3a3f6b834469f221548ac0b2411b [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.
6rust_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"],
Alan Stokesbcc2ec22022-10-31 17:02:50 +000010 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",
Alice Wang4e3015d2023-10-10 09:35:37 +000037 ],
38 visibility: [":__subpackages__"],
39}
40
Alan Stokes9fd57b02024-05-28 09:50:22 +010041// Access to the C API for Rust code.
42// This shouldn't be used directly - prefer libvm_payload_rs (below)
Alice Wangbd569a02022-10-06 15:23:24 +000043rust_bindgen {
44 name: "libvm_payload_bindgen",
Alan Stokesd4ea5a82022-11-10 12:17:42 +000045 wrapper_src: "include-restricted/vm_payload_restricted.h",
Alice Wangbd569a02022-10-06 15:23:24 +000046 crate_name: "vm_payload_bindgen",
Nikita Ioffeda1b2732023-09-04 13:46:56 +010047 defaults: ["avf_build_flags_rust"],
Alice Wangbd569a02022-10-06 15:23:24 +000048 source_stem: "bindings",
49 apex_available: ["com.android.compos"],
Alice Wang4e3015d2023-10-10 09:35:37 +000050 bindgen_flags: [
51 "--default-enum-style rust",
52 ],
Alice Wangbd569a02022-10-06 15:23:24 +000053 shared_libs: [
Alan Stokesbcc2ec22022-10-31 17:02:50 +000054 "libvm_payload#current",
Alice Wangbd569a02022-10-06 15:23:24 +000055 ],
56}
Alan Stokes52d3c722022-10-04 17:27:13 +010057
Alan Stokes9fd57b02024-05-28 09:50:22 +010058// Wrapper library for the raw C API for use by Rust clients.
59// (Yes, this involves going Rust -> C -> Rust.)
60// This is not a stable API - we may change it in subsequent versions.
61// But it is made available as an rlib so it is linked into any
62// code using it, leaving only dependencies on stable APIs.
63// So code built with it should run unchanged on future versions.
64rust_library_rlib {
65 name: "libvm_payload_rs",
66 crate_name: "vm_payload",
67 defaults: ["avf_build_flags_rust"],
68 srcs: ["wrapper/lib.rs"],
69 rustlibs: [
70 "libbinder_rs",
71 "libstatic_assertions",
72 "libvm_payload_bindgen",
73 ],
74 apex_available: ["com.android.compos"],
75 visibility: ["//visibility:public"],
76}
77
Alan Stokesbcc2ec22022-10-31 17:02:50 +000078// Shared library for clients to link against.
79cc_library_shared {
80 name: "libvm_payload",
Nikita Ioffe38b9e712024-02-08 15:55:07 +000081 defaults: ["avf_build_flags_cc"],
Alan Stokesbcc2ec22022-10-31 17:02:50 +000082 shared_libs: [
83 "libbinder_ndk",
84 "libbinder_rpc_unstable",
85 "liblog",
Alice Wang4e3015d2023-10-10 09:35:37 +000086 "libcrypto",
Alan Stokesbcc2ec22022-10-31 17:02:50 +000087 ],
88 whole_static_libs: ["libvm_payload_impl"],
89 export_static_lib_headers: ["libvm_payload_impl"],
Jiyong Park5f939f92024-05-01 16:18:14 +090090 no_full_install: true,
Alan Stokesbcc2ec22022-10-31 17:02:50 +000091 version_script: "libvm_payload.map.txt",
92 stubs: {
93 symbol_file: "libvm_payload.map.txt",
94 // Implementation is available inside a Microdroid VM.
95 implementation_installable: false,
96 },
Alan Stokesf5fc5f72024-05-15 15:06:10 +010097 visibility: ["//visibility:public"],
Alan Stokesbcc2ec22022-10-31 17:02:50 +000098}
99
100// Just the headers. Mostly useful for clients that only want the
101// declaration of AVmPayload_main().
Alan Stokes52d3c722022-10-04 17:27:13 +0100102cc_library_headers {
103 name: "vm_payload_headers",
Nikita Ioffe38b9e712024-02-08 15:55:07 +0000104 defaults: ["avf_build_flags_cc"],
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000105 apex_available: ["com.android.compos"],
Alan Stokes52d3c722022-10-04 17:27:13 +0100106 export_include_dirs: ["include"],
Alan Stokesf5fc5f72024-05-15 15:06:10 +0100107 visibility: ["//visibility:public"],
Alan Stokes52d3c722022-10-04 17:27:13 +0100108}
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000109
Alan Stokesbcc2ec22022-10-31 17:02:50 +0000110// Restricted headers for use by internal clients & associated tests.
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000111cc_library_headers {
112 name: "vm_payload_restricted_headers",
Nikita Ioffe38b9e712024-02-08 15:55:07 +0000113 defaults: ["avf_build_flags_cc"],
Alan Stokesd4ea5a82022-11-10 12:17:42 +0000114 header_libs: ["vm_payload_headers"],
115 export_header_lib_headers: ["vm_payload_headers"],
116 export_include_dirs: ["include-restricted"],
117 apex_available: ["com.android.compos"],
118 visibility: ["//packages/modules/Virtualization:__subpackages__"],
119}