blob: 2416714b631e210adc82e4f7a159828cc69b5b17 [file] [log] [blame]
Bob Badoure8af2842022-04-07 10:44:22 -07001package {
2 default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
Andrew Walbran68a8c162022-03-07 15:38:42 +00005rust_ffi_static {
6 name: "libpvmfw",
7 crate_name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +01008 defaults: ["vmbase_ffi_defaults"],
Andrew Walbran68a8c162022-03-07 15:38:42 +00009 srcs: ["src/main.rs"],
10 edition: "2021",
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010011 features: [
12 "legacy",
13 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000014 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000015 "libaarch64_paging",
Pierre-Clément Tosi90cd4f12023-02-17 11:19:56 +000016 "libbssl_ffi_nostd",
Pierre-Clément Tosifc531152022-10-20 12:22:23 +010017 "libbuddy_system_allocator",
Alice Wangcb9d2f92023-02-06 10:29:00 +000018 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000019 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000020 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000021 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010022 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000023 "libonce_cell_nostd",
Andrew Walbran9afab672023-04-17 14:26:23 +000024 "libpsci",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000025 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010026 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090027 "libpvmfw_fdt_template",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000028 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000029 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000030 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000031 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000032 "libvmbase",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000033 "libzeroize_nostd",
Jakob Vukalovic85a00d72023-04-20 09:51:10 +010034 "libspin_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000035 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000036}
Andrew Walbran15068b02022-03-22 15:57:34 +000037
Alice Wang1c7e0eb2023-04-11 17:03:42 +000038// Generates an empty file.
39genrule {
40 name: "empty_file",
41 out: ["empty_file"],
42 cmd: "touch $(out)",
43}
44
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090045rust_test {
46 name: "libpvmfw.bootargs.test",
47 host_supported: true,
48 // For now, only bootargs.rs is written to be conditionally compiled with std.
49 srcs: ["src/bootargs.rs"],
50 test_suites: ["general-tests"],
51 test_options: {
52 unit_test: true,
53 },
54 rustlibs: [
55 "libzeroize",
56 ],
57}
58
Andrew Walbran15068b02022-03-22 15:57:34 +000059cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010060 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +010061 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +000062 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +000063 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +000064 ],
65 static_libs: [
66 "libpvmfw",
67 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +000068 linker_scripts: [
69 "image.ld",
70 ":vmbase_sections",
71 ],
Jiyong Park17b8d752022-12-16 14:36:24 +090072 // `installable: false` is inherited from vmbase_elf_defaults, and that
73 // hides this module from Make, which makes it impossible for the Make world
74 // to place the unstripped binary to the symbols directory. Marking back as
75 // installable exposes this module to the Make world again. Note that this
76 // module (pvmfw) still is NOT installed to any of the filesystem images. It
77 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
78 // partition image. This is just to package the unstripped file into the
79 // symbols zip file for debugging purpose.
80 installable: true,
Nikita Ioffe831b08b2023-03-13 21:18:40 +000081 native_coverage: false,
Andrew Walbran15068b02022-03-22 15:57:34 +000082}
David Brazdil05d4e072022-04-25 14:47:06 +010083
84raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010085 name: "pvmfw_bin",
86 stem: "pvmfw.bin",
87 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +010088 enabled: false,
89 target: {
90 android_arm64: {
91 enabled: true,
92 },
93 },
94}
David Brazdilac216b52022-04-25 15:07:22 +010095
Jaewan Kim2cf6f392023-02-10 01:35:47 +090096// Provide pvmfw.bin binary regardless of the architecture for building test.
97// Note that skipping tests on unsupported device is easy
98// while configuring server configuration to make such tests to run on working
99// devices.
100prebuilt_etc {
101 name: "pvmfw_test",
102 filename: "pvmfw_test.bin",
103 target: {
104 android_arm64: {
105 src: ":pvmfw_bin",
106 },
107 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000108 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900109 installable: false,
110}
111
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100112prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100113 name: "pvmfw_embedded_key",
114 src: ":avb_testkey_rsa4096_pub_bin",
115 installable: false,
116}
117
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100118genrule {
119 name: "pvmfw_embedded_key_rs",
120 srcs: [":pvmfw_embedded_key"],
121 out: ["lib.rs"],
122 cmd: "(" +
123 " echo '#![no_std]';" +
124 " echo '#![allow(missing_docs)]';" +
125 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
126 " xxd -i < $(in);" +
127 " echo '];';" +
128 ") > $(out)",
129}
130
131rust_library_rlib {
132 name: "libpvmfw_embedded_key",
133 defaults: ["vmbase_ffi_defaults"],
134 prefer_rlib: true,
135 srcs: [":pvmfw_embedded_key_rs"],
136 crate_name: "pvmfw_embedded_key",
137 apex_available: ["com.android.virt"],
138}
139
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100140prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100141 name: "pvmfw_sign_key",
142 src: ":avb_testkey_rsa4096",
143 installable: false,
144}
145
Jiyong Park216793e2023-02-25 02:15:44 +0900146// platform.dts is passed to clang for macro preprocessing, and then compiled to dtbo using dtc.
147// The raw content of the dtbo file is then written as a Rust byte array.
148genrule {
149 name: "pvmfw_fdt_template_rs",
150 srcs: [
151 "platform.dts",
152 ":arm_dt_bindings_headers", // implicit dependency
153 ],
154 out: ["lib.rs"],
155 tools: ["dtc"],
156 cmd: "prebuilts/clang/host/linux-x86/clang-r487747/bin/clang " + // UGLY!!!
157 "-E -P -x assembler-with-cpp -I external/arm-trusted-firmware/include " +
158 "-o $(genDir)/preprocessed.dts $(location platform.dts) && " +
159 "$(location dtc) -I dts -O dtb -o $(genDir)/compiled.dtbo $(genDir)/preprocessed.dts && " +
160 "(" +
161 " echo '#![no_std]';" +
162 " echo '#![allow(missing_docs)]';" +
163 " echo 'pub const RAW: &[u8] = &[';" +
164 " xxd -i < $(genDir)/compiled.dtbo;" +
165 " echo '];';" +
166 ") > $(out)",
167}
168
169rust_library_rlib {
170 name: "libpvmfw_fdt_template",
171 defaults: ["vmbase_ffi_defaults"],
172 prefer_rlib: true,
173 srcs: [":pvmfw_fdt_template_rs"],
174 crate_name: "pvmfw_fdt_template",
175}
176
David Brazdilac216b52022-04-25 15:07:22 +0100177bootimg {
178 name: "pvmfw_img",
179 stem: "pvmfw.img",
180 kernel_prebuilt: ":pvmfw_bin",
181 header_version: "3",
182 partition_name: "pvmfw",
183 enabled: false,
184 target: {
185 android_arm64: {
186 enabled: true,
187 },
188 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100189 use_avb: true,
190 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100191}