diff --git a/crates/vite_command/Cargo.toml b/crates/vite_command/Cargo.toml index 4d031bfe42..1ef1f61cf2 100644 --- a/crates/vite_command/Cargo.toml +++ b/crates/vite_command/Cargo.toml @@ -8,7 +8,6 @@ publish = false rust-version.workspace = true [dependencies] -fspy = { workspace = true } tokio = { workspace = true } tokio-util = { workspace = true } tracing = { workspace = true } @@ -19,6 +18,9 @@ which = { workspace = true, features = ["tracing"] } [target.'cfg(not(target_os = "windows"))'.dependencies] nix = { workspace = true, features = ["term"] } +[target.'cfg(not(target_os = "android"))'.dependencies] +fspy = { workspace = true } + [dev-dependencies] tempfile = { workspace = true } tokio = { workspace = true, features = ["macros", "test-util"] } diff --git a/crates/vite_command/src/lib.rs b/crates/vite_command/src/lib.rs index 9f724e3aac..9ed83af9fb 100644 --- a/crates/vite_command/src/lib.rs +++ b/crates/vite_command/src/lib.rs @@ -6,13 +6,19 @@ use std::{ process::{ExitStatus, Stdio}, }; +#[cfg(not(target_os = "android"))] use fspy::AccessMode; use tokio::process::Command; +#[cfg(not(target_os = "android"))] use tokio_util::sync::CancellationToken; use vite_error::Error; -use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf}; +#[cfg(not(target_os = "android"))] +use vite_path::RelativePathBuf; +use vite_path::{AbsolutePath, AbsolutePathBuf}; /// Result of running a command with fspy tracking. + +#[cfg(not(target_os = "android"))] #[derive(Debug)] pub struct FspyCommandResult { /// The termination status of the command. @@ -160,6 +166,7 @@ where /// # Returns /// /// Returns a FspyCommandResult containing the exit status and path accesses. +#[cfg(not(target_os = "android"))] pub async fn run_command_with_fspy( bin_name: &str, args: I, diff --git a/crates/vite_js_runtime/src/platform.rs b/crates/vite_js_runtime/src/platform.rs index 58e03baf37..58d59ca826 100644 --- a/crates/vite_js_runtime/src/platform.rs +++ b/crates/vite_js_runtime/src/platform.rs @@ -11,6 +11,7 @@ pub struct Platform { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Os { Linux, + Android, Darwin, Windows, } @@ -51,6 +52,10 @@ impl Os { { Self::Linux } + #[cfg(target_os = "android")] + { + Self::Android + } #[cfg(target_os = "macos")] { Self::Darwin @@ -59,7 +64,13 @@ impl Os { { Self::Windows } - #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))] + #[cfg(not(any( + target_os = "android", + target_os = "linux", + target_os = "macos", + target_os = "windows", + target_os = "android" + )))] { compile_error!( "Unsupported operating system. vite_js_runtime only supports Linux, macOS, and Windows." @@ -72,6 +83,7 @@ impl fmt::Display for Os { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Linux => write!(f, "linux"), + Self::Android => write!(f, "android"), Self::Darwin => write!(f, "darwin"), Self::Windows => write!(f, "windows"), } diff --git a/crates/vite_js_runtime/src/providers/node.rs b/crates/vite_js_runtime/src/providers/node.rs index 19edaa8884..2b1fdf1227 100644 --- a/crates/vite_js_runtime/src/providers/node.rs +++ b/crates/vite_js_runtime/src/providers/node.rs @@ -169,7 +169,7 @@ impl NodeProvider { const fn archive_format(platform: Platform) -> ArchiveFormat { match platform.os { Os::Windows => ArchiveFormat::Zip, - Os::Linux | Os::Darwin => ArchiveFormat::TarGz, + Os::Linux | Os::Darwin | Os::Android => ArchiveFormat::TarGz, } } @@ -576,6 +576,7 @@ impl JsRuntimeProvider for NodeProvider { fn platform_string(&self, platform: Platform) -> Str { let os = match platform.os { Os::Linux => "linux", + Os::Android => "android", Os::Darwin => "darwin", Os::Windows => "win", }; @@ -615,14 +616,14 @@ impl JsRuntimeProvider for NodeProvider { fn binary_relative_path(&self, platform: Platform) -> Str { match platform.os { Os::Windows => "node.exe".into(), - Os::Linux | Os::Darwin => "bin/node".into(), + Os::Linux | Os::Darwin | Os::Android => "bin/node".into(), } } fn bin_dir_relative_path(&self, platform: Platform) -> Str { match platform.os { Os::Windows => "".into(), - Os::Linux | Os::Darwin => "bin".into(), + Os::Linux | Os::Darwin | Os::Android => "bin".into(), } }