1- #[ cfg( target_os = "linux" ) ]
1+ #[ cfg( any ( target_os = "linux" , target_os = "android" ) ) ]
22mod syscall_handler;
33
44#[ cfg( target_os = "macos" ) ]
55mod macos_artifacts;
66
77use std:: { io, path:: Path } ;
88
9- #[ cfg( target_os = "linux" ) ]
9+ #[ cfg( any ( target_os = "linux" , target_os = "android" ) ) ]
1010use fspy_seccomp_unotify:: supervisor:: supervise;
1111use fspy_shared:: ipc:: PathAccess ;
12- #[ cfg( not( target_env = "musl" ) ) ]
12+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
1313use fspy_shared:: ipc:: { NativeStr , channel:: channel} ;
1414#[ cfg( target_os = "macos" ) ]
1515use fspy_shared_unix:: payload:: Artifacts ;
@@ -19,12 +19,12 @@ use fspy_shared_unix::{
1919 spawn:: handle_exec,
2020} ;
2121use futures_util:: FutureExt ;
22- #[ cfg( target_os = "linux" ) ]
22+ #[ cfg( any ( target_os = "linux" , target_os = "android" ) ) ]
2323use syscall_handler:: SyscallHandler ;
2424use tokio:: task:: spawn_blocking;
2525use tokio_util:: sync:: CancellationToken ;
2626
27- #[ cfg( not( target_env = "musl" ) ) ]
27+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
2828use crate :: ipc:: { OwnedReceiverLockGuard , SHM_CAPACITY } ;
2929use crate :: { ChildTermination , Command , TrackedChild , arena:: PathAccessArena , error:: SpawnError } ;
3030
@@ -33,7 +33,7 @@ pub struct SpyImpl {
3333 #[ cfg( target_os = "macos" ) ]
3434 artifacts : Artifacts ,
3535
36- #[ cfg( not( target_env = "musl" ) ) ]
36+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
3737 preload_path : Box < NativeStr > ,
3838}
3939
@@ -42,8 +42,10 @@ impl SpyImpl {
4242 ///
4343 /// On musl targets, we don't build a preload library —
4444 /// only seccomp-based tracking is used.
45- pub fn init_in ( #[ cfg_attr( target_env = "musl" , allow( unused) ) ] dir : & Path ) -> io:: Result < Self > {
46- #[ cfg( not( target_env = "musl" ) ) ]
45+ pub fn init_in (
46+ #[ cfg_attr( any( target_os = "android" , target_env = "musl" ) , allow( unused) ) ] dir : & Path ,
47+ ) -> io:: Result < Self > {
48+ #[ cfg( all( not( target_os = "android" ) , not( target_env = "musl" ) ) ) ]
4749 let preload_path = {
4850 use materialized_artifact:: { Artifact , artifact} ;
4951
@@ -54,7 +56,7 @@ impl SpyImpl {
5456 } ;
5557
5658 Ok ( Self {
57- #[ cfg( not( target_env = "musl" ) ) ]
59+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
5860 preload_path,
5961 #[ cfg( target_os = "macos" ) ]
6062 artifacts : {
@@ -74,24 +76,24 @@ impl SpyImpl {
7476 mut command : Command ,
7577 cancellation_token : CancellationToken ,
7678 ) -> Result < TrackedChild , SpawnError > {
77- #[ cfg( target_os = "linux" ) ]
79+ #[ cfg( any ( target_os = "linux" , target_os = "android" ) ) ]
7880 let supervisor = supervise :: < SyscallHandler > ( ) . map_err ( SpawnError :: Supervisor ) ?;
7981
80- #[ cfg( not( target_env = "musl" ) ) ]
82+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
8183 let ( ipc_channel_conf, ipc_receiver) =
8284 channel ( SHM_CAPACITY ) . map_err ( SpawnError :: ChannelCreation ) ?;
8385
8486 let payload = Payload {
85- #[ cfg( not( target_env = "musl" ) ) ]
87+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
8688 ipc_channel_conf,
8789
8890 #[ cfg( target_os = "macos" ) ]
8991 artifacts : self . artifacts . clone ( ) ,
9092
91- #[ cfg( not( target_env = "musl" ) ) ]
93+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
9294 preload_path : self . preload_path . clone ( ) ,
9395
94- #[ cfg( target_os = "linux" ) ]
96+ #[ cfg( any ( target_os = "linux" , target_os = "android" ) ) ]
9597 seccomp_payload : supervisor. payload ( ) . clone ( ) ,
9698 } ;
9799
@@ -148,7 +150,7 @@ impl SpyImpl {
148150
149151 let arenas = std:: iter:: once ( exec_resolve_accesses) ;
150152 // Stop the supervisor and collect path accesses from it.
151- #[ cfg( target_os = "linux" ) ]
153+ #[ cfg( any ( target_os = "linux" , target_os = "android" ) ) ]
152154 let arenas = arenas. chain (
153155 supervisor
154156 . stop ( )
@@ -160,12 +162,12 @@ impl SpyImpl {
160162
161163 // Lock the ipc channel after the child has exited.
162164 // We are not interested in path accesses from descendants after the main child has exited.
163- #[ cfg( not( target_env = "musl" ) ) ]
165+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
164166 let ipc_receiver_lock_guard =
165167 OwnedReceiverLockGuard :: lock_async ( ipc_receiver) . await ?;
166168 let path_accesses = PathAccessIterable {
167169 arenas,
168- #[ cfg( not( target_env = "musl" ) ) ]
170+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
169171 ipc_receiver_lock_guard,
170172 } ;
171173
@@ -179,7 +181,7 @@ impl SpyImpl {
179181
180182pub struct PathAccessIterable {
181183 arenas : Vec < PathAccessArena > ,
182- #[ cfg( not( target_env = "musl" ) ) ]
184+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
183185 ipc_receiver_lock_guard : OwnedReceiverLockGuard ,
184186}
185187
@@ -188,12 +190,12 @@ impl PathAccessIterable {
188190 let accesses_in_arena =
189191 self . arenas . iter ( ) . flat_map ( |arena| arena. borrow_accesses ( ) . iter ( ) ) . copied ( ) ;
190192
191- #[ cfg( not( target_env = "musl" ) ) ]
193+ #[ cfg( all ( not( target_os = "android" ) , not ( target_env = "musl" ) ) ) ]
192194 {
193195 let accesses_in_shm = self . ipc_receiver_lock_guard . iter_path_accesses ( ) ;
194196 accesses_in_shm. chain ( accesses_in_arena)
195197 }
196- #[ cfg( target_env = "musl" ) ]
198+ #[ cfg( any ( target_os = "android" , target_env = "musl" ) ) ]
197199 {
198200 accesses_in_arena
199201 }
0 commit comments