2012-12-03 16:48:01 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-04-16 13:56:39 +09:00
|
|
|
use common::Config;
|
2011-07-30 21:11:14 -07:00
|
|
|
|
2013-12-08 02:55:28 -05:00
|
|
|
#[cfg(target_os = "win32")]
|
2013-06-30 19:36:55 -07:00
|
|
|
use std::os::getenv;
|
2013-03-01 10:44:43 -08:00
|
|
|
|
2013-09-03 19:34:23 +09:00
|
|
|
/// Conversion table from triple OS name to Rust SYSNAME
|
|
|
|
static OS_TABLE: &'static [(&'static str, &'static str)] = &[
|
|
|
|
("mingw32", "win32"),
|
|
|
|
("win32", "win32"),
|
|
|
|
("darwin", "macos"),
|
|
|
|
("android", "android"),
|
|
|
|
("linux", "linux"),
|
|
|
|
("freebsd", "freebsd"),
|
|
|
|
];
|
|
|
|
|
|
|
|
pub fn get_os(triple: &str) -> &'static str {
|
|
|
|
for &(triple_os, os) in OS_TABLE.iter() {
|
|
|
|
if triple.contains(triple_os) {
|
|
|
|
return os
|
|
|
|
}
|
|
|
|
}
|
2013-10-21 13:08:31 -07:00
|
|
|
fail!("Cannot determine OS from triple");
|
2013-09-03 19:34:23 +09:00
|
|
|
}
|
|
|
|
|
2013-12-08 02:55:28 -05:00
|
|
|
#[cfg(target_os = "win32")]
|
2014-05-22 16:57:53 -07:00
|
|
|
pub fn make_new_path(path: &str) -> String {
|
2011-07-30 21:11:14 -07:00
|
|
|
|
|
|
|
// Windows just uses PATH as the library search path, so we have to
|
|
|
|
// maintain the current value while adding our own
|
2014-05-14 20:47:24 -07:00
|
|
|
match getenv(lib_path_env_var().as_slice()) {
|
2012-12-28 11:28:36 -05:00
|
|
|
Some(curr) => {
|
2014-05-27 20:44:58 -07:00
|
|
|
format!("{}{}{}", path, path_div(), curr)
|
2011-09-29 18:30:00 -07:00
|
|
|
}
|
2014-06-05 09:15:19 +02:00
|
|
|
None => path.to_str()
|
2011-07-30 21:11:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "win32")]
|
2014-05-25 03:17:19 -07:00
|
|
|
pub fn lib_path_env_var() -> String { "PATH".to_string() }
|
2011-07-30 21:11:14 -07:00
|
|
|
|
2011-09-29 18:30:00 -07:00
|
|
|
#[cfg(target_os = "win32")]
|
2014-05-25 03:17:19 -07:00
|
|
|
pub fn path_div() -> String { ";".to_string() }
|
2011-09-29 18:30:00 -07:00
|
|
|
|
2014-05-22 16:57:53 -07:00
|
|
|
pub fn logv(config: &Config, s: String) {
|
2013-10-21 13:08:31 -07:00
|
|
|
debug!("{}", s);
|
2014-01-09 21:06:55 +11:00
|
|
|
if config.verbose { println!("{}", s); }
|
2011-07-30 21:11:14 -07:00
|
|
|
}
|