self.source_ids.insert(id.clone(), (id.clone(), kind));
}
- pub fn add_overrides(&mut self, ids: Vec<SourceId>) -> CargoResult<()> {
- for id in ids.iter() {
- try!(self.load(id, Kind::Override));
- }
- Ok(())
+ pub fn add_override(&mut self, id: &SourceId, source: Box<Source + 'cfg>) {
+ self.add_source(id, source, Kind::Override);
+ self.overrides.push(id.clone());
}
pub fn register_lock(&mut self, id: PackageId, deps: Vec<PackageId>) {
use core::{Profile, TargetKind, Profiles};
use core::resolver::{Method, Resolve};
use ops::{self, BuildOutput, ExecEngine};
+use sources::PathSource;
use util::config::Config;
-use util::{CargoResult, internal, ChainError, profile};
+use util::{CargoResult, profile};
/// Contains information about how a package should be compiled.
pub struct CompileOptions<'a> {
no_default_features: bool)
-> CargoResult<(PackageSet<'a>, Resolve)> {
- let override_ids = try!(source_ids_from_config(config, root_package.root()));
-
let mut registry = PackageRegistry::new(config);
if let Some(source) = source {
// overrides, etc.
let _p = profile::start("resolving w/ overrides...");
- try!(registry.add_overrides(override_ids));
+ try!(add_overrides(&mut registry, root_package.root(), config));
let method = Method::Required{
dev_deps: true, // TODO: remove this option?
/// Read the `paths` configuration variable to discover all path overrides that
/// have been configured.
-fn source_ids_from_config(config: &Config, cur_path: &Path)
- -> CargoResult<Vec<SourceId>> {
-
- let configs = try!(config.values());
- debug!("loaded config; configs={:?}", configs);
- let config_paths = match configs.get("paths") {
- Some(cfg) => cfg,
- None => return Ok(Vec::new())
+fn add_overrides<'a>(registry: &mut PackageRegistry<'a>,
+ cur_path: &Path,
+ config: &'a Config) -> CargoResult<()> {
+ let paths = match try!(config.get_list("paths")) {
+ Some(list) => list,
+ None => return Ok(())
};
- let paths = try!(config_paths.list().chain_error(|| {
- internal("invalid configuration for the key `paths`")
- }));
-
- paths.iter().map(|&(ref s, ref p)| {
+ let paths = paths.val.iter().map(|&(ref s, ref p)| {
// The path listed next to the string is the config file in which the
// key was located, so we want to pop off the `.cargo/config` component
// to get the directory containing the `.cargo` folder.
// Make sure we don't override the local package, even if it's in the
// list of override paths.
cur_path != &**p
- }).map(|p| SourceId::for_path(&p)).collect()
+ });
+
+ for path in paths {
+ let id = try!(SourceId::for_path(&path));
+ let mut source = PathSource::new_recursive(&path, &id, config);
+ try!(source.update());
+ registry.add_override(&id, Box::new(source));
+ }
+ Ok(())
}
/// Parse all config files to learn about build configuration. Currently