Skip to content

Commit

Permalink
jemalloc-sys: remove fs-extra (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
  • Loading branch information
BusyJay authored Feb 3, 2023
1 parent fa2ddc0 commit 725713e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
1 change: 0 additions & 1 deletion jemalloc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ libc = { version = "^0.2.8", default-features = false }

[build-dependencies]
cc = "^1.0.13"
fs_extra = "^1.1"

[features]
default = ["background_threads_runtime_support"]
Expand Down
34 changes: 25 additions & 9 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::env;
use std::ffi::OsString;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{
env,
ffi::OsString,
fs, io,
path::{Path, PathBuf},
process::Command,
};

include!("src/env.rs");

Expand All @@ -36,6 +38,23 @@ fn read_and_watch_env_os(name: &str) -> Option<OsString> {
env::var_os(name)
}

fn copy_recursively(src: &Path, dst: &Path) -> io::Result<()> {
if !dst.exists() {
fs::create_dir_all(dst)?;
}
for entry in fs::read_dir(src)? {
let entry = entry?;
let ft = entry.file_type()?;
if ft.is_dir() {
// There should be very few layer in the project, use recusion to keep simple.
copy_recursively(&entry.path(), &dst.join(entry.file_name()))?;
} else {
fs::copy(entry.path(), dst.join(entry.file_name()))?;
}
}
Ok(())
}

// TODO: split main functions and remove following allow.
#[allow(clippy::cognitive_complexity)]
fn main() {
Expand Down Expand Up @@ -123,10 +142,7 @@ fn main() {
fs::remove_dir_all(build_dir.clone()).unwrap();
}
// Copy jemalloc submodule to the OUT_DIR
let mut copy_options = fs_extra::dir::CopyOptions::new();
copy_options.overwrite = true;
copy_options.copy_inside = true;
fs_extra::dir::copy(&jemalloc_repo_dir, &build_dir, &copy_options)
copy_recursively(&jemalloc_repo_dir, &build_dir)
.expect("failed to copy jemalloc source code to OUT_DIR");
assert!(build_dir.exists());

Expand Down

0 comments on commit 725713e

Please sign in to comment.