Kind::Host => (self.host_triple(), &self.host_info),
Kind::Target => (self.target_triple(), &self.target_info),
};
- platform.matches(name, info.cfg.as_ref().map(|cfg| &cfg[..]))
+ platform.matches(name, info.cfg())
}
/// Gets a package for the given package id.
Kind::Host => &self.host_info,
Kind::Target => &self.target_info,
};
- info.cfg.as_ref().map(|s| &s[..]).unwrap_or(&[])
+ info.cfg().unwrap_or(&[])
}
/// Get the target configuration for a particular host or target
env_args(
self.config,
&self.build_config,
- self.info(&unit.kind),
+ self.info(&unit.kind).cfg(),
unit.kind,
"RUSTFLAGS",
)
env_args(
self.config,
&self.build_config,
- self.info(&unit.kind),
+ self.info(&unit.kind).cfg(),
unit.kind,
"RUSTDOCFLAGS",
)
fn env_args(
config: &Config,
build_config: &BuildConfig,
- target_info: &TargetInfo,
+ target_cfg: Option<&[Cfg]>,
kind: Kind,
name: &str,
) -> CargoResult<Vec<String>> {
rustflags.extend(args);
}
// ...including target.'cfg(...)'.rustflags
- if let Some(ref target_cfg) = target_info.cfg {
+ if let Some(target_cfg) = target_cfg {
if let Some(table) = config.get_table("target")? {
let cfgs = table.val.keys().filter_map(|t| {
if t.starts_with("cfg(") && t.ends_with(')') {
pub struct TargetInfo {
crate_type_process: Option<ProcessBuilder>,
crate_types: RefCell<HashMap<String, Option<(String, String)>>>,
- pub(super) cfg: Option<Vec<Cfg>>,
- pub(super) sysroot_libdir: Option<PathBuf>,
+ cfg: Option<Vec<Cfg>>,
+ pub sysroot_libdir: Option<PathBuf>,
}
/// Type of each file generated by a Unit.
impl TargetInfo {
pub fn new(cx: &Context, kind: Kind) -> CargoResult<TargetInfo> {
- let rustflags = env_args(
- cx.config,
- &cx.build_config,
- cx.info(&kind),
- kind,
- "RUSTFLAGS",
- )?;
+ let rustflags = env_args(cx.config, &cx.build_config, None, kind, "RUSTFLAGS")?;
let mut process = cx.config.rustc()?.process();
process
.arg("-")
})
}
+ pub fn cfg(&self) -> Option<&[Cfg]> {
+ self.cfg.as_ref().map(|v| v.as_ref())
+ }
+
pub fn file_types(
&self,
crate_type: &str,