blob: b6f39402b923bc17508f02ebc1fbac63737b20ce [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"],
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010010 features: [
11 "legacy",
12 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000013 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000014 "libaarch64_paging",
Alice Wang947f3f72023-09-29 09:04:07 +000015 "libbssl_avf_nostd",
Pierre-Clément Tosi90cd4f12023-02-17 11:19:56 +000016 "libbssl_ffi_nostd",
Alan Stokesd1ee63e2023-04-24 16:17:39 +010017 "libciborium_nostd",
18 "libciborium_io_nostd",
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000019 "libcstr",
Alice Wangcb9d2f92023-02-06 10:29:00 +000020 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000021 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000022 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000023 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010024 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000025 "libonce_cell_nostd",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000026 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010027 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090028 "libpvmfw_fdt_template",
Andrew Walbranf44f1602023-05-30 14:59:19 +000029 "libsmccc",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000030 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000031 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000032 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000033 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000034 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010035 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000036 "libzeroize_nostd",
Jakob Vukalovic85a00d72023-04-20 09:51:10 +010037 "libspin_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000038 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000039}
Andrew Walbran15068b02022-03-22 15:57:34 +000040
Alice Wang1c7e0eb2023-04-11 17:03:42 +000041// Generates an empty file.
42genrule {
43 name: "empty_file",
44 out: ["empty_file"],
45 cmd: "touch $(out)",
46}
47
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090048rust_test {
49 name: "libpvmfw.bootargs.test",
50 host_supported: true,
51 // For now, only bootargs.rs is written to be conditionally compiled with std.
52 srcs: ["src/bootargs.rs"],
Nikita Ioffeda1b2732023-09-04 13:46:56 +010053 defaults: ["avf_build_flags_rust"],
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090054 test_suites: ["general-tests"],
55 test_options: {
56 unit_test: true,
57 },
58 rustlibs: [
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000059 "libcstr",
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090060 "libzeroize",
61 ],
62}
63
Jaewan Kimc6e023b2023-10-12 15:11:05 +090064genrule {
65 name: "test_pvmfw_devices_vm_dtbo",
66 defaults: ["dts_to_dtb"],
67 srcs: ["testdata/test_pvmfw_devices_vm_dtbo.dts"],
68 out: ["test_pvmfw_devices_vm_dtbo.dtbo"],
69}
70
71genrule {
72 name: "test_pvmfw_devices_vm_dtbo_without_symbols",
73 defaults: ["dts_to_dtb"],
74 srcs: ["testdata/test_pvmfw_devices_vm_dtbo_without_symbols.dts"],
75 out: ["test_pvmfw_devices_vm_dtbo_without_symbols.dtbo"],
76}
77
78genrule {
79 name: "test_pvmfw_devices_with_rng",
80 defaults: ["dts_to_dtb"],
81 srcs: ["testdata/test_pvmfw_devices_with_rng.dts"],
82 out: ["test_pvmfw_devices_with_rng.dtb"],
83}
84
85rust_test {
86 name: "libpvmfw.device_assignment.test",
87 srcs: ["src/device_assignment.rs"],
88 defaults: ["avf_build_flags_rust"],
89 test_suites: ["general-tests"],
90 test_options: {
91 unit_test: true,
92 },
93 prefer_rlib: true,
94 rustlibs: [
Pierre-Clément Tosi1bf532b2023-11-13 11:06:20 +000095 "libcstr",
Jaewan Kimc6e023b2023-10-12 15:11:05 +090096 "liblibfdt",
97 "liblog_rust",
98 "libpvmfw_fdt_template",
99 ],
100 data: [
101 ":test_pvmfw_devices_vm_dtbo",
102 ":test_pvmfw_devices_vm_dtbo_without_symbols",
103 ":test_pvmfw_devices_with_rng",
104 ],
105 // To use libpvmfw_fdt_template for testing
106 enabled: false,
107 target: {
108 android_arm64: {
109 enabled: true,
110 },
111 },
112}
113
Andrew Walbran15068b02022-03-22 15:57:34 +0000114cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100115 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +0100116 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +0000117 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +0000118 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +0000119 ],
120 static_libs: [
121 "libpvmfw",
122 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +0000123 linker_scripts: [
124 "image.ld",
125 ":vmbase_sections",
126 ],
Jiyong Park17b8d752022-12-16 14:36:24 +0900127 // `installable: false` is inherited from vmbase_elf_defaults, and that
128 // hides this module from Make, which makes it impossible for the Make world
129 // to place the unstripped binary to the symbols directory. Marking back as
130 // installable exposes this module to the Make world again. Note that this
131 // module (pvmfw) still is NOT installed to any of the filesystem images. It
132 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
133 // partition image. This is just to package the unstripped file into the
134 // symbols zip file for debugging purpose.
135 installable: true,
Andrew Walbran15068b02022-03-22 15:57:34 +0000136}
David Brazdil05d4e072022-04-25 14:47:06 +0100137
138raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +0100139 name: "pvmfw_bin",
140 stem: "pvmfw.bin",
141 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +0100142 enabled: false,
143 target: {
144 android_arm64: {
145 enabled: true,
146 },
147 },
148}
David Brazdilac216b52022-04-25 15:07:22 +0100149
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900150// Provide pvmfw.bin binary regardless of the architecture for building test.
151// Note that skipping tests on unsupported device is easy
152// while configuring server configuration to make such tests to run on working
153// devices.
154prebuilt_etc {
155 name: "pvmfw_test",
156 filename: "pvmfw_test.bin",
157 target: {
158 android_arm64: {
159 src: ":pvmfw_bin",
160 },
161 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000162 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900163 installable: false,
164}
165
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100166prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100167 name: "pvmfw_embedded_key",
168 src: ":avb_testkey_rsa4096_pub_bin",
169 installable: false,
170}
171
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100172genrule {
173 name: "pvmfw_embedded_key_rs",
174 srcs: [":pvmfw_embedded_key"],
175 out: ["lib.rs"],
176 cmd: "(" +
177 " echo '#![no_std]';" +
178 " echo '#![allow(missing_docs)]';" +
179 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
180 " xxd -i < $(in);" +
181 " echo '];';" +
182 ") > $(out)",
183}
184
185rust_library_rlib {
186 name: "libpvmfw_embedded_key",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000187 defaults: ["vmbase_rlib_defaults"],
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100188 srcs: [":pvmfw_embedded_key_rs"],
189 crate_name: "pvmfw_embedded_key",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100190}
191
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100192prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100193 name: "pvmfw_sign_key",
194 src: ":avb_testkey_rsa4096",
195 installable: false,
196}
197
Jiyong Park9c1c8182023-05-25 15:40:11 +0900198// We need to rename *.dts into *.cpp as cc_object doesn't accept *.dts as an
199// input
Jiyong Park216793e2023-02-25 02:15:44 +0900200genrule {
Jiyong Park9c1c8182023-05-25 15:40:11 +0900201 name: "pvmfw_platform.dts.renamed",
202 srcs: ["platform.dts"],
203 out: ["out.cpp"],
204 cmd: "cp $(in) $(out)",
205 visibility: ["//visibility:private"],
206}
207
208// Then run the macro processor to replace symbols like GIC_SPI into actual
209// numbers defined in the ARM DT binding headers
210cc_object {
211 name: "pvmfw_platform.dts.preprocessed",
212 header_libs: ["arm_dt_bindings_headers"],
213 host_supported: true,
214 srcs: [":pvmfw_platform.dts.renamed"],
215 cflags: [
216 "-E",
217 "-P",
218 "-xassembler-with-cpp", // allow C preprocessor directives
Jiyong Park216793e2023-02-25 02:15:44 +0900219 ],
Jiyong Park9c1c8182023-05-25 15:40:11 +0900220 visibility: ["//visibility:private"],
221}
222
223// Compile the preprocessed dts into binary and create a rust library source
224// having the binary.
225cc_genrule {
226 name: "pvmfw_fdt_template_rs",
227 srcs: [":pvmfw_platform.dts.preprocessed"],
Jiyong Park216793e2023-02-25 02:15:44 +0900228 out: ["lib.rs"],
229 tools: ["dtc"],
Jaewan Kim96411e92023-11-13 15:54:02 +0900230 cmd: "$(location dtc) -@ -I dts -O dtb -o $(genDir)/compiled.dtbo $(in) && " +
Jiyong Park216793e2023-02-25 02:15:44 +0900231 "(" +
232 " echo '#![no_std]';" +
233 " echo '#![allow(missing_docs)]';" +
234 " echo 'pub const RAW: &[u8] = &[';" +
235 " xxd -i < $(genDir)/compiled.dtbo;" +
236 " echo '];';" +
237 ") > $(out)",
Jiyong Park9c1c8182023-05-25 15:40:11 +0900238 visibility: ["//visibility:private"],
Jiyong Park216793e2023-02-25 02:15:44 +0900239}
240
241rust_library_rlib {
242 name: "libpvmfw_fdt_template",
Pierre-Clément Tosi4894b432023-06-27 14:02:26 +0000243 defaults: ["vmbase_rlib_defaults"],
Jiyong Park216793e2023-02-25 02:15:44 +0900244 srcs: [":pvmfw_fdt_template_rs"],
245 crate_name: "pvmfw_fdt_template",
246}
247
David Brazdilac216b52022-04-25 15:07:22 +0100248bootimg {
249 name: "pvmfw_img",
250 stem: "pvmfw.img",
251 kernel_prebuilt: ":pvmfw_bin",
252 header_version: "3",
253 partition_name: "pvmfw",
254 enabled: false,
255 target: {
256 android_arm64: {
257 enabled: true,
258 },
259 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100260 use_avb: true,
261 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100262}