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

Rollup of 14 pull requests #42193

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
770bd57
Add `'static` and `Send` constraints explanations to `thread::spawn`
May 13, 2017
173f693
Rewrite make-win-dist.py in Rust
wesleywiser May 6, 2017
a256630
Add an option to the parser to avoid parsing out of line modules
nrc May 17, 2017
37b9ee2
Make assignments to `Copy` union fields safe
petrochenkov May 18, 2017
59b65b3
Use parameter environment associated with field use, not field defini…
petrochenkov May 18, 2017
9ad0dba
remove "much" from unicode diagnostic
euclio May 20, 2017
f166bd9
Make RangeInclusive just a two-field struct
scottmcm Apr 24, 2017
7eaca60
Return a correct size_hint for degenerate inclusive ranges
scottmcm May 21, 2017
66237af
Fix building without backtrace feature, which was broken in ca8b754
ids1024 May 21, 2017
f4147e5
Implement requires_synchronized_create() for Redox
ids1024 May 21, 2017
0b85b64
libstd/sync/mpsc: relicense under rust license
dvyukov May 22, 2017
14b767d
Add example of recursive drop to Drop trait.
Havvy May 22, 2017
ca909c8
Add example of variable declaration drop order to Drop trait.
Havvy May 22, 2017
d7927ff
Add description of how values are dropped to Drop trait.
Havvy May 22, 2017
5f4b0ff
Fix trailing whitespace.
Havvy May 22, 2017
7eebabe
Create the bin dir
wesleywiser May 23, 2017
b41b294
Suggested changes by birkenfeld
Havvy May 23, 2017
e860655
Remove some needless // gate-test- comments
est31 May 23, 2017
2aa6700
bootstrap: Actually respect verbosity setting in config.toml
devurandom May 24, 2017
604f716
bootstrap: Make bootstrap verbose if requested
devurandom May 24, 2017
cd86a9b
bootstrap: Use common run() function to call cargo
devurandom May 24, 2017
5558c64
Change error count messages
citizen428 May 22, 2017
216a12c
Update Cargo submodule
alexcrichton May 24, 2017
4cbfa70
Rollup merge of #41932 - wesleywiser:py-to-rust, r=alexcrichton
Mark-Simulacrum May 24, 2017
2fa7110
Rollup merge of #41980 - gamazeps:thread-send, r=steveklabnik
Mark-Simulacrum May 24, 2017
505ef6e
Rollup merge of #42071 - nrc:parse-mods, r=nikomatsakis
Mark-Simulacrum May 24, 2017
df9bf0a
Rollup merge of #42083 - petrochenkov:safeassign, r=nikomatsakis
Mark-Simulacrum May 24, 2017
ce42e6c
Rollup merge of #42120 - euclio:unicode, r=arielb1
Mark-Simulacrum May 24, 2017
933f3ee
Rollup merge of #42134 - scottmcm:rangeinclusive-struct, r=aturon
Mark-Simulacrum May 24, 2017
0c3bc8d
Rollup merge of #42141 - ids1024:nobacktrace, r=aturon
Mark-Simulacrum May 24, 2017
ee8dda4
Rollup merge of #42142 - ids1024:redox, r=aturon
Mark-Simulacrum May 24, 2017
a01f363
Rollup merge of #42149 - dvyukov:license, r=brson
Mark-Simulacrum May 24, 2017
34907f0
Rollup merge of #42150 - citizen428:feature/error-count-messages, r=M…
Mark-Simulacrum May 24, 2017
caf881a
Rollup merge of #42159 - Havvy:doc-drop, r=steveklabnik
Mark-Simulacrum May 24, 2017
3958dbe
Rollup merge of #42177 - est31:master, r=Mark-Simulacrum
Mark-Simulacrum May 24, 2017
8c88656
Rollup merge of #42186 - devurandom:fix/bootstrap-verbose, r=alexcric…
Mark-Simulacrum May 24, 2017
eacb51b
Rollup merge of #42191 - alexcrichton:update-cargo, r=Mark-Simulacrum
Mark-Simulacrum May 24, 2017
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
39 changes: 21 additions & 18 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def unpack(tarball, dst, verbose=False, match=None):
shutil.move(tp, fp)
shutil.rmtree(os.path.join(dst, fname))

def run(args, verbose=False, exception=False, cwd=None):
def run(args, verbose=False, exception=False, cwd=None, env=None):
if verbose:
print("running: " + ' '.join(args))
sys.stdout.flush()
# Use Popen here instead of call() as it apparently allows powershell on
# Windows to not lock up waiting for input presumably.
ret = subprocess.Popen(args, cwd=cwd)
ret = subprocess.Popen(args, cwd=cwd, env=env)
code = ret.wait()
if code != 0:
err = "failed to run: " + ' '.join(args)
Expand Down Expand Up @@ -385,17 +385,15 @@ def build_bootstrap(self):
raise Exception("no cargo executable found at `%s`" % self.cargo())
args = [self.cargo(), "build", "--manifest-path",
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
if self.verbose:
args.append("--verbose")
if self.verbose > 1:
args.append("--verbose")
if self.use_locked_deps:
args.append("--locked")
if self.use_vendored_sources:
args.append("--frozen")
self.run(args, env)

def run(self, args, env=None, cwd=None):
proc = subprocess.Popen(args, env=env, cwd=cwd)
ret = proc.wait()
if ret != 0:
sys.exit(ret)
run(args, env=env, verbose=self.verbose)

def output(self, args, env=None, cwd=None):
default_encoding = sys.getdefaultencoding()
Expand Down Expand Up @@ -567,7 +565,7 @@ def update_submodules(self):
path = line[1:].split(' ')[1]
submodules.append([path, line[0]])

self.run(["git", "submodule", "sync"], cwd=self.rust_root)
run(["git", "submodule", "sync"], cwd=self.rust_root)

for submod in submodules:
path, status = submod
Expand All @@ -580,15 +578,15 @@ def update_submodules(self):
submod_path = os.path.join(self.rust_root, path)

if status == ' ':
self.run(["git", "reset", "--hard"], cwd=submod_path)
self.run(["git", "clean", "-fdx"], cwd=submod_path)
run(["git", "reset", "--hard"], cwd=submod_path)
run(["git", "clean", "-fdx"], cwd=submod_path)
elif status == '+':
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
self.run(["git", "reset", "--hard"], cwd=submod_path)
self.run(["git", "clean", "-fdx"], cwd=submod_path)
run(["git", "submodule", "update", path], cwd=self.rust_root)
run(["git", "reset", "--hard"], cwd=submod_path)
run(["git", "clean", "-fdx"], cwd=submod_path)
elif status == '-':
self.run(["git", "submodule", "init", path], cwd=self.rust_root)
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
run(["git", "submodule", "init", path], cwd=self.rust_root)
run(["git", "submodule", "update", path], cwd=self.rust_root)
else:
raise ValueError('unknown submodule status: ' + status)

Expand Down Expand Up @@ -620,6 +618,11 @@ def bootstrap():
except:
pass

if '\nverbose = 2' in rb.config_toml:
rb.verbose = 2
elif '\nverbose = 1' in rb.config_toml:
rb.verbose = 1

rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
'CFG_ENABLE_VENDOR' in rb.config_mk

Expand Down Expand Up @@ -676,7 +679,7 @@ def bootstrap():
env["BUILD"] = rb.build
env["SRC"] = rb.rust_root
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
rb.run(args, env)
run(args, env=env, verbose=rb.verbose)

def main():
start_time = time()
Expand Down
154 changes: 137 additions & 17 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,140 @@ pub fn docs(build: &Build, stage: u32, host: &str) {
}
}

fn find_files(files: &[&str], path: &[PathBuf]) -> Vec<PathBuf> {
let mut found = Vec::new();

for file in files {
let file_path =
path.iter()
.map(|dir| dir.join(file))
.find(|p| p.exists());

if let Some(file_path) = file_path {
found.push(file_path);
} else {
panic!("Could not find '{}' in {:?}", file, path);
}
}

found
}

fn make_win_dist(rust_root: &Path, plat_root: &Path, target_triple: &str, build: &Build) {
//Ask gcc where it keeps its stuff
let mut cmd = Command::new(build.cc(target_triple));
cmd.arg("-print-search-dirs");
build.run_quiet(&mut cmd);
let gcc_out =
String::from_utf8(
cmd
.output()
.expect("failed to execute gcc")
.stdout).expect("gcc.exe output was not utf8");

let mut bin_path: Vec<_> =
env::split_paths(&env::var_os("PATH").unwrap_or_default())
.collect();
let mut lib_path = Vec::new();

for line in gcc_out.lines() {
let idx = line.find(':').unwrap();
let key = &line[..idx];
let trim_chars: &[_] = &[' ', '='];
let value =
line[(idx + 1)..]
.trim_left_matches(trim_chars)
.split(';')
.map(|s| PathBuf::from(s));

if key == "programs" {
bin_path.extend(value);
} else if key == "libraries" {
lib_path.extend(value);
}
}

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

let target_libs = vec![ //MinGW libs
"libgcc.a",
"libgcc_eh.a",
"libgcc_s.a",
"libm.a",
"libmingw32.a",
"libmingwex.a",
"libstdc++.a",
"libiconv.a",
"libmoldname.a",
"libpthread.a",
//Windows import libs
"libadvapi32.a",
"libbcrypt.a",
"libcomctl32.a",
"libcomdlg32.a",
"libcrypt32.a",
"libgdi32.a",
"libimagehlp.a",
"libiphlpapi.a",
"libkernel32.a",
"libmsvcrt.a",
"libodbc32.a",
"libole32.a",
"liboleaut32.a",
"libopengl32.a",
"libpsapi.a",
"librpcrt4.a",
"libsetupapi.a",
"libshell32.a",
"libuser32.a",
"libuserenv.a",
"libuuid.a",
"libwinhttp.a",
"libwinmm.a",
"libwinspool.a",
"libws2_32.a",
"libwsock32.a",
];

//Find mingw artifacts we want to bundle
let target_tools = find_files(&target_tools, &bin_path);
let rustc_dlls = find_files(&rustc_dlls, &bin_path);
let target_libs = find_files(&target_libs, &lib_path);

fn copy_to_folder(src: &Path, dest_folder: &Path) {
let file_name = src.file_name().unwrap().to_os_string();
let dest = dest_folder.join(file_name);
copy(src, &dest);
}

//Copy runtime dlls next to rustc.exe
let dist_bin_dir = rust_root.join("bin/");
fs::create_dir_all(&dist_bin_dir).expect("creating dist_bin_dir failed");
for src in rustc_dlls {
copy_to_folder(&src, &dist_bin_dir);
}

//Copy platform tools to platform-specific bin directory
let target_bin_dir = plat_root.join("lib").join("rustlib").join(target_triple).join("bin");
fs::create_dir_all(&target_bin_dir).expect("creating target_bin_dir failed");
for src in target_tools {
copy_to_folder(&src, &target_bin_dir);
}

//Copy platform libs to platform-specific lib directory
let target_lib_dir = plat_root.join("lib").join("rustlib").join(target_triple).join("lib");
fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed");
for src in target_libs {
copy_to_folder(&src, &target_lib_dir);
}
}

/// Build the `rust-mingw` installer component.
///
/// This contains all the bits and pieces to run the MinGW Windows targets
Expand All @@ -109,18 +243,11 @@ pub fn mingw(build: &Build, host: &str) {
let _ = fs::remove_dir_all(&image);
t!(fs::create_dir_all(&image));

// The first argument to the script is a "temporary directory" which is just
// The first argument is a "temporary directory" which is just
// thrown away (this contains the runtime DLLs included in the rustc package
// above) and the second argument is where to place all the MinGW components
// (which is what we want).
//
// FIXME: this script should be rewritten into Rust
let mut cmd = Command::new(build.python());
cmd.arg(build.src.join("src/etc/make-win-dist.py"))
.arg(tmpdir(build))
.arg(&image)
.arg(host);
build.run(&mut cmd);
make_win_dist(&tmpdir(build), &image, host, &build);

let mut cmd = rust_installer(build);
cmd.arg("generate")
Expand Down Expand Up @@ -172,15 +299,8 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
// anything requiring us to distribute a license, but it's likely the
// install will *also* include the rust-mingw package, which also needs
// licenses, so to be safe we just include it here in all MinGW packages.
//
// FIXME: this script should be rewritten into Rust
if host.contains("pc-windows-gnu") {
let mut cmd = Command::new(build.python());
cmd.arg(build.src.join("src/etc/make-win-dist.py"))
.arg(&image)
.arg(tmpdir(build))
.arg(host);
build.run(&mut cmd);
make_win_dist(&image, &tmpdir(build), host, build);

let dst = image.join("share/doc");
t!(fs::create_dir_all(&dst));
Expand Down
126 changes: 0 additions & 126 deletions src/etc/make-win-dist.py

This file was deleted.

Loading