1package {
2    default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
5// The hierarchy of Soong modules to produce a vmbase-based binary is
6//
7// 0. rlibs may be used to provide high-level code (see "vmbase_rlib_defaults");
8// 1. rust_ffi_static packages low-level Rust code and any rlib into a static
9//    library (see "vmbase_ffi_defaults") that cc_binary supports;
10// 2. cc_library_static may be used for extra C code (see "vmbase_cc_defaults");
11// 3. cc_binary produces an ELF from the (single) Rust-wrapping static library,
12//    optional extra C libraries, and linker script (see "vmbase_elf_defaults");
13// 4. raw_binary strips the ELF into an image that can be loaded to memory;
14
15// Used by intermediate rust_library_rlib for vmbase-based binaries.
16rust_defaults {
17    name: "vmbase_rlib_defaults",
18    defaults: ["avf_build_flags_rust"],
19    edition: "2021",
20    prefer_rlib: true,
21    host_supported: false,
22    enabled: false,
23    no_stdlibs: true,
24    stdlibs: [
25        "libcompiler_builtins.rust_sysroot",
26        "libcore.rust_sysroot",
27    ],
28    target: {
29        android_arm64: {
30            enabled: true,
31        },
32    },
33}
34
35// Used by the "top-level" rust_ffi_static of vmbase-based binaries.
36rust_defaults {
37    name: "vmbase_ffi_defaults",
38    defaults: ["vmbase_rlib_defaults"],
39}
40
41// Used by extra cc_library_static linked into the final ELF.
42cc_defaults {
43    name: "vmbase_cc_defaults",
44    defaults: ["avf_build_flags_cc"],
45    nocrt: true,
46    no_libcrt: true,
47    system_shared_libs: [],
48    stl: "none",
49    installable: false,
50    enabled: false,
51    target: {
52        android_arm64: {
53            enabled: true,
54        },
55    },
56    sanitize: {
57        hwaddress: false,
58    },
59    native_coverage: false,
60    // TODO(b/346974429): Workaround pvmfw failure when enabling full LTO
61    lto_O0: true,
62}
63
64// Used by cc_binary when producing the ELF of a vmbase-based binary.
65cc_defaults {
66    name: "vmbase_elf_defaults",
67    defaults: ["vmbase_cc_defaults"],
68    static_executable: true,
69    static_libs: [
70        "libvmbase_entry",
71    ],
72}
73
74rust_library_rlib {
75    name: "libvmbase",
76    defaults: ["vmbase_rlib_defaults"],
77    crate_name: "vmbase",
78    srcs: ["src/lib.rs"],
79    rustlibs: [
80        "libaarch64_paging",
81        "libbuddy_system_allocator",
82        "libcstr",
83        "libfdtpci",
84        "liblibfdt",
85        "liblog_rust_nostd",
86        "libonce_cell_nostd",
87        "libsmccc",
88        "libspin_nostd",
89        "libstatic_assertions",
90        "libtinyvec_nostd",
91        "libuuid_nostd",
92        "libvirtio_drivers",
93        "libzerocopy_nostd",
94        "libzeroize_nostd",
95    ],
96    whole_static_libs: [
97        "librust_baremetal",
98    ],
99    // TODO(b/277859415, b/277860860): Drop "compat_android_13".
100    features: [
101        "compat_android_13",
102        "cpu_feat_hafdbs",
103    ],
104}
105
106cc_library_static {
107    name: "libvmbase_entry",
108    defaults: ["vmbase_cc_defaults"],
109    srcs: [
110        "entry.S",
111        "exceptions.S",
112        "exceptions_panic.S",
113    ],
114}
115
116filegroup {
117    name: "vmbase_sections",
118    srcs: ["sections.ld"],
119}
120