Alice Wang | fb46ee1 | 2022-09-30 13:08:52 +0000 | [diff] [blame] | 1 | package { |
| 2 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 3 | } |
| 4 | |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 5 | // The Rust implementation of the C API. |
| 6 | rust_ffi_static { |
| 7 | name: "libvm_payload_impl", |
Alice Wang | fb46ee1 | 2022-09-30 13:08:52 +0000 | [diff] [blame] | 8 | crate_name: "vm_payload", |
Nikita Ioffe | da1b273 | 2023-09-04 13:46:56 +0100 | [diff] [blame] | 9 | defaults: ["avf_build_flags_rust"], |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 10 | visibility: ["//visibility:private"], |
Alan Stokes | f760196 | 2023-11-09 14:28:40 +0000 | [diff] [blame] | 11 | srcs: ["src/lib.rs"], |
Alice Wang | fb46ee1 | 2022-09-30 13:08:52 +0000 | [diff] [blame] | 12 | include_dirs: ["include"], |
| 13 | prefer_rlib: true, |
| 14 | rustlibs: [ |
Alice Wang | 59a9e56 | 2022-10-04 15:24:10 +0000 | [diff] [blame] | 15 | "android.system.virtualization.payload-rust", |
Alice Wang | fb46ee1 | 2022-09-30 13:08:52 +0000 | [diff] [blame] | 16 | "libandroid_logger", |
| 17 | "libanyhow", |
| 18 | "libbinder_rs", |
Alice Wang | 6bbb6da | 2022-10-26 12:44:06 +0000 | [diff] [blame] | 19 | "liblazy_static", |
David Brazdil | 451cc96 | 2022-10-14 14:08:12 +0100 | [diff] [blame] | 20 | "liblibc", |
Alice Wang | fb46ee1 | 2022-09-30 13:08:52 +0000 | [diff] [blame] | 21 | "liblog_rust", |
Alice Wang | 4e3015d | 2023-10-10 09:35:37 +0000 | [diff] [blame] | 22 | "libopenssl", |
Alice Wang | 2be64f3 | 2022-10-13 14:37:35 +0000 | [diff] [blame] | 23 | "librpcbinder_rs", |
Alice Wang | 4e3015d | 2023-10-10 09:35:37 +0000 | [diff] [blame] | 24 | "libvm_payload_status_bindgen", |
David Brazdil | 73988ea | 2022-11-11 15:10:32 +0000 | [diff] [blame] | 25 | "libvsock", |
Alice Wang | fb46ee1 | 2022-09-30 13:08:52 +0000 | [diff] [blame] | 26 | ], |
Alice Wang | fb46ee1 | 2022-09-30 13:08:52 +0000 | [diff] [blame] | 27 | } |
Alice Wang | bd569a0 | 2022-10-06 15:23:24 +0000 | [diff] [blame] | 28 | |
Alice Wang | 4e3015d | 2023-10-10 09:35:37 +0000 | [diff] [blame] | 29 | rust_bindgen { |
| 30 | name: "libvm_payload_status_bindgen", |
| 31 | wrapper_src: "include/vm_payload.h", |
| 32 | crate_name: "vm_payload_status_bindgen", |
| 33 | defaults: ["avf_build_flags_rust"], |
| 34 | source_stem: "bindings", |
| 35 | bindgen_flags: [ |
| 36 | "--default-enum-style rust", |
Alice Wang | 1715f37 | 2024-02-14 10:51:52 +0000 | [diff] [blame] | 37 | "--allowlist-type=AVmAttestationStatus", |
Alice Wang | 4e3015d | 2023-10-10 09:35:37 +0000 | [diff] [blame] | 38 | ], |
| 39 | visibility: [":__subpackages__"], |
| 40 | } |
| 41 | |
Alan Stokes | 9fd57b0 | 2024-05-28 09:50:22 +0100 | [diff] [blame^] | 42 | // Access to the C API for Rust code. |
| 43 | // This shouldn't be used directly - prefer libvm_payload_rs (below) |
Alice Wang | bd569a0 | 2022-10-06 15:23:24 +0000 | [diff] [blame] | 44 | rust_bindgen { |
| 45 | name: "libvm_payload_bindgen", |
Alan Stokes | d4ea5a8 | 2022-11-10 12:17:42 +0000 | [diff] [blame] | 46 | wrapper_src: "include-restricted/vm_payload_restricted.h", |
Alice Wang | bd569a0 | 2022-10-06 15:23:24 +0000 | [diff] [blame] | 47 | crate_name: "vm_payload_bindgen", |
Nikita Ioffe | da1b273 | 2023-09-04 13:46:56 +0100 | [diff] [blame] | 48 | defaults: ["avf_build_flags_rust"], |
Alice Wang | bd569a0 | 2022-10-06 15:23:24 +0000 | [diff] [blame] | 49 | source_stem: "bindings", |
| 50 | apex_available: ["com.android.compos"], |
Alice Wang | 4e3015d | 2023-10-10 09:35:37 +0000 | [diff] [blame] | 51 | bindgen_flags: [ |
| 52 | "--default-enum-style rust", |
| 53 | ], |
Alice Wang | bd569a0 | 2022-10-06 15:23:24 +0000 | [diff] [blame] | 54 | shared_libs: [ |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 55 | "libvm_payload#current", |
Alice Wang | bd569a0 | 2022-10-06 15:23:24 +0000 | [diff] [blame] | 56 | ], |
| 57 | } |
Alan Stokes | 52d3c72 | 2022-10-04 17:27:13 +0100 | [diff] [blame] | 58 | |
Alan Stokes | 9fd57b0 | 2024-05-28 09:50:22 +0100 | [diff] [blame^] | 59 | // 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. |
| 65 | rust_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 | |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 79 | // Shared library for clients to link against. |
| 80 | cc_library_shared { |
| 81 | name: "libvm_payload", |
Nikita Ioffe | 38b9e71 | 2024-02-08 15:55:07 +0000 | [diff] [blame] | 82 | defaults: ["avf_build_flags_cc"], |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 83 | shared_libs: [ |
| 84 | "libbinder_ndk", |
| 85 | "libbinder_rpc_unstable", |
| 86 | "liblog", |
Alice Wang | 4e3015d | 2023-10-10 09:35:37 +0000 | [diff] [blame] | 87 | "libcrypto", |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 88 | ], |
| 89 | whole_static_libs: ["libvm_payload_impl"], |
| 90 | export_static_lib_headers: ["libvm_payload_impl"], |
Jiyong Park | 5f939f9 | 2024-05-01 16:18:14 +0900 | [diff] [blame] | 91 | no_full_install: true, |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 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 | }, |
Alan Stokes | f5fc5f7 | 2024-05-15 15:06:10 +0100 | [diff] [blame] | 98 | visibility: ["//visibility:public"], |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | // Just the headers. Mostly useful for clients that only want the |
| 102 | // declaration of AVmPayload_main(). |
Alan Stokes | 52d3c72 | 2022-10-04 17:27:13 +0100 | [diff] [blame] | 103 | cc_library_headers { |
| 104 | name: "vm_payload_headers", |
Nikita Ioffe | 38b9e71 | 2024-02-08 15:55:07 +0000 | [diff] [blame] | 105 | defaults: ["avf_build_flags_cc"], |
Alan Stokes | d4ea5a8 | 2022-11-10 12:17:42 +0000 | [diff] [blame] | 106 | apex_available: ["com.android.compos"], |
Alan Stokes | 52d3c72 | 2022-10-04 17:27:13 +0100 | [diff] [blame] | 107 | export_include_dirs: ["include"], |
Alan Stokes | f5fc5f7 | 2024-05-15 15:06:10 +0100 | [diff] [blame] | 108 | visibility: ["//visibility:public"], |
Alan Stokes | 52d3c72 | 2022-10-04 17:27:13 +0100 | [diff] [blame] | 109 | } |
Alan Stokes | d4ea5a8 | 2022-11-10 12:17:42 +0000 | [diff] [blame] | 110 | |
Alan Stokes | bcc2ec2 | 2022-10-31 17:02:50 +0000 | [diff] [blame] | 111 | // Restricted headers for use by internal clients & associated tests. |
Alan Stokes | d4ea5a8 | 2022-11-10 12:17:42 +0000 | [diff] [blame] | 112 | cc_library_headers { |
| 113 | name: "vm_payload_restricted_headers", |
Nikita Ioffe | 38b9e71 | 2024-02-08 15:55:07 +0000 | [diff] [blame] | 114 | defaults: ["avf_build_flags_cc"], |
Alan Stokes | d4ea5a8 | 2022-11-10 12:17:42 +0000 | [diff] [blame] | 115 | 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 | } |