2013-01-14 04:55:47 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// rustpkg - a purely function package manager and build system
|
|
|
|
|
|
|
|
#[link(name = "rustpkg",
|
|
|
|
vers = "0.6",
|
|
|
|
uuid = "25de5e6e-279e-4a20-845c-4cabae92daaf",
|
|
|
|
url = "https://github.com/mozilla/rust/tree/master/src/librustpkg")];
|
|
|
|
|
|
|
|
#[crate_type = "lib"];
|
|
|
|
#[no_core];
|
|
|
|
|
|
|
|
extern mod core(vers = "0.6");
|
|
|
|
extern mod std(vers = "0.6");
|
|
|
|
extern mod rustc(vers = "0.6");
|
|
|
|
extern mod syntax(vers = "0.6");
|
|
|
|
|
2013-01-15 07:57:03 -06:00
|
|
|
use core::*;
|
|
|
|
use std::getopts;
|
|
|
|
use getopts::{optflag, optopt, opt_present};
|
2013-01-14 04:55:47 -06:00
|
|
|
use rustc::metadata::{filesearch};
|
|
|
|
|
2013-01-15 07:57:03 -06:00
|
|
|
mod api;
|
|
|
|
mod usage;
|
|
|
|
mod util;
|
|
|
|
|
|
|
|
use util::*;
|
|
|
|
|
2013-01-14 04:55:47 -06:00
|
|
|
pub fn main() {
|
2013-01-15 07:57:03 -06:00
|
|
|
let args = os::args();
|
|
|
|
let opts = ~[optflag(~"h"), optflag(~"help")];
|
|
|
|
let matches = &match getopts::getopts(args, opts) {
|
|
|
|
result::Ok(m) => m,
|
|
|
|
result::Err(f) => {
|
|
|
|
fail fmt!("%s", getopts::fail_str(f));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let help = opt_present(matches, ~"h") || opt_present(matches, ~"help");
|
|
|
|
let mut args = copy matches.free;
|
|
|
|
|
|
|
|
args.shift();
|
2013-01-14 04:55:47 -06:00
|
|
|
|
2013-01-15 07:57:03 -06:00
|
|
|
if (args.len() < 1) {
|
|
|
|
return usage::general();
|
|
|
|
}
|
|
|
|
|
|
|
|
let cmd = copy args[0];
|
|
|
|
|
|
|
|
if !is_cmd(cmd) {
|
|
|
|
return usage::general();
|
|
|
|
} else if help {
|
|
|
|
match cmd {
|
|
|
|
~"build" => usage::build(),
|
|
|
|
~"clean" => usage::clean(),
|
|
|
|
~"install" => usage::install(),
|
|
|
|
~"prefer" => usage::prefer(),
|
|
|
|
~"test" => usage::test(),
|
|
|
|
~"uninstall" => usage::uninstall(),
|
|
|
|
~"unprefer" => usage::unprefer(),
|
|
|
|
_ => usage::general()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ctx { cmd: cmd, args: args }
|
2013-01-14 04:55:47 -06:00
|
|
|
}
|
2013-01-15 07:57:03 -06:00
|
|
|
|
|
|
|
pub use Crate = api::Crate;
|
|
|
|
pub use build = api::build;
|
|
|
|
pub use util = api::util;
|