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

jemalloc-sys: remove fs-extra #47

Merged
merged 2 commits into from
Feb 3, 2023
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
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