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

rust-src: include everything needed to compile libstd with jemalloc #42214

Merged
merged 1 commit into from
May 29, 2017
Merged
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
27 changes: 21 additions & 6 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
t!(fs::remove_dir_all(&image));
}

fn copy_src_dirs(build: &Build, src_dirs: &[&str], dst_dir: &Path) {
let filter_fn = move |path: &Path| {
fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_dir: &Path) {
fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
let spath = match path.to_str() {
Some(path) => path,
None => return false,
Expand All @@ -506,6 +506,11 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], dst_dir: &Path) {
}
}

let full_path = Path::new(dir).join(path);
if exclude_dirs.iter().any(|excl| full_path == Path::new(excl)) {
return false;
}

let excludes = [
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
Expand All @@ -515,13 +520,13 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], dst_dir: &Path) {
!path.iter()
.map(|s| s.to_str().unwrap())
.any(|s| excludes.contains(&s))
};
}

// Copy the directories using our filter
for item in src_dirs {
let dst = &dst_dir.join(item);
t!(fs::create_dir_all(dst));
cp_filtered(&build.src.join(item), dst, &filter_fn);
cp_filtered(&build.src.join(item), dst, &|path| filter_fn(exclude_dirs, item, path));
}
}

Expand All @@ -544,6 +549,7 @@ pub fn rust_src(build: &Build) {
"src/liballoc",
"src/liballoc_jemalloc",
"src/liballoc_system",
"src/libbacktrace",
"src/libcollections",
"src/libcompiler_builtins",
"src/libcore",
Expand All @@ -559,9 +565,18 @@ pub fn rust_src(build: &Build) {
"src/libstd_unicode",
"src/libunwind",
"src/rustc/libc_shim",
"src/libtest",
"src/libterm",
"src/libgetopts",
"src/compiler-rt",
"src/jemalloc",
];
let std_src_dirs_exclude = [
"src/compiler-rt/test",
"src/jemalloc/test/unit",
];

copy_src_dirs(build, &std_src_dirs[..], &dst_src);
copy_src_dirs(build, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src);

// Create source tarball in rust-installer format
let mut cmd = rust_installer(build);
Expand Down Expand Up @@ -608,7 +623,7 @@ pub fn plain_source_tarball(build: &Build) {
"src",
];

copy_src_dirs(build, &src_dirs[..], &plain_dst_src);
copy_src_dirs(build, &src_dirs[..], &[], &plain_dst_src);

// Copy the files normally
for item in &src_files {
Expand Down