]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/driver/config.rs
auto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis
[rust.git] / src / librustc / driver / config.rs
index 345877d9ab6c47beea8f81694eeccb00af7c462b..f4309d9e51b56f7ae14c84349c09fb896aa0fd94 100644 (file)
@@ -97,6 +97,10 @@ pub struct Options {
     pub color: ColorConfig,
     pub externs: HashMap<String, Vec<String>>,
     pub crate_name: Option<String>,
+    /// An optional name to use as the crate for std during std injection,
+    /// written `extern crate std = "name"`. Default to "std". Used by
+    /// out-of-tree drivers.
+    pub alt_std_name: Option<String>
 }
 
 /// Some reasonable defaults
@@ -124,6 +128,7 @@ pub fn basic_options() -> Options {
         color: Auto,
         externs: HashMap::new(),
         crate_name: None,
+        alt_std_name: None,
     }
 }
 
@@ -332,8 +337,12 @@ fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
         "prefer dynamic linking to static linking"),
     no_integrated_as: bool = (false, parse_bool,
         "use an external assembler rather than LLVM's integrated one"),
+    no_redzone: bool = (false, parse_bool,
+        "disable the use of the redzone"),
     relocation_model: String = ("pic".to_string(), parse_string,
          "choose the relocation model to use (llc -relocation-model for details)"),
+    code_model: String = ("default".to_string(), parse_string,
+         "choose the code model to use (llc -code-model for details)"),
     metadata: Vec<String> = (Vec::new(), parse_list,
          "metadata to mangle symbol names with"),
     extra_filename: String = ("".to_string(), parse_string,
@@ -381,12 +390,13 @@ pub fn default_lib_output() -> CrateType {
 
 pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
     let tos = match sess.targ_cfg.os {
-        abi::OsWin32 =>   InternedString::new("win32"),
-        abi::OsMacos =>   InternedString::new("macos"),
-        abi::OsLinux =>   InternedString::new("linux"),
-        abi::OsAndroid => InternedString::new("android"),
-        abi::OsFreebsd => InternedString::new("freebsd"),
-        abi::OsiOS =>     InternedString::new("ios"),
+        abi::OsWin32 =>     InternedString::new("win32"),
+        abi::OsMacos =>     InternedString::new("macos"),
+        abi::OsLinux =>     InternedString::new("linux"),
+        abi::OsAndroid =>   InternedString::new("android"),
+        abi::OsFreebsd =>   InternedString::new("freebsd"),
+        abi::OsDragonfly => InternedString::new("dragonfly"),
+        abi::OsiOS =>       InternedString::new("ios"),
     };
 
     // ARM is bi-endian, however using NDK seems to default
@@ -432,12 +442,6 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
     if sess.opts.test {
         append_configuration(&mut user_cfg, InternedString::new("test"))
     }
-    // If the user requested GC, then add the GC cfg
-    append_configuration(&mut user_cfg, if sess.opts.gc {
-        InternedString::new("gc")
-    } else {
-        InternedString::new("nogc")
-    });
     user_cfg.move_iter().collect::<Vec<_>>().append(default_cfg.as_slice())
 }
 
@@ -448,13 +452,14 @@ pub fn get_os(triple: &str) -> Option<abi::Os> {
     None
 }
 static os_names : &'static [(&'static str, abi::Os)] = &[
-    ("mingw32", abi::OsWin32),
-    ("win32",   abi::OsWin32),
-    ("darwin",  abi::OsMacos),
-    ("android", abi::OsAndroid),
-    ("linux",   abi::OsLinux),
-    ("freebsd", abi::OsFreebsd),
-    ("ios",     abi::OsiOS)];
+    ("mingw32",   abi::OsWin32),
+    ("win32",     abi::OsWin32),
+    ("darwin",    abi::OsMacos),
+    ("android",   abi::OsAndroid),
+    ("linux",     abi::OsLinux),
+    ("freebsd",   abi::OsFreebsd),
+    ("dragonfly", abi::OsDragonfly),
+    ("ios",       abi::OsiOS)];
 
 pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
     for &(arch, abi) in architecture_abis.iter() {
@@ -573,7 +578,7 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
             always = always colorize output;
             never  = never colorize output", "auto|always|never"),
         optmulti("", "extern", "Specify where an external rust library is located",
-                 "PATH"),
+                 "NAME=PATH"),
     )
 }
 
@@ -589,24 +594,10 @@ fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
 }
 
 pub fn build_session_options(matches: &getopts::Matches) -> Options {
-    let mut crate_types: Vec<CrateType> = Vec::new();
+
     let unparsed_crate_types = matches.opt_strs("crate-type");
-    for unparsed_crate_type in unparsed_crate_types.iter() {
-        for part in unparsed_crate_type.as_slice().split(',') {
-            let new_part = match part {
-                "lib"       => default_lib_output(),
-                "rlib"      => CrateTypeRlib,
-                "staticlib" => CrateTypeStaticlib,
-                "dylib"     => CrateTypeDylib,
-                "bin"       => CrateTypeExecutable,
-                _ => {
-                    early_error(format!("unknown crate type: `{}`",
-                                        part).as_slice())
-                }
-            };
-            crate_types.push(new_part)
-        }
-    }
+    let crate_types = parse_crate_types_from_list(unparsed_crate_types)
+        .unwrap_or_else(|e| early_error(e.as_slice()));
 
     let parse_only = matches.opt_present("parse-only");
     let no_trans = matches.opt_present("no-trans");
@@ -797,7 +788,31 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         color: color,
         externs: externs,
         crate_name: crate_name,
+        alt_std_name: None
+    }
+}
+
+pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
+
+    let mut crate_types: Vec<CrateType> = Vec::new();
+    for unparsed_crate_type in list_list.iter() {
+        for part in unparsed_crate_type.as_slice().split(',') {
+            let new_part = match part {
+                "lib"       => default_lib_output(),
+                "rlib"      => CrateTypeRlib,
+                "staticlib" => CrateTypeStaticlib,
+                "dylib"     => CrateTypeDylib,
+                "bin"       => CrateTypeExecutable,
+                _ => {
+                    return Err(format!("unknown crate type: `{}`",
+                                       part));
+                }
+            };
+            crate_types.push(new_part)
+        }
     }
+
+    return Ok(crate_types);
 }
 
 impl fmt::Show for CrateType {