Skip to content

Commit 802b6db

Browse files
Cleanup dist
1 parent c6ece96 commit 802b6db

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

src/bootstrap/dist.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn docs(build: &Build, stage: u32, host: &str) {
9797
}
9898

9999
fn find_files(files: &[&str], path: &[PathBuf]) -> Vec<PathBuf> {
100-
let mut found = Vec::new();
100+
let mut found = Vec::with_capacity(files.len());
101101

102102
for file in files {
103103
let file_path =
@@ -119,17 +119,9 @@ fn make_win_dist(rust_root: &Path, plat_root: &Path, target_triple: &str, build:
119119
//Ask gcc where it keeps its stuff
120120
let mut cmd = Command::new(build.cc(target_triple));
121121
cmd.arg("-print-search-dirs");
122-
build.run_quiet(&mut cmd);
123-
let gcc_out =
124-
String::from_utf8(
125-
cmd
126-
.output()
127-
.expect("failed to execute gcc")
128-
.stdout).expect("gcc.exe output was not utf8");
129-
130-
let mut bin_path: Vec<_> =
131-
env::split_paths(&env::var_os("PATH").unwrap_or_default())
132-
.collect();
122+
let gcc_out = output(&mut cmd);
123+
124+
let mut bin_path: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap_or_default()).collect();
133125
let mut lib_path = Vec::new();
134126

135127
for line in gcc_out.lines() {
@@ -140,7 +132,7 @@ fn make_win_dist(rust_root: &Path, plat_root: &Path, target_triple: &str, build:
140132
line[(idx + 1)..]
141133
.trim_left_matches(trim_chars)
142134
.split(';')
143-
.map(|s| PathBuf::from(s));
135+
.map(PathBuf::from);
144136

145137
if key == "programs" {
146138
bin_path.extend(value);
@@ -149,15 +141,15 @@ fn make_win_dist(rust_root: &Path, plat_root: &Path, target_triple: &str, build:
149141
}
150142
}
151143

152-
let target_tools = vec!["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", "libwinpthread-1.dll"];
144+
let target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", "libwinpthread-1.dll"];
153145
let mut rustc_dlls = vec!["libstdc++-6.dll", "libwinpthread-1.dll"];
154146
if target_triple.starts_with("i686-") {
155147
rustc_dlls.push("libgcc_s_dw2-1.dll");
156148
} else {
157149
rustc_dlls.push("libgcc_s_seh-1.dll");
158150
}
159151

160-
let target_libs = vec![ //MinGW libs
152+
let target_libs = [ //MinGW libs
161153
"libgcc.a",
162154
"libgcc_eh.a",
163155
"libgcc_s.a",
@@ -203,7 +195,7 @@ fn make_win_dist(rust_root: &Path, plat_root: &Path, target_triple: &str, build:
203195
let target_libs = find_files(&target_libs, &lib_path);
204196

205197
fn copy_to_folder(src: &Path, dest_folder: &Path) {
206-
let file_name = src.file_name().unwrap().to_os_string();
198+
let file_name = src.file_name().unwrap();
207199
let dest = dest_folder.join(file_name);
208200
copy(src, &dest);
209201
}
@@ -234,8 +226,6 @@ fn make_win_dist(rust_root: &Path, plat_root: &Path, target_triple: &str, build:
234226
///
235227
/// This contains all the bits and pieces to run the MinGW Windows targets
236228
/// without any extra installed software (e.g. we bundle gcc, libraries, etc).
237-
/// Currently just shells out to a python script, but that should be rewritten
238-
/// in Rust.
239229
pub fn mingw(build: &Build, host: &str) {
240230
println!("Dist mingw ({})", host);
241231
let name = pkgname(build, "rust-mingw");
@@ -366,9 +356,9 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
366356
pub fn debugger_scripts(build: &Build,
367357
sysroot: &Path,
368358
host: &str) {
359+
let dst = sysroot.join("lib/rustlib/etc");
360+
t!(fs::create_dir_all(&dst));
369361
let cp_debugger_script = |file: &str| {
370-
let dst = sysroot.join("lib/rustlib/etc");
371-
t!(fs::create_dir_all(&dst));
372362
install(&build.src.join("src/etc/").join(file), &dst, 0o644);
373363
};
374364
if host.contains("windows-msvc") {
@@ -595,7 +585,7 @@ pub fn rust_src(build: &Build) {
595585
t!(fs::remove_dir_all(&image));
596586
}
597587

598-
const CARGO_VENDOR_VERSION: &'static str = "0.1.4";
588+
const CARGO_VENDOR_VERSION: &str = "0.1.4";
599589

600590
/// Creates the plain source tarball
601591
pub fn plain_source_tarball(build: &Build) {

0 commit comments

Comments
 (0)