1
Fork 0

Introduce a TargetTriple enum to support absolute target paths

This commit is contained in:
Philipp Oppermann 2018-03-14 15:27:06 +01:00
parent b4aa80dd73
commit 3908b2e443
12 changed files with 118 additions and 56 deletions

View file

@ -21,7 +21,7 @@ use session::search_paths::SearchPaths;
use ich::StableHashingContext; use ich::StableHashingContext;
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel}; use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use rustc_back::target::Target; use rustc_back::target::{Target, TargetTriple};
use rustc_data_structures::stable_hasher::ToStableHashKey; use rustc_data_structures::stable_hasher::ToStableHashKey;
use lint; use lint;
use middle::cstore; use middle::cstore;
@ -367,7 +367,7 @@ top_level_options!(
libs: Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> [TRACKED], libs: Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> [TRACKED],
maybe_sysroot: Option<PathBuf> [TRACKED], maybe_sysroot: Option<PathBuf> [TRACKED],
target_triple: String [TRACKED], target_triple: TargetTriple [TRACKED],
test: bool [TRACKED], test: bool [TRACKED],
error_format: ErrorOutputType [UNTRACKED], error_format: ErrorOutputType [UNTRACKED],
@ -567,7 +567,7 @@ pub fn basic_options() -> Options {
output_types: OutputTypes(BTreeMap::new()), output_types: OutputTypes(BTreeMap::new()),
search_paths: SearchPaths::new(), search_paths: SearchPaths::new(),
maybe_sysroot: None, maybe_sysroot: None,
target_triple: host_triple().to_string(), target_triple: TargetTriple::from_triple(host_triple()),
test: false, test: false,
incremental: None, incremental: None,
debugging_opts: basic_debugging_options(), debugging_opts: basic_debugging_options(),
@ -1903,9 +1903,15 @@ pub fn build_session_options_and_crate_config(
let cg = cg; let cg = cg;
let sysroot_opt = matches.opt_str("sysroot").map(|m| PathBuf::from(&m)); let sysroot_opt = matches.opt_str("sysroot").map(|m| PathBuf::from(&m));
let target = matches let target_triple = if let Some(target) = matches.opt_str("target") {
.opt_str("target") if target.ends_with(".json") {
.unwrap_or(host_triple().to_string()); TargetTriple::TargetPath(PathBuf::from(target))
} else {
TargetTriple::TargetTriple(target)
}
} else {
TargetTriple::from_triple(host_triple())
};
let opt_level = { let opt_level = {
if matches.opt_present("O") { if matches.opt_present("O") {
if cg.opt_level.is_some() { if cg.opt_level.is_some() {
@ -2113,7 +2119,7 @@ pub fn build_session_options_and_crate_config(
output_types: OutputTypes(output_types), output_types: OutputTypes(output_types),
search_paths, search_paths,
maybe_sysroot: sysroot_opt, maybe_sysroot: sysroot_opt,
target_triple: target, target_triple,
test, test,
incremental, incremental,
debugging_opts, debugging_opts,
@ -2264,6 +2270,7 @@ mod dep_tracking {
Passes, Sanitizer}; Passes, Sanitizer};
use syntax::feature_gate::UnstableFeatures; use syntax::feature_gate::UnstableFeatures;
use rustc_back::{PanicStrategy, RelroLevel}; use rustc_back::{PanicStrategy, RelroLevel};
use rustc_back::target::TargetTriple;
pub trait DepTrackingHash { pub trait DepTrackingHash {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType); fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType);
@ -2323,6 +2330,7 @@ mod dep_tracking {
impl_dep_tracking_hash_via_hash!(Sanitizer); impl_dep_tracking_hash_via_hash!(Sanitizer);
impl_dep_tracking_hash_via_hash!(Option<Sanitizer>); impl_dep_tracking_hash_via_hash!(Option<Sanitizer>);
impl_dep_tracking_hash_via_hash!(Edition); impl_dep_tracking_hash_via_hash!(Edition);
impl_dep_tracking_hash_via_hash!(TargetTriple);
impl_dep_tracking_hash_for_sortable_vec_of!(String); impl_dep_tracking_hash_for_sortable_vec_of!(String);
impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf); impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf);

View file

@ -42,7 +42,7 @@ use syntax::feature_gate::AttributeType;
use syntax_pos::{MultiSpan, Span}; use syntax_pos::{MultiSpan, Span};
use rustc_back::{LinkerFlavor, PanicStrategy}; use rustc_back::{LinkerFlavor, PanicStrategy};
use rustc_back::target::Target; use rustc_back::target::{Target, TargetTriple};
use rustc_data_structures::flock; use rustc_data_structures::flock;
use jobserver::Client; use jobserver::Client;
@ -707,7 +707,7 @@ impl Session {
pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch { pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch {
filesearch::FileSearch::new( filesearch::FileSearch::new(
self.sysroot(), self.sysroot(),
&self.opts.target_triple, self.opts.target_triple.triple(),
&self.opts.search_paths, &self.opts.search_paths,
kind, kind,
) )
@ -1085,7 +1085,8 @@ pub fn build_session_(
span_diagnostic: errors::Handler, span_diagnostic: errors::Handler,
codemap: Lrc<codemap::CodeMap>, codemap: Lrc<codemap::CodeMap>,
) -> Session { ) -> Session {
let host = match Target::search(config::host_triple()) { let host_triple = TargetTriple::from_triple(config::host_triple());
let host = match Target::search(&host_triple) {
Ok(t) => t, Ok(t) => t,
Err(e) => { Err(e) => {
span_diagnostic span_diagnostic

View file

@ -47,6 +47,8 @@
use serialize::json::{Json, ToJson}; use serialize::json::{Json, ToJson};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::default::Default; use std::default::Default;
use std::fmt;
use std::path::{Path, PathBuf};
use syntax::abi::{Abi, lookup as lookup_abi}; use syntax::abi::{Abi, lookup as lookup_abi};
use {LinkerFlavor, PanicStrategy, RelroLevel}; use {LinkerFlavor, PanicStrategy, RelroLevel};
@ -824,11 +826,10 @@ impl Target {
/// ///
/// The error string could come from any of the APIs called, including /// The error string could come from any of the APIs called, including
/// filesystem access and JSON decoding. /// filesystem access and JSON decoding.
pub fn search(target: &str) -> Result<Target, String> { pub fn search(target_triple: &TargetTriple) -> Result<Target, String> {
use std::env; use std::env;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs; use std::fs;
use std::path::{Path, PathBuf};
use serialize::json; use serialize::json;
fn load_file(path: &Path) -> Result<Target, String> { fn load_file(path: &Path) -> Result<Target, String> {
@ -838,35 +839,40 @@ impl Target {
Target::from_json(obj) Target::from_json(obj)
} }
if let Ok(t) = load_specific(target) { match target_triple {
return Ok(t) &TargetTriple::TargetTriple(ref target_triple) => {
} // check if triple is in list of supported targets
if let Ok(t) = load_specific(target_triple) {
return Ok(t)
}
let path = Path::new(target); // search for a file named `target_triple`.json in RUST_TARGET_PATH
let path = {
let mut target = target_triple.to_string();
target.push_str(".json");
PathBuf::from(target)
};
if path.is_file() { let target_path = env::var_os("RUST_TARGET_PATH")
return load_file(&path); .unwrap_or(OsString::new());
}
let path = { // FIXME 16351: add a sane default search path?
let mut target = target.to_string();
target.push_str(".json");
PathBuf::from(target)
};
let target_path = env::var_os("RUST_TARGET_PATH") for dir in env::split_paths(&target_path) {
.unwrap_or(OsString::new()); let p = dir.join(&path);
if p.is_file() {
// FIXME 16351: add a sane default search path? return load_file(&p);
}
for dir in env::split_paths(&target_path) { }
let p = dir.join(&path); Err(format!("Could not find specification for target {:?}", target_triple))
if p.is_file() { }
return load_file(&p); &TargetTriple::TargetPath(ref target_path) => {
if target_path.is_file() {
return load_file(&target_path);
}
Err(format!("Target path {:?} is not a valid file", target_path))
} }
} }
Err(format!("Could not find specification for target {:?}", target))
} }
} }
@ -1014,3 +1020,36 @@ fn maybe_jemalloc() -> Option<String> {
None None
} }
} }
/// Either a target triple string or a path to a JSON file.
#[derive(PartialEq, Clone, Debug, Hash, RustcEncodable, RustcDecodable)]
pub enum TargetTriple {
TargetTriple(String),
TargetPath(PathBuf),
}
impl TargetTriple {
/// Creates a target target from the passed target triple string.
pub fn from_triple(triple: &str) -> Self {
TargetTriple::TargetTriple(triple.to_string())
}
/// Returns a string triple for this target.
///
/// If this target is a path, the file name (without extension) is returned.
pub fn triple(&self) -> &str {
match self {
&TargetTriple::TargetTriple(ref triple) => triple,
&TargetTriple::TargetPath(ref path) => {
path.file_stem().expect("target path must not be empty").to_str()
.expect("target path must be valid unicode")
}
}
}
}
impl fmt::Display for TargetTriple {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.triple())
}
}

View file

@ -22,6 +22,7 @@ use rustc::middle::cstore::DepKind;
use rustc::session::{Session, CrateDisambiguator}; use rustc::session::{Session, CrateDisambiguator};
use rustc::session::config::{Sanitizer, self}; use rustc::session::config::{Sanitizer, self};
use rustc_back::PanicStrategy; use rustc_back::PanicStrategy;
use rustc_back::target::TargetTriple;
use rustc::session::search_paths::PathKind; use rustc::session::search_paths::PathKind;
use rustc::middle; use rustc::middle;
use rustc::middle::cstore::{validate_crate_name, ExternCrate}; use rustc::middle::cstore::{validate_crate_name, ExternCrate};
@ -295,7 +296,7 @@ impl<'a> CrateLoader<'a> {
let mut proc_macro_locator = locator::Context { let mut proc_macro_locator = locator::Context {
target: &self.sess.host, target: &self.sess.host,
triple: config::host_triple(), triple: &TargetTriple::from_triple(config::host_triple()),
filesearch: self.sess.host_filesearch(path_kind), filesearch: self.sess.host_filesearch(path_kind),
rejected_via_hash: vec![], rejected_via_hash: vec![],
rejected_via_triple: vec![], rejected_via_triple: vec![],
@ -339,7 +340,7 @@ impl<'a> CrateLoader<'a> {
// don't want to match a host crate against an equivalent target one // don't want to match a host crate against an equivalent target one
// already loaded. // already loaded.
let root = library.metadata.get_root(); let root = library.metadata.get_root();
if locate_ctxt.triple == self.sess.opts.target_triple { if locate_ctxt.triple == &self.sess.opts.target_triple {
let mut result = LoadResult::Loaded(library); let mut result = LoadResult::Loaded(library);
self.cstore.iter_crate_data(|cnum, data| { self.cstore.iter_crate_data(|cnum, data| {
if data.name() == root.name && root.hash == data.hash() { if data.name() == root.name && root.hash == data.hash() {
@ -426,8 +427,9 @@ impl<'a> CrateLoader<'a> {
fn read_extension_crate(&mut self, span: Span, orig_name: Symbol, rename: Symbol) fn read_extension_crate(&mut self, span: Span, orig_name: Symbol, rename: Symbol)
-> ExtensionCrate { -> ExtensionCrate {
info!("read extension crate `extern crate {} as {}`", orig_name, rename); info!("read extension crate `extern crate {} as {}`", orig_name, rename);
let target_triple = &self.sess.opts.target_triple[..]; let target_triple = &self.sess.opts.target_triple;
let is_cross = target_triple != config::host_triple(); let host_triple = TargetTriple::from_triple(config::host_triple());
let is_cross = target_triple != &host_triple;
let mut target_only = false; let mut target_only = false;
let mut locate_ctxt = locator::Context { let mut locate_ctxt = locator::Context {
sess: self.sess, sess: self.sess,
@ -437,7 +439,7 @@ impl<'a> CrateLoader<'a> {
hash: None, hash: None,
filesearch: self.sess.host_filesearch(PathKind::Crate), filesearch: self.sess.host_filesearch(PathKind::Crate),
target: &self.sess.host, target: &self.sess.host,
triple: config::host_triple(), triple: &host_triple,
root: &None, root: &None,
rejected_via_hash: vec![], rejected_via_hash: vec![],
rejected_via_triple: vec![], rejected_via_triple: vec![],

View file

@ -233,7 +233,7 @@ use rustc::util::nodemap::FxHashMap;
use errors::DiagnosticBuilder; use errors::DiagnosticBuilder;
use syntax::symbol::Symbol; use syntax::symbol::Symbol;
use syntax_pos::Span; use syntax_pos::Span;
use rustc_back::target::Target; use rustc_back::target::{Target, TargetTriple};
use std::cmp; use std::cmp;
use std::fmt; use std::fmt;
@ -258,7 +258,7 @@ pub struct Context<'a> {
pub hash: Option<&'a Svh>, pub hash: Option<&'a Svh>,
// points to either self.sess.target.target or self.sess.host, must match triple // points to either self.sess.target.target or self.sess.host, must match triple
pub target: &'a Target, pub target: &'a Target,
pub triple: &'a str, pub triple: &'a TargetTriple,
pub filesearch: FileSearch<'a>, pub filesearch: FileSearch<'a>,
pub root: &'a Option<CratePaths>, pub root: &'a Option<CratePaths>,
pub rejected_via_hash: Vec<CrateMismatch>, pub rejected_via_hash: Vec<CrateMismatch>,
@ -394,7 +394,7 @@ impl<'a> Context<'a> {
add); add);
if (self.ident == "std" || self.ident == "core") if (self.ident == "std" || self.ident == "core")
&& self.triple != config::host_triple() { && self.triple != &TargetTriple::from_triple(config::host_triple()) {
err.note(&format!("the `{}` target may not be installed", self.triple)); err.note(&format!("the `{}` target may not be installed", self.triple));
} }
err.span_label(self.span, "can't find crate"); err.span_label(self.span, "can't find crate");
@ -698,13 +698,13 @@ impl<'a> Context<'a> {
} }
} }
if root.triple != self.triple { if &root.triple != self.triple {
info!("Rejecting via crate triple: expected {} got {}", info!("Rejecting via crate triple: expected {} got {}",
self.triple, self.triple,
root.triple); root.triple);
self.rejected_via_triple.push(CrateMismatch { self.rejected_via_triple.push(CrateMismatch {
path: libpath.to_path_buf(), path: libpath.to_path_buf(),
got: root.triple, got: format!("{}", root.triple),
}); });
return None; return None;
} }

View file

@ -22,6 +22,7 @@ use rustc::mir;
use rustc::session::CrateDisambiguator; use rustc::session::CrateDisambiguator;
use rustc::ty::{self, Ty, ReprOptions}; use rustc::ty::{self, Ty, ReprOptions};
use rustc_back::PanicStrategy; use rustc_back::PanicStrategy;
use rustc_back::target::TargetTriple;
use rustc_serialize as serialize; use rustc_serialize as serialize;
use syntax::{ast, attr}; use syntax::{ast, attr};
@ -186,7 +187,7 @@ pub enum LazyState {
#[derive(RustcEncodable, RustcDecodable)] #[derive(RustcEncodable, RustcDecodable)]
pub struct CrateRoot { pub struct CrateRoot {
pub name: Symbol, pub name: Symbol,
pub triple: String, pub triple: TargetTriple,
pub hash: hir::svh::Svh, pub hash: hir::svh::Svh,
pub disambiguator: CrateDisambiguator, pub disambiguator: CrateDisambiguator,
pub panic_strategy: PanicStrategy, pub panic_strategy: PanicStrategy,

View file

@ -950,7 +950,7 @@ impl<'a, 'tcx> FnType<'tcx> {
"s390x" => cabi_s390x::compute_abi_info(cx, self), "s390x" => cabi_s390x::compute_abi_info(cx, self),
"asmjs" => cabi_asmjs::compute_abi_info(cx, self), "asmjs" => cabi_asmjs::compute_abi_info(cx, self),
"wasm32" => { "wasm32" => {
if cx.sess().opts.target_triple.contains("emscripten") { if cx.sess().opts.target_triple.triple().contains("emscripten") {
cabi_asmjs::compute_abi_info(cx, self) cabi_asmjs::compute_abi_info(cx, self)
} else { } else {
cabi_wasm32::compute_abi_info(cx, self) cabi_wasm32::compute_abi_info(cx, self)

View file

@ -31,6 +31,7 @@ use rustc::util::fs::fix_windows_verbatim_for_gcc;
use rustc::hir::def_id::CrateNum; use rustc::hir::def_id::CrateNum;
use tempdir::TempDir; use tempdir::TempDir;
use rustc_back::{PanicStrategy, RelroLevel}; use rustc_back::{PanicStrategy, RelroLevel};
use rustc_back::target::TargetTriple;
use context::get_reloc_model; use context::get_reloc_model;
use llvm; use llvm;
@ -81,7 +82,7 @@ pub fn get_linker(sess: &Session) -> (PathBuf, Command) {
} }
}; };
let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple, "link.exe"); let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe");
let linker_path = sess.opts.cg.linker.as_ref().map(|s| &**s) let linker_path = sess.opts.cg.linker.as_ref().map(|s| &**s)
.or(sess.target.target.options.linker.as_ref().map(|s| s.as_ref())) .or(sess.target.target.options.linker.as_ref().map(|s| s.as_ref()))
@ -812,7 +813,7 @@ fn link_natively(sess: &Session,
} }
} }
if sess.opts.target_triple == "wasm32-unknown-unknown" { if sess.opts.target_triple == TargetTriple::from_triple("wasm32-unknown-unknown") {
wasm::rewrite_imports(&out_filename, &trans.crate_info.wasm_imports); wasm::rewrite_imports(&out_filename, &trans.crate_info.wasm_imports);
wasm::add_custom_sections(&out_filename, wasm::add_custom_sections(&out_filename,
&trans.crate_info.wasm_custom_sections); &trans.crate_info.wasm_custom_sections);
@ -1090,7 +1091,7 @@ fn link_args(cmd: &mut Linker,
// addl_lib_search_paths // addl_lib_search_paths
if sess.opts.cg.rpath { if sess.opts.cg.rpath {
let sysroot = sess.sysroot(); let sysroot = sess.sysroot();
let target_triple = &sess.opts.target_triple; let target_triple = sess.opts.target_triple.triple();
let mut get_install_prefix_lib_path = || { let mut get_install_prefix_lib_path = || {
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX"); let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple); let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);

View file

@ -848,7 +848,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
"rustc.embedded.module\0".as_ptr() as *const _, "rustc.embedded.module\0".as_ptr() as *const _,
); );
llvm::LLVMSetInitializer(llglobal, llconst); llvm::LLVMSetInitializer(llglobal, llconst);
let section = if cgcx.opts.target_triple.contains("-ios") { let section = if cgcx.opts.target_triple.triple().contains("-ios") {
"__LLVM,__bitcode\0" "__LLVM,__bitcode\0"
} else { } else {
".llvmbc\0" ".llvmbc\0"
@ -863,7 +863,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
"rustc.embedded.cmdline\0".as_ptr() as *const _, "rustc.embedded.cmdline\0".as_ptr() as *const _,
); );
llvm::LLVMSetInitializer(llglobal, llconst); llvm::LLVMSetInitializer(llglobal, llconst);
let section = if cgcx.opts.target_triple.contains("-ios") { let section = if cgcx.opts.target_triple.triple().contains("-ios") {
"__LLVM,__cmdline\0" "__LLVM,__cmdline\0"
} else { } else {
".llvmcmd\0" ".llvmcmd\0"

View file

@ -73,6 +73,7 @@ use type_of::LayoutLlvmExt;
use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet};
use CrateInfo; use CrateInfo;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_back::target::TargetTriple;
use std::any::Any; use std::any::Any;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -1079,7 +1080,7 @@ impl CrateInfo {
let load_wasm_items = tcx.sess.crate_types.borrow() let load_wasm_items = tcx.sess.crate_types.borrow()
.iter() .iter()
.any(|c| *c != config::CrateTypeRlib) && .any(|c| *c != config::CrateTypeRlib) &&
tcx.sess.opts.target_triple == "wasm32-unknown-unknown"; tcx.sess.opts.target_triple == TargetTriple::from_triple("wasm32-unknown-unknown");
if load_wasm_items { if load_wasm_items {
info!("attempting to load all wasm sections"); info!("attempting to load all wasm sections");

View file

@ -22,6 +22,7 @@ use rustc::util::nodemap::{FxHashMap, FxHashSet};
use rustc_resolve as resolve; use rustc_resolve as resolve;
use rustc_metadata::creader::CrateLoader; use rustc_metadata::creader::CrateLoader;
use rustc_metadata::cstore::CStore; use rustc_metadata::cstore::CStore;
use rustc_back::target::TargetTriple;
use syntax::ast::NodeId; use syntax::ast::NodeId;
use syntax::codemap; use syntax::codemap;
@ -116,7 +117,7 @@ pub fn run_core(search_paths: SearchPaths,
cfgs: Vec<String>, cfgs: Vec<String>,
externs: config::Externs, externs: config::Externs,
input: Input, input: Input,
triple: Option<String>, triple: Option<TargetTriple>,
maybe_sysroot: Option<PathBuf>, maybe_sysroot: Option<PathBuf>,
allow_warnings: bool, allow_warnings: bool,
crate_name: Option<String>, crate_name: Option<String>,
@ -131,6 +132,7 @@ pub fn run_core(search_paths: SearchPaths,
let warning_lint = lint::builtin::WARNINGS.name_lower(); let warning_lint = lint::builtin::WARNINGS.name_lower();
let host_triple = TargetTriple::from_triple(config::host_triple());
let sessopts = config::Options { let sessopts = config::Options {
maybe_sysroot, maybe_sysroot,
search_paths, search_paths,
@ -138,7 +140,7 @@ pub fn run_core(search_paths: SearchPaths,
lint_opts: if !allow_warnings { vec![(warning_lint, lint::Allow)] } else { vec![] }, lint_opts: if !allow_warnings { vec![(warning_lint, lint::Allow)] } else { vec![] },
lint_cap: Some(lint::Allow), lint_cap: Some(lint::Allow),
externs, externs,
target_triple: triple.unwrap_or(config::host_triple().to_string()), target_triple: triple.unwrap_or(host_triple),
// Ensure that rustdoc works even if rustc is feature-staged // Ensure that rustdoc works even if rustc is feature-staged
unstable_features: UnstableFeatures::Allow, unstable_features: UnstableFeatures::Allow,
actually_rustdoc: true, actually_rustdoc: true,

View file

@ -64,6 +64,7 @@ use std::sync::mpsc::channel;
use externalfiles::ExternalHtml; use externalfiles::ExternalHtml;
use rustc::session::search_paths::SearchPaths; use rustc::session::search_paths::SearchPaths;
use rustc::session::config::{ErrorOutputType, RustcOptGroup, nightly_options, Externs}; use rustc::session::config::{ErrorOutputType, RustcOptGroup, nightly_options, Externs};
use rustc_back::target::TargetTriple;
#[macro_use] #[macro_use]
pub mod externalfiles; pub mod externalfiles;
@ -542,7 +543,13 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
paths.add_path(s, ErrorOutputType::default()); paths.add_path(s, ErrorOutputType::default());
} }
let cfgs = matches.opt_strs("cfg"); let cfgs = matches.opt_strs("cfg");
let triple = matches.opt_str("target"); let triple = matches.opt_str("target").map(|target| {
if target.ends_with(".json") {
TargetTriple::TargetPath(PathBuf::from(target))
} else {
TargetTriple::TargetTriple(target)
}
});
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from); let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
let crate_name = matches.opt_str("crate-name"); let crate_name = matches.opt_str("crate-name");
let crate_version = matches.opt_str("crate-version"); let crate_version = matches.opt_str("crate-version");