diff options
| author | Ian Douglas Scott <ian@iandouglasscott.com> | 2017-06-22 11:51:32 -0700 |
|---|---|---|
| committer | Ian Douglas Scott <ian@iandouglasscott.com> | 2017-06-22 11:51:32 -0700 |
| commit | f98ffb5bc348d1b11f10ebd5f4c5e2fe2813e167 (patch) | |
| tree | cfc7e212079d0b2cf681ff3ae768cad177ad58b9 /src/bootstrap/lib.rs | |
| parent | 526afcb0a341c6036c069e113ebecf574c861c9f (diff) | |
| download | rust-f98ffb5bc348d1b11f10ebd5f4c5e2fe2813e167.tar.gz rust-f98ffb5bc348d1b11f10ebd5f4c5e2fe2813e167.zip | |
Make Build.cxx() return a Result instead of panicking
Diffstat (limited to 'src/bootstrap/lib.rs')
| -rw-r--r-- | src/bootstrap/lib.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 3a43cc0c29d..ce7cde8fc94 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -450,9 +450,12 @@ impl Build { // FIXME: the guard against msvc shouldn't need to be here if !target.contains("msvc") { cargo.env(format!("CC_{}", target), self.cc(target)) - .env(format!("CXX_{}", target), self.cxx(target)) .env(format!("AR_{}", target), self.ar(target).unwrap()) // only msvc is None .env(format!("CFLAGS_{}", target), self.cflags(target).join(" ")); + + if let Ok(cxx) = self.cxx(target) { + cargo.env(format!("CXX_{}", target), cxx); + } } if self.config.extended && compiler.is_final_stage(self) { @@ -839,13 +842,13 @@ impl Build { self.cc[target].1.as_ref().map(|p| &**p) } - /// Returns the path to the C++ compiler for the target specified, may panic - /// if no C++ compiler was configured for the target. - fn cxx(&self, target: &str) -> &Path { + /// Returns the path to the C++ compiler for the target specified. + fn cxx(&self, target: &str) -> Result<&Path, String> { match self.cxx.get(target) { - Some(p) => p.path(), - None => panic!("\n\ntarget `{}` is not configured as a host, - only as a target\n\n", target), + Some(p) => Ok(p.path()), + None => Err(format!( + "target `{}` is not configured as a host, only as a target", + target)) } } |
