Skip to content

Commit

Permalink
apply formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
KoltesDigital committed Jun 2, 2022
1 parent e149e3f commit bcfee7b
Show file tree
Hide file tree
Showing 8 changed files with 1,502 additions and 712 deletions.
30 changes: 24 additions & 6 deletions dokan-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ fn run_generator(compiler: &Tool) -> String {
assert!(compiler_cmd.output().unwrap().status.success());
let generate_output = Command::new(format!("{}/generate_version.exe", out_dir))
.current_dir(&out_dir)
.output().unwrap();
.output()
.unwrap();
assert!(generate_output.status.success());
println!("cargo:rerun-if-changed=src/generate_version.c");

Expand All @@ -63,16 +64,26 @@ fn check_dokan_env(version_major: &str) -> bool {
println!("cargo:rustc-link-search=native={}", lib_path);
true
} else {
println!("cargo:warning=Environment variable {} not found, building Dokan from source.", env_name);
println!(
"cargo:warning=Environment variable {} not found, building Dokan from source.",
env_name
);
false
}
}

fn build_dokan(compiler: &Tool, version_major: &str) {
let out_dir = env::var("OUT_DIR").unwrap();
let src = fs::read_dir("src/dokany/dokan").unwrap()
let src = fs::read_dir("src/dokany/dokan")
.unwrap()
.map(|d| d.unwrap().path())
.filter(|p| if let Some(ext) = p.extension() { ext == "c" } else { false });
.filter(|p| {
if let Some(ext) = p.extension() {
ext == "c"
} else {
false
}
});
let dll_name = format!("dokan{}.dll", version_major);
let dll_path = format!("{}/{}", out_dir, dll_name);
let mut compiler_cmd = compiler.to_command();
Expand Down Expand Up @@ -103,7 +114,10 @@ fn build_dokan(compiler: &Tool, version_major: &str) {
.arg("-shared")
.arg(format!("-o{}", dll_path))
.args(src)
.arg(format!("-Wl,--out-implib,{}/dokan{}.lib", out_dir, version_major))
.arg(format!(
"-Wl,--out-implib,{}/dokan{}.lib",
out_dir, version_major
))
};
assert!(compiler_cmd.output().unwrap().status.success());
if let Ok(output_path) = env::var("DOKAN_DLL_OUTPUT_PATH") {
Expand All @@ -120,7 +134,11 @@ fn main() {
let version = run_generator(&compiler);
assert_eq!(
format!("dokan{}", version),
env::var("CARGO_PKG_VERSION").unwrap().split('+').last().unwrap(),
env::var("CARGO_PKG_VERSION")
.unwrap()
.split('+')
.last()
.unwrap(),
"Mismatch detected between crate version and bundled Dokan source version.",
);
let version_major = &version[..1];
Expand Down
Loading

0 comments on commit bcfee7b

Please sign in to comment.