-use std::collections::HashSet;
+use std::collections::{HashSet, HashMap};
use std::dynamic_lib::DynamicLibrary;
use std::io::{fs, BufferedReader, USER_RWX};
use std::io::fs::{File, PathExtensions};
use util::{mod, CargoResult, ProcessBuilder, CargoError, human, caused_human};
use util::{Require, Config, internal, ChainError, Fresh, profile, join_paths};
-use self::custom_build::CustomBuildCommandOutput;
use self::job::{Job, Work};
use self::job_queue as jq;
use self::job_queue::JobQueue;
pub use self::context::{PlatformPlugin, PlatformPluginAndTarget};
pub use self::context::{PlatformRequirement, PlatformTarget};
pub use self::layout::{Layout, LayoutProxy};
+pub use self::custom_build::BuildOutput;
mod context;
mod compilation;
pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
deps: &PackageSet, resolve: &'a Resolve,
sources: &'a SourceMap,
- config: &'a Config<'a>)
+ config: &'a Config<'a>,
+ lib_overrides: HashMap<String, BuildOutput>)
-> CargoResult<Compilation> {
if targets.is_empty() {
return Ok(Compilation::new(pkg))
});
let mut cx = try!(Context::new(env, resolve, sources, deps, config,
- host_layout, target_layout, pkg));
+ host_layout, target_layout, pkg,
+ lib_overrides));
let mut queue = JobQueue::new(cx.resolve, deps, cx.config);
// First ensure that the destination directory exists
match cx.resolve.features(pkg.get_package_id()) {
Some(features) => {
for feat in features.iter() {
- let feat = feat.as_slice().chars()
- .map(|c| c.to_uppercase())
- .map(|c| if c == '-' {'_'} else {c})
- .collect::<String>();
- p = p.env(format!("CARGO_FEATURE_{}", feat).as_slice(), Some("1"));
+ p = p.env(format!("CARGO_FEATURE_{}",
+ envify(feat.as_slice())).as_slice(),
+ Some("1"));
}
}
None => {}
// list of `-l` flags to pass to rustc coming from custom build scripts
let additional_library_links = match File::open(&command_output_file) {
Ok(f) => {
- let flags = try!(CustomBuildCommandOutput::parse(
+ let flags = try!(BuildOutput::parse(
BufferedReader::new(f), name.as_slice()));
additional_library_paths.extend(flags.library_paths.iter().map(|p| p.clone()));
// doesn't have a build command
};
- let flags = try!(CustomBuildCommandOutput::parse(
+ let flags = try!(BuildOutput::parse(
BufferedReader::new(flags), name.as_slice()));
additional_library_paths.extend(flags.library_paths.iter().map(|p| p.clone()));
}
}
}
}
+
+fn envify(s: &str) -> String {
+ s.chars()
+ .map(|c| c.to_uppercase())
+ .map(|c| if c == '-' {'_'} else {c})
+ .collect()
+}