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

rustbuild: Optimize build times slightly #37027

Merged
merged 1 commit into from
Oct 8, 2016
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
70 changes: 3 additions & 67 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ num_cpus = "0.2"
toml = "0.1"
getopts = "0.2"
rustc-serialize = "0.3"
winapi = "0.2"
kernel32-sys = "0.2"
gcc = { git = "https://github.com/alexcrichton/gcc-rs" }
libc = "0.2"
md5 = "0.1"
regex = "0.1.73"

[target.'cfg(windows)'.dependencies]
winapi = "0.2"
kernel32-sys = "0.2"
65 changes: 23 additions & 42 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use std::process::Command;

use {Build, Compiler};
use util::{cp_r, libdir, is_dylib, cp_filtered, copy};
use regex::{RegexSet, quote};

pub fn package_vers(build: &Build) -> &str {
match &build.config.channel[..] {
Expand Down Expand Up @@ -315,49 +314,31 @@ pub fn rust_src(build: &Build) {
"mk"
];

// Exclude paths matching these wildcard expressions
let excludes = [
// exclude-vcs
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules", ".gitattributes", ".cvsignore",
".svn", ".arch-ids", "{arch}", "=RELEASE-ID", "=meta-update", "=update", ".bzr",
".bzrignore", ".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
// extensions
"*~", "*.pyc",
// misc
"llvm/test/*/*.ll",
"llvm/test/*/*.td",
"llvm/test/*/*.s",
"llvm/test/*/*/*.ll",
"llvm/test/*/*/*.td",
"llvm/test/*/*/*.s"
];

// Construct a set of regexes for efficiently testing whether paths match one of the above
// expressions.
let regex_set = t!(RegexSet::new(
// This converts a wildcard expression to a regex
excludes.iter().map(|&s| {
// Prefix ensures that matching starts on a path separator boundary
r"^(.*[\\/])?".to_owned() + (
// Escape the expression to produce a regex matching exactly that string
&quote(s)
// Replace slashes with a pattern matching either forward or backslash
.replace(r"/", r"[\\/]")
// Replace wildcards with a pattern matching a single path segment, ie. containing
// no slashes.
.replace(r"\*", r"[^\\/]*")
// Suffix anchors to the end of the path
) + "$"
})
));

// Create a filter which skips files which match the regex set or contain invalid unicode
let filter_fn = move |path: &Path| {
if let Some(path) = path.to_str() {
!regex_set.is_match(path)
} else {
false
let spath = match path.to_str() {
Some(path) => path,
None => return false,
};
if spath.ends_with("~") || spath.ends_with(".pyc") {
return false
}
if spath.contains("llvm/test") || spath.contains("llvm\\test") {
if spath.ends_with(".ll") ||
spath.ends_with(".td") ||
spath.ends_with(".s") {
return false
}
}

let excludes = [
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
"=RELEASE-ID", "=meta-update", "=update", ".bzr", ".bzrignore",
".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
];
!path.iter()
.map(|s| s.to_str().unwrap())
.any(|s| excludes.contains(&s))
};

// Copy the directories using our filter
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extern crate md5;
extern crate num_cpus;
extern crate rustc_serialize;
extern crate toml;
extern crate regex;

use std::collections::HashMap;
use std::env;
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ opt-level = 2

[dependencies]
log = "0.3"
env_logger = "0.3"
serialize = { path = "../../libserialize" }
env_logger = { version = "0.3.5", default-features = false }
serialize = { path = "../../libserialize" }