mirror of
https://github.com/rust-lang/cargo
synced 2024-09-19 15:52:12 +00:00
Start pulling out the configured paths
This commit is contained in:
parent
62bff631e9
commit
6b44764893
|
@ -12,7 +12,6 @@ pub struct NameVer {
|
||||||
|
|
||||||
impl NameVer {
|
impl NameVer {
|
||||||
pub fn new(name: &str, version: &str) -> NameVer {
|
pub fn new(name: &str, version: &str) -> NameVer {
|
||||||
println!("version: {}", version);
|
|
||||||
NameVer { name: name.to_owned(), version: semver::parse(version.to_owned()).unwrap() }
|
NameVer { name: name.to_owned(), version: semver::parse(version.to_owned()).unwrap() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,11 @@ use std::vec::Vec;
|
||||||
use serialize::{Decodable};
|
use serialize::{Decodable};
|
||||||
use hammer::{FlagDecoder,FlagConfig,FlagConfiguration,HammerError};
|
use hammer::{FlagDecoder,FlagConfig,FlagConfiguration,HammerError};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::os;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::io::process::{Process,ProcessExit,ProcessOutput,InheritFd,ProcessConfig};
|
use std::io::process::{Process,ProcessExit,ProcessOutput,InheritFd,ProcessConfig};
|
||||||
use {ToCargoError,CargoResult};
|
use {ToCargoError,CargoResult};
|
||||||
|
use util::config::{get_config,all_configs};
|
||||||
|
|
||||||
#[deriving(Decodable)]
|
#[deriving(Decodable)]
|
||||||
struct Options {
|
struct Options {
|
||||||
|
@ -34,7 +36,7 @@ impl FlagConfig for Options {
|
||||||
|
|
||||||
pub fn compile() -> CargoResult<()> {
|
pub fn compile() -> CargoResult<()> {
|
||||||
let options = try!(flags::<Options>());
|
let options = try!(flags::<Options>());
|
||||||
let manifest_bytes = try!(read_manifest(options.manifest_path).to_cargo_error(~"Could not read manifest", 1));
|
let manifest_bytes = try!(read_manifest(options.manifest_path));
|
||||||
|
|
||||||
call_rustc(~BufReader::new(manifest_bytes.as_slice()))
|
call_rustc(~BufReader::new(manifest_bytes.as_slice()))
|
||||||
}
|
}
|
||||||
|
@ -66,6 +68,8 @@ fn exec_tty(program: &str, args: &[~str], input: Option<&mut Reader>) -> CargoRe
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator: |&mut ProcessConfig|) -> CargoResult<Process> {
|
fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator: |&mut ProcessConfig|) -> CargoResult<Process> {
|
||||||
|
let paths = get_config(os::getcwd(), "source-paths");
|
||||||
|
|
||||||
let mut config = ProcessConfig::new();
|
let mut config = ProcessConfig::new();
|
||||||
config.program = program;
|
config.program = program;
|
||||||
config.args = args;
|
config.args = args;
|
||||||
|
@ -73,7 +77,7 @@ fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator:
|
||||||
|
|
||||||
println!("Executing {} {}", program, args);
|
println!("Executing {} {}", program, args);
|
||||||
|
|
||||||
let mut process = try!(Process::configure(config).to_cargo_error(~"Could not configure process", 1));
|
let mut process = try!(Process::configure(config).to_cargo_error(|e: io::IoError| format!("Could not configure process: {}", e), 1));
|
||||||
|
|
||||||
input.map(|mut reader| io::util::copy(&mut reader, process.stdin.get_mut_ref()));
|
input.map(|mut reader| io::util::copy(&mut reader, process.stdin.get_mut_ref()));
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
pub mod path_source;
|
|
||||||
pub mod cargo_compile;
|
pub mod cargo_compile;
|
||||||
pub mod cargo_read_manifest;
|
pub mod cargo_read_manifest;
|
||||||
pub mod cargo_rustc;
|
pub mod cargo_rustc;
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
struct PathSourceOp;
|
|
|
@ -1,7 +1,7 @@
|
||||||
extern crate collections;
|
extern crate collections;
|
||||||
extern crate toml;
|
extern crate toml;
|
||||||
|
|
||||||
use super::super::{CargoResult,ToCargoError};
|
use super::super::{CargoResult,ToCargoError,CargoError};
|
||||||
use std::{io,fmt};
|
use std::{io,fmt};
|
||||||
|
|
||||||
#[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
|
#[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
|
||||||
|
@ -10,9 +10,15 @@ pub enum Location {
|
||||||
Global
|
Global
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving(Eq,TotalEq,Clone,Encodable,Decodable,Show)]
|
||||||
|
enum ConfigValueValue {
|
||||||
|
String(~str),
|
||||||
|
List(~[~str])
|
||||||
|
}
|
||||||
|
|
||||||
#[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
|
#[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
|
||||||
pub struct ConfigValue {
|
pub struct ConfigValue {
|
||||||
value: ~str,
|
value: ConfigValueValue,
|
||||||
path: ~str
|
path: ~str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +88,15 @@ fn extract_config(file: io::fs::File, key: &str) -> CargoResult<ConfigValue> {
|
||||||
let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned();
|
let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned();
|
||||||
let mut buf = io::BufferedReader::new(file);
|
let mut buf = io::BufferedReader::new(file);
|
||||||
let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1));
|
let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1));
|
||||||
let val = try!(try!(root.lookup(key).to_cargo_error(~"", 1)).get_str().to_cargo_error(~"", 1));
|
let val = try!(root.lookup(key).to_cargo_error(~"", 1));
|
||||||
Ok(ConfigValue{ value: val.to_owned(), path: path })
|
|
||||||
|
let v = match val {
|
||||||
|
&toml::String(ref val) => String(val.to_owned()),
|
||||||
|
&toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()),
|
||||||
|
_ => return Err(CargoError::new(~"", 1))
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(ConfigValue{ value: v, path: path })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_all_configs(file: io::fs::File) -> CargoResult<collections::HashMap<~str, ConfigValue>> {
|
fn extract_all_configs(file: io::fs::File) -> CargoResult<collections::HashMap<~str, ConfigValue>> {
|
||||||
|
@ -96,7 +109,8 @@ fn extract_all_configs(file: io::fs::File) -> CargoResult<collections::HashMap<~
|
||||||
|
|
||||||
for (key, value) in table.iter() {
|
for (key, value) in table.iter() {
|
||||||
match value {
|
match value {
|
||||||
&toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: val.to_owned(), path: path.clone() }); }
|
&toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: String(val.to_owned()), path: path.clone() }); }
|
||||||
|
&toml::Array(ref val) => { map.insert(key.to_owned(), ConfigValue { value: List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), path: path.clone() }); }
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue