Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce explicit feature "fuse". #40

Merged
merged 4 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@ jobs:
run: cargo install cross

- name: Test code
env:
CROSS_CONTAINER_OPTS: "--device /dev/fuse --cap-add SYS_ADMIN"
run: |
cross test --workspace --verbose --target=i686-unknown-linux-gnu
cross test --workspace --verbose --target=i686-unknown-linux-gnu --features in_ci
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions arx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,26 @@ env_logger = "0.10.0"
log = "0.4.20"
tempfile = "3.10.1"

[dev-dependencies]
[target.'cfg(not(windows))'.dev-dependencies]
arx_test_dir = { git = "https://github.com/jubako/arx_test_dir.git" }
tempfile = "3.8.0"

[features]
default = ["zstd"]
default = ["zstd", "fuse"]
in_ci = []
lz4 = ["arx/lz4"]
zstd = ["arx/zstd"]
lzma = ["arx/lzma"]
fuse = ["arx/fuse", "arx_test_dir/fuse"]

[[bin]]
name = "auto_mount"
required-features = ["fuse"]

[[bin]]
name = "mount_fuse_arx"
required-features = ["fuse"]

[[test]]
name = "create"
required-features = ["fuse"]
10 changes: 5 additions & 5 deletions arx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod dump;
mod extract;
mod light_path;
mod list;
#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
mod mount;

use anyhow::Result;
Expand All @@ -29,7 +29,7 @@ struct Cli {
"list",
"dump",
"extract",
#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
"mount"
])
)]
Expand All @@ -56,7 +56,7 @@ enum Commands {
#[command(arg_required_else_help = true)]
Extract(extract::Options),

#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
#[command(arg_required_else_help = true)]
Mount(mount::Options),
}
Expand Down Expand Up @@ -91,7 +91,7 @@ fn run() -> Result<()> {
"list" => list::Options::command(),
"dump" => dump::Options::command(),
"extract" => extract::Options::command(),
#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
"mount" => mount::Options::command(),
_ => return Ok(Cli::command().print_help()?),
};
Expand All @@ -114,7 +114,7 @@ fn run() -> Result<()> {
Commands::List(options) => Ok(list::list(options)?),
Commands::Dump(options) => Ok(dump::dump(options)?),
Commands::Extract(options) => Ok(extract::extract(options)?),
#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
Commands::Mount(options) => Ok(mount::mount(options)?),
},
}
Expand Down
60 changes: 60 additions & 0 deletions arx/tests/create.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#[cfg(all(unix, not(feature = "in_ci")))]
mod inner {
pub use std::path::{Path, PathBuf};
pub use std::process::Command;

// Generate a fake directory with fake content.
pub fn spawn_mount() -> std::io::Result<(arx_test_dir::BackgroundSession, PathBuf)> {
let mount_path = tempfile::TempDir::new_in(env!("CARGO_TARGET_TMPDIR")).unwrap();
let builder = arx_test_dir::ContextBuilder::new();
let context = builder.create();
let dir = arx_test_dir::DirEntry::new_root(context);
let mount_dir = arx_test_dir::TreeFs::new(dir);
Ok((
mount_dir.spawn(mount_path.path())?,
mount_path.path().into(),
))
}
}

#[cfg(all(unix, not(feature = "in_ci")))]
#[test]
fn test_create() {
use inner::*;

let (_source_mount_handle, source_mount_point) = spawn_mount().unwrap();
let bin_path = env!("CARGO_BIN_EXE_arx");
let arx_file = Path::new(env!("CARGO_TARGET_TMPDIR")).join("test.arx");
let output = Command::new(bin_path)
.arg("--verbose")
.arg("create")
.arg("--outfile")
.arg(&arx_file)
.arg("-C")
.arg(&source_mount_point.parent().unwrap())
.arg("--strip-prefix")
.arg(&source_mount_point.file_name().unwrap())
.arg(&source_mount_point.file_name().unwrap())
.output()
.expect("foo");
println!("Out : {}", String::from_utf8(output.stdout).unwrap());
println!("Err : {}", String::from_utf8(output.stderr).unwrap());
assert!(output.status.success());
assert!(arx_file.is_file());

let mount_point = tempfile::TempDir::new_in(env!("CARGO_TARGET_TMPDIR")).unwrap();
let arx = arx::Arx::new(arx_file).unwrap();
let arxfs = arx::ArxFs::new(arx).unwrap();
let _mount_handle = arxfs
.spawn_mount("Test mounted arx".into(), mount_point.path())
.unwrap();
let output = Command::new("diff")
.arg("-r")
.arg(&source_mount_point)
.arg(&mount_point.path())
.output()
.unwrap();
println!("Out : {}", String::from_utf8(output.stdout).unwrap());
println!("Err: {}", String::from_utf8(output.stderr).unwrap());
assert!(output.status.success());
}
5 changes: 3 additions & 2 deletions libarx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license.workspace = true

[dependencies]
jbk.workspace = true
clap = { workspace=true, optional =true }
clap = { workspace=true, optional = true }
libc = "0.2.148"
lru = "0.11.1"
fxhash = "0.2.1"
Expand All @@ -25,10 +25,11 @@ rayon = "1.10.0"
bstr = "1.9.1"

[target.'cfg(not(windows))'.dependencies]
fuser = "0.13.0"
fuser = { version = "0.13.0", optional = true }

[features]
cmd_utils = [ "dep:clap"]
lz4 = ["jbk/lz4"]
zstd = ["jbk/zstd"]
lzma = ["jbk/lzma"]
fuse = ["dep:fuser"]
2 changes: 1 addition & 1 deletion libarx/src/common/entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl ToString for EntryType {

impl jbk::creator::VariantName for EntryType {}

#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
impl From<EntryType> for fuser::FileType {
fn from(t: EntryType) -> Self {
match t {
Expand Down
4 changes: 2 additions & 2 deletions libarx/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//#![feature(get_mut_unchecked)]

mod arx;
#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
mod arx_fs;
#[cfg(feature = "cmd_utils")]
pub mod cmd_utils;
Expand All @@ -12,7 +12,7 @@ mod tools;
pub mod walk;

pub use arx::Arx;
#[cfg(not(windows))]
#[cfg(all(not(windows), feature = "fuse"))]
pub use arx_fs::{ArxFs, Stats};
pub use common::{AllProperties, Builder, Entry, FullBuilderTrait, Path, PathBuf, VENDOR_ID};
pub use entry::*;
Expand Down
52 changes: 0 additions & 52 deletions tests/create.rs

This file was deleted.

Loading