1package {
2    default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
5rust_ffi_static {
6    name: "librialto",
7    crate_name: "rialto",
8    srcs: ["src/main.rs"],
9    defaults: ["vmbase_ffi_defaults"],
10    rustlibs: [
11        "libaarch64_paging",
12        "libbssl_avf_nostd",
13        "libbssl_sys_nostd",
14        "libciborium_io_nostd",
15        "libciborium_nostd",
16        "libcstr",
17        "libdiced_open_dice_nostd",
18        "libfdtpci",
19        "liblibfdt",
20        "liblog_rust_nostd",
21        "libservice_vm_comm_nostd",
22        "libservice_vm_fake_chain_nostd",
23        "libservice_vm_requests_nostd",
24        "libtinyvec_nostd",
25        "libvirtio_drivers",
26        "libvmbase",
27    ],
28}
29
30cc_binary {
31    name: "rialto_elf",
32    stem: "rialto",
33    defaults: ["vmbase_elf_defaults"],
34    srcs: [
35        "idmap.S",
36    ],
37    static_libs: [
38        "librialto",
39    ],
40    linker_scripts: [
41        "image.ld",
42        ":vmbase_sections",
43    ],
44}
45
46raw_binary {
47    name: "rialto_unsigned",
48    src: ":rialto_elf",
49    enabled: false,
50    target: {
51        android_arm64: {
52            enabled: true,
53        },
54    },
55}
56
57// python -c "import hashlib; print(hashlib.sha256(b'rialto_salt').hexdigest())"
58rialto_salt = "ea9d8c3ae1785396884d0c16c7652921874e2b8703f336ff23760f2049ee9e29"
59
60filegroup {
61    name: "rialto_sign_key",
62    srcs: [":avb_testkey_rsa4096"],
63}
64
65// Both SERVICE_VM_VERSION and SERVICE_VM_VERSION_STRING should represent the
66// same version number for the service VM.
67SERVICE_VM_VERSION = 1
68SERVICE_VM_VERSION_STRING = "1"
69
70genrule {
71    name: "service_vm_version_rs",
72    out: ["lib.rs"],
73    cmd: "(" +
74        "    echo '#![no_std]';" +
75        "    echo '#![allow(missing_docs)]';" +
76        "    echo 'pub const VERSION: u64 = " + SERVICE_VM_VERSION_STRING + ";'" +
77        ") > $(out)",
78}
79
80rust_library_rlib {
81    name: "libservice_vm_version",
82    crate_name: "service_vm_version",
83    defaults: ["vmbase_rlib_defaults"],
84    srcs: [":service_vm_version_rs"],
85}
86
87avb_add_hash_footer {
88    name: "rialto_signed",
89    src: ":empty_file",
90    filename: "rialto",
91    partition_name: "boot",
92    private_key: ":rialto_sign_key",
93    salt: rialto_salt,
94    rollback_index: SERVICE_VM_VERSION,
95    props: [
96        {
97            name: "com.android.virt.cap",
98            value: "remote_attest",
99        },
100    ],
101    enabled: false,
102    arch: {
103        arm64: {
104            src: ":rialto_unsigned",
105            enabled: true,
106        },
107    },
108}
109
110prebuilt_etc {
111    // rialto_bin is a prebuilt target wrapping the signed bare-metal service VM.
112    name: "rialto_bin",
113    filename: "rialto.bin",
114    target: {
115        android_arm64: {
116            src: ":rialto_signed",
117        },
118    },
119    src: ":empty_file",
120    installable: false,
121}
122
123rust_test {
124    name: "rialto_test",
125    crate_name: "rialto_test",
126    defaults: ["avf_build_flags_rust"],
127    srcs: ["tests/test.rs"],
128    prefer_rlib: true,
129    edition: "2021",
130    rustlibs: [
131        "android.system.virtualizationservice-rust",
132        "libandroid_logger",
133        "libanyhow",
134        "libbssl_avf_nostd",
135        "libclient_vm_csr",
136        "libcoset",
137        "liblibc",
138        "liblog_rust",
139        "libhwtrust",
140        "libservice_vm_comm",
141        "libservice_vm_fake_chain",
142        "libservice_vm_manager",
143        "libvmclient",
144        "libx509_cert_nostd",
145    ],
146    data: [
147        ":rialto_unsigned",
148        ":test_rkp_cert_chain",
149    ],
150    test_suites: ["general-tests"],
151    enabled: false,
152    target: {
153        android_arm64: {
154            enabled: true,
155        },
156    },
157}
158