jemalloc-sys: remove fs-extra (#47)

Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
This commit is contained in:
Jay 2023-02-03 14:37:52 +08:00 committed by GitHub
parent fa2ddc0014
commit 725713e565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 10 deletions

View File

@ -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"]

View File

@ -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");
@ -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() {
@ -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());