Re-export op fns in cargo::ops

This commit is contained in:
Carl Lerche 2014-05-22 14:26:36 -07:00
parent 92b449b644
commit 12f49111cd
6 changed files with 27 additions and 16 deletions

View File

@ -1,16 +1,20 @@
#![crate_id="cargo-compile"]
#![allow(deprecated_owned_vector)]
#![feature(phase)]
extern crate cargo;
extern crate hammer;
extern crate serialize;
#[phase(syntax, link)]
extern crate log;
use std::os;
use hammer::FlagConfig;
use cargo::{execute_main_without_stdin,CLIResult,CLIError,ToResult};
use cargo::ops::cargo_compile::compile;
use cargo::ops;
use cargo::util::important_paths::find_project;
use cargo::util::ToCLI;
use hammer::FlagConfig;
use std::os;
#[deriving(Eq,Clone,Decodable,Encodable)]
pub struct Options {
@ -24,6 +28,8 @@ fn main() {
}
fn execute(options: Options) -> CLIResult<Option<()>> {
debug!("executing; cmd=cargo-compile; args={}", os::args());
let root = match options.manifest_path {
Some(path) => Path::new(path),
None => try!(find_project(os::getcwd(), "Cargo.toml".to_owned())
@ -32,5 +38,5 @@ fn execute(options: Options) -> CLIResult<Option<()>> {
CLIError::new("Could not find Cargo.toml in this directory or any parent directory", Some(err), 102)))
};
compile(root.as_str().unwrap().as_slice()).map(|_| None).to_cli(101)
ops::compile(root.as_str().unwrap().as_slice()).map(|_| None).to_cli(101)
}

View File

@ -8,7 +8,7 @@ extern crate hammer;
use hammer::FlagConfig;
use cargo::{execute_main_without_stdin,CLIResult,CLIError};
use cargo::core::Package;
use cargo::ops::cargo_read_manifest::read_manifest;
use cargo::ops;
#[deriving(Eq,Clone,Decodable)]
struct Options {
@ -22,7 +22,7 @@ fn main() {
}
fn execute(options: Options) -> CLIResult<Option<Package>> {
read_manifest(options.manifest_path.as_slice()).map(|m| Some(m))
ops::read_manifest(options.manifest_path.as_slice()).map(|m| Some(m))
.map_err(|err| CLIError {
msg: err.get_desc().to_strbuf(),
detail: err.get_detail().map(|s| s.to_strbuf()),

View File

@ -20,12 +20,13 @@ use util::config::{ConfigValue};
use core::{PackageSet,Source};
use core::resolver::resolve;
use sources::path::PathSource;
use ops::cargo_rustc;
use ops::cargo_read_manifest::read_manifest;
use ops;
use util::{other_error, CargoResult, Wrap};
pub fn compile(manifest_path: &str) -> CargoResult<()> {
let root_dep = try!(read_manifest(manifest_path)).to_dependency();
log!(4, "compile; manifest-path={}", manifest_path);
let root_dep = try!(ops::read_manifest(manifest_path)).to_dependency();
let configs = try!(config::all_configs(os::getcwd()));
@ -48,7 +49,7 @@ pub fn compile(manifest_path: &str) -> CargoResult<()> {
let package_set = PackageSet::new(packages.as_slice());
try!(cargo_rustc::compile(&package_set));
try!(ops::compile_packages(&package_set));
Ok(())
}

View File

@ -9,7 +9,7 @@ use util::result::ProcessError;
type Args = Vec<StrBuf>;
pub fn compile(pkgs: &core::PackageSet) -> CargoResult<()> {
pub fn compile_packages(pkgs: &core::PackageSet) -> CargoResult<()> {
let mut sorted = match pkgs.sort() {
Some(pkgs) => pkgs,
None => return Err(other_error("circular dependency detected"))

View File

@ -1,3 +1,7 @@
pub mod cargo_compile;
pub mod cargo_read_manifest;
pub mod cargo_rustc;
pub use self::cargo_compile::compile;
pub use self::cargo_read_manifest::read_manifest;
pub use self::cargo_rustc::compile_packages;
mod cargo_compile;
mod cargo_read_manifest;
mod cargo_rustc;

View File

@ -2,7 +2,7 @@ use std::fmt;
use std::fmt::{Show,Formatter};
use core::{NameVer,Package,Summary};
use core::source::Source;
use cargo_read_manifest = ops::cargo_read_manifest::read_manifest;
use ops;
use util::{CargoResult};
pub struct PathSource {
@ -49,5 +49,5 @@ impl Source for PathSource {
fn read_manifest(path: &Path) -> CargoResult<Package> {
let joined = path.join("Cargo.toml");
cargo_read_manifest(joined.as_str().unwrap())
ops::read_manifest(joined.as_str().unwrap())
}