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:
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)
+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:
- mkdir -p $(RUSTC_TARGET)
+ mkdir -p $(RUSTC_TARGET)/libs
.PHONY: default clean
#[crate_id="cargo-rustc"];
-extern crate rustc;
+extern crate toml;
use std::os::args;
use std::io::process::Process;
let mut arguments = args();
arguments.shift();
- println!("host: {}", driver::host_triple());
-
if arguments[0] != ~"--" {
fail!("LOL");
} else {
--- /dev/null
+#[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);
+}