blob: e5fdfe8e4d5d5d350ce16322ccdb477d25c765eb [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",
Alan Stokesa0e42962023-04-14 17:59:50 +010011 // Require unsafe blocks for inside unsafe functions.
12 flags: ["-Dunsafe_op_in_unsafe_fn"],
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010013 features: [
14 "legacy",
15 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000016 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000017 "libaarch64_paging",
Pierre-Clément Tosi90cd4f12023-02-17 11:19:56 +000018 "libbssl_ffi_nostd",
Pierre-Clément Tosifc531152022-10-20 12:22:23 +010019 "libbuddy_system_allocator",
Alan Stokesd1ee63e2023-04-24 16:17:39 +010020 "libciborium_nostd",
21 "libciborium_io_nostd",
Alice Wangcb9d2f92023-02-06 10:29:00 +000022 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000023 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000024 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000025 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010026 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000027 "libonce_cell_nostd",
Andrew Walbran9afab672023-04-17 14:26:23 +000028 "libpsci",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000029 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010030 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090031 "libpvmfw_fdt_template",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000032 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000033 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000034 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000035 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000036 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010037 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000038 "libzeroize_nostd",
Jakob Vukalovic85a00d72023-04-20 09:51:10 +010039 "libspin_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000040 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000041}
Andrew Walbran15068b02022-03-22 15:57:34 +000042
Alice Wang1c7e0eb2023-04-11 17:03:42 +000043// Generates an empty file.
44genrule {
45 name: "empty_file",
46 out: ["empty_file"],
47 cmd: "touch $(out)",
48}
49
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090050rust_test {
51 name: "libpvmfw.bootargs.test",
52 host_supported: true,
53 // For now, only bootargs.rs is written to be conditionally compiled with std.
54 srcs: ["src/bootargs.rs"],
55 test_suites: ["general-tests"],
56 test_options: {
57 unit_test: true,
58 },
59 rustlibs: [
60 "libzeroize",
61 ],
62}
63
Andrew Walbran15068b02022-03-22 15:57:34 +000064cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010065 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +010066 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +000067 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +000068 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +000069 ],
70 static_libs: [
71 "libpvmfw",
72 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +000073 linker_scripts: [
74 "image.ld",
75 ":vmbase_sections",
76 ],
Jiyong Park17b8d752022-12-16 14:36:24 +090077 // `installable: false` is inherited from vmbase_elf_defaults, and that
78 // hides this module from Make, which makes it impossible for the Make world
79 // to place the unstripped binary to the symbols directory. Marking back as
80 // installable exposes this module to the Make world again. Note that this
81 // module (pvmfw) still is NOT installed to any of the filesystem images. It
82 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
83 // partition image. This is just to package the unstripped file into the
84 // symbols zip file for debugging purpose.
85 installable: true,
Nikita Ioffe831b08b2023-03-13 21:18:40 +000086 native_coverage: false,
Andrew Walbran15068b02022-03-22 15:57:34 +000087}
David Brazdil05d4e072022-04-25 14:47:06 +010088
89raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010090 name: "pvmfw_bin",
91 stem: "pvmfw.bin",
92 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +010093 enabled: false,
94 target: {
95 android_arm64: {
96 enabled: true,
97 },
98 },
99}
David Brazdilac216b52022-04-25 15:07:22 +0100100
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900101// Provide pvmfw.bin binary regardless of the architecture for building test.
102// Note that skipping tests on unsupported device is easy
103// while configuring server configuration to make such tests to run on working
104// devices.
105prebuilt_etc {
106 name: "pvmfw_test",
107 filename: "pvmfw_test.bin",
108 target: {
109 android_arm64: {
110 src: ":pvmfw_bin",
111 },
112 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000113 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900114 installable: false,
115}
116
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100117prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100118 name: "pvmfw_embedded_key",
119 src: ":avb_testkey_rsa4096_pub_bin",
120 installable: false,
121}
122
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100123genrule {
124 name: "pvmfw_embedded_key_rs",
125 srcs: [":pvmfw_embedded_key"],
126 out: ["lib.rs"],
127 cmd: "(" +
128 " echo '#![no_std]';" +
129 " echo '#![allow(missing_docs)]';" +
130 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
131 " xxd -i < $(in);" +
132 " echo '];';" +
133 ") > $(out)",
134}
135
136rust_library_rlib {
137 name: "libpvmfw_embedded_key",
138 defaults: ["vmbase_ffi_defaults"],
139 prefer_rlib: true,
140 srcs: [":pvmfw_embedded_key_rs"],
141 crate_name: "pvmfw_embedded_key",
142 apex_available: ["com.android.virt"],
143}
144
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100145prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100146 name: "pvmfw_sign_key",
147 src: ":avb_testkey_rsa4096",
148 installable: false,
149}
150
Jiyong Park9c1c8182023-05-25 15:40:11 +0900151// We need to rename *.dts into *.cpp as cc_object doesn't accept *.dts as an
152// input
Jiyong Park216793e2023-02-25 02:15:44 +0900153genrule {
Jiyong Park9c1c8182023-05-25 15:40:11 +0900154 name: "pvmfw_platform.dts.renamed",
155 srcs: ["platform.dts"],
156 out: ["out.cpp"],
157 cmd: "cp $(in) $(out)",
158 visibility: ["//visibility:private"],
159}
160
161// Then run the macro processor to replace symbols like GIC_SPI into actual
162// numbers defined in the ARM DT binding headers
163cc_object {
164 name: "pvmfw_platform.dts.preprocessed",
165 header_libs: ["arm_dt_bindings_headers"],
166 host_supported: true,
167 srcs: [":pvmfw_platform.dts.renamed"],
168 cflags: [
169 "-E",
170 "-P",
171 "-xassembler-with-cpp", // allow C preprocessor directives
Jiyong Park216793e2023-02-25 02:15:44 +0900172 ],
Jiyong Park9c1c8182023-05-25 15:40:11 +0900173 visibility: ["//visibility:private"],
174}
175
176// Compile the preprocessed dts into binary and create a rust library source
177// having the binary.
178cc_genrule {
179 name: "pvmfw_fdt_template_rs",
180 srcs: [":pvmfw_platform.dts.preprocessed"],
Jiyong Park216793e2023-02-25 02:15:44 +0900181 out: ["lib.rs"],
182 tools: ["dtc"],
Jiyong Park9c1c8182023-05-25 15:40:11 +0900183 cmd: "$(location dtc) -I dts -O dtb -o $(genDir)/compiled.dtbo $(in) && " +
Jiyong Park216793e2023-02-25 02:15:44 +0900184 "(" +
185 " echo '#![no_std]';" +
186 " echo '#![allow(missing_docs)]';" +
187 " echo 'pub const RAW: &[u8] = &[';" +
188 " xxd -i < $(genDir)/compiled.dtbo;" +
189 " echo '];';" +
190 ") > $(out)",
Jiyong Park9c1c8182023-05-25 15:40:11 +0900191 visibility: ["//visibility:private"],
Jiyong Park216793e2023-02-25 02:15:44 +0900192}
193
194rust_library_rlib {
195 name: "libpvmfw_fdt_template",
196 defaults: ["vmbase_ffi_defaults"],
197 prefer_rlib: true,
198 srcs: [":pvmfw_fdt_template_rs"],
199 crate_name: "pvmfw_fdt_template",
200}
201
David Brazdilac216b52022-04-25 15:07:22 +0100202bootimg {
203 name: "pvmfw_img",
204 stem: "pvmfw.img",
205 kernel_prebuilt: ":pvmfw_bin",
206 header_version: "3",
207 partition_name: "pvmfw",
208 enabled: false,
209 target: {
210 android_arm64: {
211 enabled: true,
212 },
213 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100214 use_avb: true,
215 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100216}