diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml index adbdf27c1..82ae57a19 100644 --- a/ffi/Cargo.toml +++ b/ffi/Cargo.toml @@ -22,7 +22,7 @@ num_enum = { workspace = true } once_cell = { workspace = true } ouisync-bridge = { path = "../bridge" } ouisync-lib = { package = "ouisync", path = "../lib" } -ouisync-vfs = { path = "../vfs" } +ouisync-vfs = { path = "../vfs", default-features = false } rustls = { workspace = true } scoped_task = { path = "../scoped_task" } serde = { workspace = true } @@ -35,3 +35,7 @@ tracing = { workspace = true } [dev-dependencies] rmp-serde = { workspace = true } + +[features] +default = ["mount"] +mount = ["ouisync-vfs/mount"] \ No newline at end of file diff --git a/vfs/Cargo.toml b/vfs/Cargo.toml index 82d08c24a..e54af3b0d 100644 --- a/vfs/Cargo.toml +++ b/vfs/Cargo.toml @@ -22,17 +22,17 @@ tracing = { workspace = true } thiserror = { workspace = true } [target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies] -fuser = "0.13.0" -libc = "0.2.139" +fuser = { version = "0.13.0", optional = true } +libc = { version = "0.2.139", optional = true } [target.'cfg(target_os = "windows")'.dependencies] # Patch to force compilation of dokan2.dll when `DOKAN_DLL_OUTPUT_PATH` is # defined even if dokan is installed. # https://github.com/dokan-dev/dokan-rust/pull/7 -dokan = { git = "https://github.com/inetic/dokan-rust", branch = "env-to-recompile-dll" } -dokan-sys = { git = "https://github.com/inetic/dokan-rust", branch = "env-to-recompile-dll" } -widestring = "0.4.3" -winapi = { version = "0.3.9", features = ["ntstatus", "winnt"] } +dokan = { git = "https://github.com/inetic/dokan-rust", branch = "env-to-recompile-dll", optional = true } +dokan-sys = { git = "https://github.com/inetic/dokan-rust", branch = "env-to-recompile-dll", optional = true } +widestring = { version = "0.4.3", optional = true } +winapi = { version = "0.3.9", features = ["ntstatus", "winnt"], optional = true } [dev-dependencies] criterion = { version = "0.4", features = ["html_reports"] } @@ -42,3 +42,6 @@ tempfile = "3.2" test-strategy = "0.2.1" tracing-subscriber = { workspace = true, features = [ "env-filter" ] } +[features] +default = ["mount"] +mount = ["fuser", "libc", "dokan", "dokan-sys", "widestring", "winapi"] diff --git a/vfs/src/lib.rs b/vfs/src/lib.rs index 1ff48d8ed..bfefc24c0 100644 --- a/vfs/src/lib.rs +++ b/vfs/src/lib.rs @@ -1,22 +1,22 @@ -#[cfg(target_os = "linux")] +#[cfg(all(feature = "mount", target_os = "linux"))] mod fuse; -#[cfg(target_os = "linux")] +#[cfg(all(feature = "mount", target_os = "linux"))] pub use fuse::{mount, MountGuard, MultiRepoVFS}; -#[cfg(target_os = "windows")] +#[cfg(all(feature = "mount", target_os = "windows"))] mod dokan; -#[cfg(target_os = "windows")] +#[cfg(all(feature = "mount", target_os = "windows"))] pub use crate::dokan::{ multi_repo_mount::MultiRepoVFS, single_repo_mount::{mount, MountGuard}, }; -#[cfg(not(any(target_os = "linux", target_os = "windows")))] +#[cfg(not(all(feature = "mount", any(target_os = "linux", target_os = "windows"))))] mod dummy; -#[cfg(not(any(target_os = "linux", target_os = "windows")))] +#[cfg(not(all(feature = "mount", any(target_os = "linux", target_os = "windows"))))] pub use dummy::{mount, MountGuard, MultiRepoVFS}; #[cfg(test)]