Skip to content

Commit d17f0b0

Browse files
committed
rustbuild: Optimize build times slightly
As the entry point for building the Rust compiler, a good user experience hinges on this compiling quickly to get to the meat of the problem. To that end use `#[cfg]`-specific dependencies to avoid building Windows crates on Unix and drop the `regex` crate for now which was easily replacable with some string searching.
1 parent 4344f14 commit d17f0b0

File tree

5 files changed

+32
-115
lines changed

5 files changed

+32
-115
lines changed

src/Cargo.lock

+3-67
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ num_cpus = "0.2"
2727
toml = "0.1"
2828
getopts = "0.2"
2929
rustc-serialize = "0.3"
30-
winapi = "0.2"
31-
kernel32-sys = "0.2"
3230
gcc = { git = "https://github.com/alexcrichton/gcc-rs" }
3331
libc = "0.2"
3432
md5 = "0.1"
35-
regex = "0.1.73"
33+
34+
[target.'cfg(windows)'.dependencies]
35+
winapi = "0.2"
36+
kernel32-sys = "0.2"

src/bootstrap/dist.rs

+23-42
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use std::process::Command;
2525

2626
use {Build, Compiler};
2727
use util::{cp_r, libdir, is_dylib, cp_filtered, copy};
28-
use regex::{RegexSet, quote};
2928

3029
pub fn package_vers(build: &Build) -> &str {
3130
match &build.config.channel[..] {
@@ -315,49 +314,31 @@ pub fn rust_src(build: &Build) {
315314
"mk"
316315
];
317316

318-
// Exclude paths matching these wildcard expressions
319-
let excludes = [
320-
// exclude-vcs
321-
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules", ".gitattributes", ".cvsignore",
322-
".svn", ".arch-ids", "{arch}", "=RELEASE-ID", "=meta-update", "=update", ".bzr",
323-
".bzrignore", ".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
324-
// extensions
325-
"*~", "*.pyc",
326-
// misc
327-
"llvm/test/*/*.ll",
328-
"llvm/test/*/*.td",
329-
"llvm/test/*/*.s",
330-
"llvm/test/*/*/*.ll",
331-
"llvm/test/*/*/*.td",
332-
"llvm/test/*/*/*.s"
333-
];
334-
335-
// Construct a set of regexes for efficiently testing whether paths match one of the above
336-
// expressions.
337-
let regex_set = t!(RegexSet::new(
338-
// This converts a wildcard expression to a regex
339-
excludes.iter().map(|&s| {
340-
// Prefix ensures that matching starts on a path separator boundary
341-
r"^(.*[\\/])?".to_owned() + (
342-
// Escape the expression to produce a regex matching exactly that string
343-
&quote(s)
344-
// Replace slashes with a pattern matching either forward or backslash
345-
.replace(r"/", r"[\\/]")
346-
// Replace wildcards with a pattern matching a single path segment, ie. containing
347-
// no slashes.
348-
.replace(r"\*", r"[^\\/]*")
349-
// Suffix anchors to the end of the path
350-
) + "$"
351-
})
352-
));
353-
354-
// Create a filter which skips files which match the regex set or contain invalid unicode
355317
let filter_fn = move |path: &Path| {
356-
if let Some(path) = path.to_str() {
357-
!regex_set.is_match(path)
358-
} else {
359-
false
318+
let spath = match path.to_str() {
319+
Some(path) => path,
320+
None => return false,
321+
};
322+
if spath.ends_with("~") || spath.ends_with(".pyc") {
323+
return false
360324
}
325+
if spath.contains("llvm/test") || spath.contains("llvm\\test") {
326+
if spath.ends_with(".ll") ||
327+
spath.ends_with(".td") ||
328+
spath.ends_with(".s") {
329+
return false
330+
}
331+
}
332+
333+
let excludes = [
334+
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
335+
".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
336+
"=RELEASE-ID", "=meta-update", "=update", ".bzr", ".bzrignore",
337+
".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
338+
];
339+
!path.iter()
340+
.map(|s| s.to_str().unwrap())
341+
.any(|s| excludes.contains(&s))
361342
};
362343

363344
// Copy the directories using our filter

src/bootstrap/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ extern crate md5;
2626
extern crate num_cpus;
2727
extern crate rustc_serialize;
2828
extern crate toml;
29-
extern crate regex;
3029

3130
use std::collections::HashMap;
3231
use std::env;

src/tools/compiletest/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ opt-level = 2
1212

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

0 commit comments

Comments
 (0)