xref: /aosp_15_r20/external/crosvm/base/patches/Android.bp.patch (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1diff --git a/base/Android.bp b/base/Android.bp
2index 734ab7c1..20f48f53 100644
3--- a/base/Android.bp
4+++ b/base/Android.bp
5@@ -13,7 +13,7 @@ package {
6 rust_test {
7     name: "base_test_src_lib",
8     defaults: ["crosvm_inner_defaults"],
9-    host_supported: true,
10+    host_supported: false, // Can't seem to access syslog in TH host tests.
11     crate_name: "base",
12     cargo_env_compat: true,
13     srcs: ["src/lib.rs"],
14@@ -44,6 +44,25 @@ rust_test {
15         "libbase_event_token_derive",
16         "libremain",
17     ],
18+    target: {
19+        android: {
20+            rustlibs: ["libandroid_log_sys"],
21+        },
22+        linux_bionic_arm64: {
23+            // For ARM architecture, we use aarch64-linux-android for BOTH
24+            // device and host targets. As a result, host targets are also
25+            // built with target_os = "android". Therefore, sys_util/src/android
26+            // is used and thus this android module is required.
27+            // This seems incorrect, but is inevitable because rustc doesn't
28+            // yet support a Linux-based target using Bionic as libc. We can't
29+            // use aarch64-unknown-linux-gnu because it's using glibc which
30+            // we don't support for cross-host builds.
31+            rustlibs: [
32+                "libandroid_log_sys",
33+            ],
34+        },
35+    },
36+    shared_libs: ["libcap"], // specified in src/linux/capabilities.rs
37 }
38
39 rust_test {
40@@ -86,7 +106,7 @@ rust_test {
41 rust_test {
42     name: "base_test_tests_linux_main",
43     defaults: ["crosvm_inner_defaults"],
44-    host_supported: true,
45+    host_supported: false, // Can't seem to access syslog in TH host tests.
46     crate_name: "linux",
47     cargo_env_compat: true,
48     srcs: ["tests/linux/main.rs"],
49@@ -118,6 +138,25 @@ rust_test {
50         "libbase_event_token_derive",
51         "libremain",
52     ],
53+    target: {
54+        android: {
55+            rustlibs: ["libandroid_log_sys"],
56+        },
57+        linux_bionic_arm64: {
58+            // For ARM architecture, we use aarch64-linux-android for BOTH
59+            // device and host targets. As a result, host targets are also
60+            // built with target_os = "android". Therefore, sys_util/src/android
61+            // is used and thus this android module is required.
62+            // This seems incorrect, but is inevitable because rustc doesn't
63+            // yet support a Linux-based target using Bionic as libc. We can't
64+            // use aarch64-unknown-linux-gnu because it's using glibc which
65+            // we don't support for cross-host builds.
66+            rustlibs: [
67+                "libandroid_log_sys",
68+            ],
69+        },
70+    },
71+    shared_libs: ["libcap"], // specified in src/linux/capabilities.rs
72 }
73
74 rust_library {
75@@ -153,4 +192,23 @@ rust_library {
76     apex_available: [
77         "//apex_available:platform",
78     ],
79+    target: {
80+        android: {
81+            rustlibs: ["libandroid_log_sys"],
82+        },
83+        linux_bionic_arm64: {
84+            // For ARM architecture, we use aarch64-linux-android for BOTH
85+            // device and host targets. As a result, host targets are also
86+            // built with target_os = "android". Therefore, sys_util/src/android
87+            // is used and thus this android module is required.
88+            // This seems incorrect, but is inevitable because rustc doesn't
89+            // yet support a Linux-based target using Bionic as libc. We can't
90+            // use aarch64-unknown-linux-gnu because it's using glibc which
91+            // we don't support for cross-host builds.
92+            rustlibs: [
93+                "libandroid_log_sys",
94+            ],
95+        },
96+    },
97+    shared_libs: ["libcap"], // specified in src/linux/capabilities.rs
98     visibility: ["//vendor:__subpackages__"],
99 }
100