mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Add sketch of cargo-verify-project
This commit is contained in:
parent
4de86d2eec
commit
03943b7dbb
17
Makefile
17
Makefile
@ -1,15 +1,24 @@
|
|||||||
RUSTC_TARGET = target
|
RUSTC_TARGET = target
|
||||||
RUSTC_FLAGS ?= --out-dir $(RUSTC_TARGET)
|
RUSTC_FLAGS ?= --out-dir $(RUSTC_TARGET) -L $(RUSTC_TARGET)/libs
|
||||||
|
|
||||||
default: target/cargo-rustc
|
TOML_LIB := $(shell rustc --crate-file-name libs/rust-toml/src/toml/lib.rs)
|
||||||
|
|
||||||
|
default: target/cargo-rustc target/cargo-verify-project
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf target
|
rm -rf target
|
||||||
|
|
||||||
target/cargo-rustc: target commands/cargo-rustc/main.rs
|
target/cargo-rustc: target target/libs/$(TOML_LIB) commands/cargo-rustc/main.rs
|
||||||
rustc commands/cargo-rustc/main.rs $(RUSTC_FLAGS)
|
rustc commands/cargo-rustc/main.rs $(RUSTC_FLAGS)
|
||||||
|
|
||||||
|
target/cargo-verify-project: target target/libs/$(TOML_LIB) commands/cargo-verify-project/main.rs
|
||||||
|
rustc commands/cargo-verify-project/main.rs $(RUSTC_FLAGS)
|
||||||
|
|
||||||
|
target/libs/$(TOML_LIB): libs/rust-toml/src/toml/lib.rs
|
||||||
|
cd libs/rust-toml && make
|
||||||
|
cp libs/rust-toml/lib/*.rlib target/libs
|
||||||
|
|
||||||
target:
|
target:
|
||||||
mkdir -p $(RUSTC_TARGET)
|
mkdir -p $(RUSTC_TARGET)/libs
|
||||||
|
|
||||||
.PHONY: default clean
|
.PHONY: default clean
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#[crate_id="cargo-rustc"];
|
#[crate_id="cargo-rustc"];
|
||||||
|
|
||||||
extern crate rustc;
|
extern crate toml;
|
||||||
|
|
||||||
use std::os::args;
|
use std::os::args;
|
||||||
use std::io::process::Process;
|
use std::io::process::Process;
|
||||||
@ -15,8 +15,6 @@ fn main() {
|
|||||||
let mut arguments = args();
|
let mut arguments = args();
|
||||||
arguments.shift();
|
arguments.shift();
|
||||||
|
|
||||||
println!("host: {}", driver::host_triple());
|
|
||||||
|
|
||||||
if arguments[0] != ~"--" {
|
if arguments[0] != ~"--" {
|
||||||
fail!("LOL");
|
fail!("LOL");
|
||||||
} else {
|
} else {
|
||||||
|
56
commands/cargo-verify-project/main.rs
Normal file
56
commands/cargo-verify-project/main.rs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#[crate_id="cargo-verify-project"];
|
||||||
|
|
||||||
|
extern crate toml;
|
||||||
|
extern crate getopts;
|
||||||
|
|
||||||
|
use std::os::{args,set_exit_status};
|
||||||
|
use std::io::process::Process;
|
||||||
|
use getopts::{reqopt,getopts,OptGroup};
|
||||||
|
|
||||||
|
/**
|
||||||
|
cargo-verify-project --manifest=LOCATION
|
||||||
|
*/
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let arguments = args();
|
||||||
|
|
||||||
|
let opts = ~[
|
||||||
|
reqopt("m", "manifest", "the location of the manifest", "MANIFEST")
|
||||||
|
];
|
||||||
|
|
||||||
|
let matches = match getopts(arguments.tail(), opts) {
|
||||||
|
Ok(m) => m,
|
||||||
|
Err(err) => {
|
||||||
|
fail("missing-argument", "manifest");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if !matches.opt_present("m") {
|
||||||
|
fail("missing-argument", "manifest");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let manifest = matches.opt_str("m").unwrap();
|
||||||
|
let file = Path::new(manifest);
|
||||||
|
|
||||||
|
if !file.exists() {
|
||||||
|
fail("invalid", "not-found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let root = match toml::parse_from_file(file.as_str().unwrap()) {
|
||||||
|
Err(e) => {
|
||||||
|
fail("invalid", "invalid-format");
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
Ok(r) => r
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("{}", "{ \"success\": \"true\" }");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fail(reason: &str, value: &str) {
|
||||||
|
println!(r#"\{ "{:s}", "{:s}" \}"#, reason, value);
|
||||||
|
set_exit_status(1);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user