vmbase/pvmfw: Extract common build properties to defaults
All vmbase-based projects follow the same structure of build targets.
Extract common properties of their build rules into defaults.
vmbase_rust_defaults: rust_* targets, no-std, arm64 only
vmbase_cc_defaults: cc_* targets, no std, arm64 only
vmbase_elf_defaults: cc_binary, arm64 only, link vmbase_entry
Test: m pvmfw vmbase_example
Change-Id: I635ce939fd349b9ce02d20c26e48a95e8b84ca50
diff --git a/vmbase/Android.bp b/vmbase/Android.bp
index 4c5e9d1..e098ea7 100644
--- a/vmbase/Android.bp
+++ b/vmbase/Android.bp
@@ -2,9 +2,57 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
+rust_defaults {
+ name: "vmbase_rust_defaults",
+ host_supported: false,
+ enabled: false,
+ target: {
+ android_arm64: {
+ enabled: true,
+ },
+ },
+}
+
+rust_defaults {
+ name: "vmbase_ffi_defaults",
+ defaults: ["vmbase_rust_defaults"],
+ no_stdlibs: true,
+ stdlibs: [
+ "libcompiler_builtins.rust_sysroot",
+ "libcore.rust_sysroot",
+ ],
+}
+
+cc_defaults {
+ name: "vmbase_cc_defaults",
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ installable: false,
+ enabled: false,
+ target: {
+ android_arm64: {
+ enabled: true,
+ },
+ },
+ sanitize: {
+ hwaddress: false,
+ },
+}
+
+cc_defaults {
+ name: "vmbase_elf_defaults",
+ defaults: ["vmbase_cc_defaults"],
+ system_shared_libs: ["libc"],
+ static_executable: true,
+ static_libs: [
+ "libvmbase_entry",
+ ],
+}
+
rust_library_rlib {
name: "libvmbase",
- host_supported: false,
+ defaults: ["vmbase_rust_defaults"],
crate_name: "vmbase",
srcs: ["src/lib.rs"],
edition: "2021",
@@ -13,31 +61,17 @@
"libpsci",
"libspin_nostd",
],
- enabled: false,
- target: {
- android_arm64: {
- enabled: true,
- },
- },
apex_available: ["com.android.virt"],
}
cc_library_static {
name: "libvmbase_entry",
+ defaults: ["vmbase_cc_defaults"],
srcs: [
"entry.S",
"exceptions.S",
],
- nocrt: true,
no_libcrt: true,
- system_shared_libs: [],
- stl: "none",
- enabled: false,
- target: {
- android_arm64: {
- enabled: true,
- },
- },
apex_available: ["com.android.virt"],
}
diff --git a/vmbase/example/Android.bp b/vmbase/example/Android.bp
index 4011807..e11bb2f 100644
--- a/vmbase/example/Android.bp
+++ b/vmbase/example/Android.bp
@@ -4,57 +4,33 @@
rust_ffi_static {
name: "libvmbase_example",
+ defaults: ["vmbase_ffi_defaults"],
crate_name: "vmbase_example",
srcs: ["src/main.rs"],
edition: "2021",
- no_stdlibs: true,
- stdlibs: [
- "libcompiler_builtins.rust_sysroot",
- "libcore.rust_sysroot",
- ],
rustlibs: [
"libaarch64_paging",
"libbuddy_system_allocator",
"liblog_rust_nostd",
"libvmbase",
],
- enabled: false,
- target: {
- android_arm64: {
- enabled: true,
- },
- },
apex_available: ["com.android.virt"],
}
cc_binary {
name: "vmbase_example_elf",
stem: "vmbase_example",
+ defaults: ["vmbase_elf_defaults"],
srcs: [
"idmap.S",
],
static_libs: [
- "libvmbase_entry",
"libvmbase_example",
],
- static_executable: true,
- nocrt: true,
- system_shared_libs: ["libc"],
- stl: "none",
linker_scripts: [
"image.ld",
":vmbase_sections",
],
- installable: false,
- enabled: false,
- target: {
- android_arm64: {
- enabled: true,
- },
- },
- sanitize: {
- hwaddress: false,
- },
apex_available: ["com.android.virt"],
}