2013-02-28 07:15:32 -06:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2013-01-14 04:55:47 -06:00
|
|
|
// 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.
|
|
|
|
|
2013-04-12 18:15:40 -05:00
|
|
|
// rustpkg - a package manager and build system for Rust
|
2013-01-14 04:55:47 -06:00
|
|
|
|
|
|
|
#[link(name = "rustpkg",
|
2013-04-04 23:46:37 -05:00
|
|
|
vers = "0.7-pre",
|
2013-01-14 04:55:47 -06:00
|
|
|
uuid = "25de5e6e-279e-4a20-845c-4cabae92daaf",
|
|
|
|
url = "https://github.com/mozilla/rust/tree/master/src/librustpkg")];
|
|
|
|
|
2013-03-01 10:41:31 -06:00
|
|
|
#[license = "MIT/ASL2"];
|
2013-01-14 04:55:47 -06:00
|
|
|
#[crate_type = "lib"];
|
|
|
|
#[no_core];
|
2013-01-16 05:59:37 -06:00
|
|
|
#[allow(vecs_implicitly_copyable,
|
|
|
|
non_implicitly_copyable_typarams)];
|
2013-01-14 04:55:47 -06:00
|
|
|
|
2013-04-04 23:46:37 -05:00
|
|
|
extern mod core(vers = "0.7-pre");
|
|
|
|
extern mod std(vers = "0.7-pre");
|
|
|
|
extern mod rustc(vers = "0.7-pre");
|
|
|
|
extern mod syntax(vers = "0.7-pre");
|
2013-01-14 04:55:47 -06:00
|
|
|
|
2013-01-15 07:57:03 -06:00
|
|
|
use core::*;
|
2013-04-11 19:43:02 -05:00
|
|
|
pub use core::path::Path;
|
2013-03-26 21:53:33 -05:00
|
|
|
use core::container::Map;
|
2013-04-03 08:28:36 -05:00
|
|
|
use core::hashmap::HashMap;
|
2013-03-26 15:38:07 -05:00
|
|
|
use core::io::WriterUtil;
|
2013-01-18 02:31:43 -06:00
|
|
|
use rustc::driver::{driver, session};
|
2013-03-01 12:44:43 -06:00
|
|
|
use rustc::metadata::filesearch;
|
2013-04-11 19:43:02 -05:00
|
|
|
use std::{getopts};
|
2013-03-26 15:38:07 -05:00
|
|
|
use syntax::{ast, diagnostic};
|
2013-04-17 15:53:34 -05:00
|
|
|
use util::*;
|
|
|
|
use path_util::{dest_dir, normalize};
|
2013-04-18 16:56:41 -05:00
|
|
|
use rustc::driver::session::{lib_crate, bin_crate, crate_type};
|
2013-01-14 04:55:47 -06:00
|
|
|
|
2013-04-12 18:15:40 -05:00
|
|
|
mod conditions;
|
2013-01-15 07:57:03 -06:00
|
|
|
mod usage;
|
2013-04-12 18:15:40 -05:00
|
|
|
mod path_util;
|
2013-01-15 07:57:03 -06:00
|
|
|
mod util;
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
/// A PkgScript represents user-supplied custom logic for
|
|
|
|
/// special build hooks. This only exists for packages with
|
|
|
|
/// an explicit package script.
|
|
|
|
struct PkgScript {
|
|
|
|
/// Uniquely identifies this package
|
|
|
|
id: PkgId,
|
|
|
|
// Used to have this field: deps: ~[(~str, Option<~str>)]
|
|
|
|
// but I think it shouldn't be stored here
|
|
|
|
/// The contents of the package script: either a file path,
|
|
|
|
/// or a string containing the text of the input
|
2013-01-22 19:19:13 -06:00
|
|
|
input: driver::input,
|
2013-04-11 19:43:02 -05:00
|
|
|
/// The session to use *only* for compiling the custom
|
|
|
|
/// build script
|
2013-01-22 19:19:13 -06:00
|
|
|
sess: session::Session,
|
2013-04-11 19:43:02 -05:00
|
|
|
/// The config for compiling the custom build script
|
2013-01-22 19:19:13 -06:00
|
|
|
cfg: ast::crate_cfg,
|
2013-04-11 19:43:02 -05:00
|
|
|
/// The crate for the custom build script
|
2013-01-22 19:19:13 -06:00
|
|
|
crate: @ast::crate,
|
2013-04-11 19:43:02 -05:00
|
|
|
/// Directory in which to store build output
|
|
|
|
build_dir: Path
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
impl PkgScript {
|
|
|
|
/// Given the path name for a package script
|
|
|
|
/// and a package ID, parse the package script into
|
|
|
|
/// a PkgScript that we can then execute
|
|
|
|
fn parse(script: Path, id: PkgId) -> PkgScript {
|
|
|
|
// Get the executable name that was invoked
|
2013-01-22 19:19:13 -06:00
|
|
|
let binary = os::args()[0];
|
2013-04-11 19:43:02 -05:00
|
|
|
// Build the rustc session data structures to pass
|
|
|
|
// to the compiler
|
2013-02-19 02:01:03 -06:00
|
|
|
let options = @session::options {
|
2013-04-16 19:30:31 -05:00
|
|
|
binary: @binary,
|
2013-01-22 19:19:13 -06:00
|
|
|
crate_type: session::bin_crate,
|
|
|
|
.. *session::basic_options()
|
|
|
|
};
|
|
|
|
let input = driver::file_input(script);
|
|
|
|
let sess = driver::build_session(options, diagnostic::emit);
|
2013-04-18 16:56:41 -05:00
|
|
|
let cfg = driver::build_configuration(sess, @binary, &input);
|
|
|
|
let (crate, _) = driver::compile_upto(sess, cfg, &input,
|
2013-01-22 19:19:13 -06:00
|
|
|
driver::cu_parse, None);
|
2013-04-11 19:43:02 -05:00
|
|
|
let work_dir = dest_dir(id);
|
2013-01-16 05:59:37 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Returning package script with id %?", id);
|
2013-01-16 05:59:37 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
PkgScript {
|
2013-01-16 05:59:37 -06:00
|
|
|
id: id,
|
2013-01-22 19:19:13 -06:00
|
|
|
input: input,
|
|
|
|
sess: sess,
|
|
|
|
cfg: cfg,
|
|
|
|
crate: crate,
|
2013-04-11 19:43:02 -05:00
|
|
|
build_dir: work_dir
|
|
|
|
}
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
/// Run the contents of this package script, where <what>
|
|
|
|
/// is the command to pass to it (e.g., "build", "clean", "install")
|
|
|
|
/// Returns a pair of an exit code and list of configs (obtained by
|
|
|
|
/// calling the package script's configs() function if it exists
|
2013-01-23 03:25:03 -06:00
|
|
|
// FIXME (#4432): Use workcache to only compile the script when changed
|
2013-04-11 19:43:02 -05:00
|
|
|
fn run_custom(&self, what: ~str) -> (~[~str], ExitCode) {
|
|
|
|
debug!("run_custom: %s", what);
|
2013-01-22 19:19:13 -06:00
|
|
|
let sess = self.sess;
|
2013-04-11 19:43:02 -05:00
|
|
|
|
|
|
|
debug!("Working directory = %s", self.build_dir.to_str());
|
|
|
|
// Collect together any user-defined commands in the package script
|
2013-01-22 19:19:13 -06:00
|
|
|
let crate = util::ready_crate(sess, self.crate);
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Building output filenames with script name %s",
|
2013-04-18 16:56:41 -05:00
|
|
|
driver::source_name(&self.input));
|
2013-04-11 19:43:02 -05:00
|
|
|
match filesearch::get_rustpkg_sysroot() {
|
|
|
|
Ok(r) => {
|
|
|
|
let root = r.pop().pop().pop().pop(); // :-\
|
|
|
|
debug!("Root is %s, calling compile_rest", root.to_str());
|
|
|
|
let exe = self.build_dir.push(~"pkg" + util::exe_suffix());
|
2013-04-17 15:53:34 -05:00
|
|
|
util::compile_crate_from_input(self.input, self.id,
|
|
|
|
Some(self.build_dir),
|
|
|
|
sess, Some(crate),
|
|
|
|
exe, os::args()[0],
|
|
|
|
driver::cu_everything);
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Running program: %s %s %s", exe.to_str(), root.to_str(), what);
|
|
|
|
let status = run::run_program(exe.to_str(), ~[root.to_str(), what]);
|
|
|
|
if status != 0 {
|
|
|
|
return (~[], status);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
debug!("Running program (configs): %s %s %s",
|
|
|
|
exe.to_str(), root.to_str(), ~"configs");
|
|
|
|
let output = run::program_output(exe.to_str(), ~[root.to_str(), ~"configs"]);
|
|
|
|
// Run the configs() function to get the configs
|
|
|
|
let mut cfgs = ~[];
|
|
|
|
for str::each_word(output.out) |w| {
|
|
|
|
cfgs.push(w.to_owned());
|
|
|
|
}
|
|
|
|
(cfgs, output.status)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
fail!(fmt!("Running package script, couldn't find rustpkg sysroot (%s)",
|
|
|
|
e))
|
|
|
|
}
|
|
|
|
}
|
2013-01-22 19:19:13 -06:00
|
|
|
}
|
|
|
|
|
2013-02-04 19:12:31 -06:00
|
|
|
fn hash(&self) -> ~str {
|
2013-04-11 19:43:02 -05:00
|
|
|
self.id.hash()
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Ctx {
|
2013-04-11 19:43:02 -05:00
|
|
|
// I'm not sure what this is for
|
2013-01-26 02:35:10 -06:00
|
|
|
json: bool,
|
2013-04-11 19:43:02 -05:00
|
|
|
// Cache of hashes of things already installed
|
|
|
|
// though I'm not sure why the value is a bool
|
|
|
|
dep_cache: @mut HashMap<~str, bool>,
|
|
|
|
}
|
|
|
|
|
2013-01-16 05:59:37 -06:00
|
|
|
impl Ctx {
|
2013-04-11 19:43:02 -05:00
|
|
|
|
2013-02-04 19:12:31 -06:00
|
|
|
fn run(&self, cmd: ~str, args: ~[~str]) {
|
2013-01-17 03:05:19 -06:00
|
|
|
let root = util::root();
|
|
|
|
|
|
|
|
util::need_dir(&root);
|
|
|
|
util::need_dir(&root.push(~"work"));
|
|
|
|
util::need_dir(&root.push(~"lib"));
|
|
|
|
util::need_dir(&root.push(~"bin"));
|
|
|
|
util::need_dir(&root.push(~"tmp"));
|
|
|
|
|
2013-01-18 02:31:43 -06:00
|
|
|
fn sep_name_vers(in: ~str) -> (Option<~str>, Option<~str>) {
|
|
|
|
let mut name = None;
|
|
|
|
let mut vers = None;
|
|
|
|
|
2013-03-25 22:39:10 -05:00
|
|
|
for str::each_split_char(in, '@') |s| {
|
|
|
|
if name.is_none() { name = Some(s.to_owned()); }
|
|
|
|
else if vers.is_none() { vers = Some(s.to_owned()); }
|
|
|
|
else { break; }
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
(name, vers)
|
|
|
|
}
|
|
|
|
|
2013-01-17 03:05:19 -06:00
|
|
|
match cmd {
|
2013-01-22 19:19:13 -06:00
|
|
|
~"build" => {
|
2013-03-07 16:54:23 -06:00
|
|
|
if args.len() < 1 {
|
|
|
|
return usage::build();
|
|
|
|
}
|
2013-04-11 19:43:02 -05:00
|
|
|
// The package id is presumed to be the first command-line
|
|
|
|
// argument
|
2013-03-07 16:54:23 -06:00
|
|
|
let pkgid = PkgId::new(args[0]);
|
2013-04-11 19:43:02 -05:00
|
|
|
// Should allow the build directory to be configured.
|
|
|
|
// Right now it's always the "build" subdirectory in
|
|
|
|
// the package directory
|
|
|
|
let dst_dir = dest_dir(pkgid);
|
|
|
|
debug!("Destination dir = %s", dst_dir.to_str());
|
|
|
|
// Right now, we assume the pkgid path is a valid dir
|
|
|
|
// relative to the CWD. In the future, we should search
|
|
|
|
// paths
|
|
|
|
let cwd = os::getcwd().normalize();
|
2013-04-17 15:53:34 -05:00
|
|
|
debug!("Current working directory = %s", cwd.to_str());
|
2013-04-11 19:43:02 -05:00
|
|
|
|
2013-04-17 15:53:34 -05:00
|
|
|
// Create the package source
|
2013-04-11 19:43:02 -05:00
|
|
|
let mut src = PkgSrc::new(&cwd, &dst_dir, &pkgid);
|
|
|
|
debug!("Package src = %?", src);
|
|
|
|
|
|
|
|
// Is there custom build logic? If so, use it
|
|
|
|
let pkg_src_dir = cwd.push_rel(&pkgid.path);
|
2013-04-17 15:53:34 -05:00
|
|
|
let mut custom = false;;
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Package source directory = %s", pkg_src_dir.to_str());
|
|
|
|
let cfgs = match src.package_script_option(&pkg_src_dir) {
|
|
|
|
Some(package_script_path) => {
|
|
|
|
let pscript = PkgScript::parse(package_script_path,
|
|
|
|
pkgid);
|
|
|
|
// Limited right now -- we're only running the post_build
|
|
|
|
// hook and probably fail otherwise
|
|
|
|
// also post_build should be called pre_build
|
|
|
|
let (cfgs, hook_result) = pscript.run_custom(~"post_build");
|
|
|
|
debug!("Command return code = %?", hook_result);
|
|
|
|
if hook_result != 0 {
|
|
|
|
fail!(fmt!("Error running custom build command"))
|
|
|
|
}
|
2013-04-17 15:53:34 -05:00
|
|
|
custom = true;
|
2013-04-11 19:43:02 -05:00
|
|
|
// otherwise, the package script succeeded
|
|
|
|
cfgs
|
|
|
|
}
|
|
|
|
None => {
|
|
|
|
debug!("No package script, continuing");
|
|
|
|
~[]
|
|
|
|
}
|
|
|
|
};
|
2013-04-17 15:53:34 -05:00
|
|
|
|
2013-04-17 20:58:59 -05:00
|
|
|
// If there was a package script, it should have finished
|
|
|
|
// the build already. Otherwise...
|
2013-04-17 15:53:34 -05:00
|
|
|
if !custom {
|
2013-04-17 20:58:59 -05:00
|
|
|
// Find crates inside the workspace
|
2013-04-17 15:53:34 -05:00
|
|
|
src.find_crates();
|
2013-04-17 20:58:59 -05:00
|
|
|
// Build it!
|
|
|
|
src.build(&dst_dir, cfgs);
|
2013-04-17 15:53:34 -05:00
|
|
|
}
|
2013-01-22 19:19:13 -06:00
|
|
|
}
|
|
|
|
~"clean" => {
|
2013-04-17 17:47:24 -05:00
|
|
|
if args.len() < 1 {
|
|
|
|
return usage::build();
|
|
|
|
}
|
|
|
|
// The package id is presumed to be the first command-line
|
|
|
|
// argument
|
|
|
|
let pkgid = PkgId::new(args[0]);
|
|
|
|
|
|
|
|
self.clean(pkgid);
|
2013-01-22 19:19:13 -06:00
|
|
|
}
|
2013-01-22 20:41:11 -06:00
|
|
|
~"do" => {
|
2013-04-11 19:43:02 -05:00
|
|
|
if args.len() < 2 {
|
2013-01-22 20:41:11 -06:00
|
|
|
return usage::do_cmd();
|
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
self.do_cmd(args[0], args[1]);
|
2013-01-22 20:41:11 -06:00
|
|
|
}
|
2013-01-26 02:35:10 -06:00
|
|
|
~"info" => {
|
|
|
|
self.info();
|
|
|
|
}
|
2013-01-18 02:31:43 -06:00
|
|
|
~"install" => {
|
|
|
|
self.install(if args.len() >= 1 { Some(args[0]) }
|
2013-01-23 00:38:05 -06:00
|
|
|
else { None },
|
2013-01-18 02:31:43 -06:00
|
|
|
if args.len() >= 2 { Some(args[1]) }
|
2013-01-22 19:19:13 -06:00
|
|
|
else { None }, false);
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
~"prefer" => {
|
|
|
|
if args.len() < 1 {
|
|
|
|
return usage::uninstall();
|
|
|
|
}
|
|
|
|
|
|
|
|
let (name, vers) = sep_name_vers(args[0]);
|
|
|
|
|
2013-01-22 19:19:13 -06:00
|
|
|
self.prefer(name.get(), vers);
|
|
|
|
}
|
|
|
|
~"test" => {
|
|
|
|
self.test();
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
~"uninstall" => {
|
|
|
|
if args.len() < 1 {
|
|
|
|
return usage::uninstall();
|
|
|
|
}
|
|
|
|
|
|
|
|
let (name, vers) = sep_name_vers(args[0]);
|
|
|
|
|
2013-01-22 19:19:13 -06:00
|
|
|
self.uninstall(name.get(), vers);
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
~"unprefer" => {
|
|
|
|
if args.len() < 1 {
|
|
|
|
return usage::uninstall();
|
|
|
|
}
|
|
|
|
|
|
|
|
let (name, vers) = sep_name_vers(args[0]);
|
|
|
|
|
2013-01-22 19:19:13 -06:00
|
|
|
self.unprefer(name.get(), vers);
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
2013-02-04 19:12:31 -06:00
|
|
|
_ => fail!(~"reached an unhandled command")
|
2013-01-22 19:19:13 -06:00
|
|
|
}
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn do_cmd(&self, cmd: ~str, pkgname: ~str) {
|
2013-01-26 06:00:39 -06:00
|
|
|
match cmd {
|
|
|
|
~"build" | ~"test" => {
|
|
|
|
util::error(~"that command cannot be manually called");
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!(~"do_cmd");
|
2013-01-26 06:00:39 -06:00
|
|
|
}
|
|
|
|
_ => {}
|
2013-01-22 20:41:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
let cwd = &os::getcwd();
|
2013-04-11 19:43:02 -05:00
|
|
|
let pkgid = PkgId::new(pkgname);
|
|
|
|
// Always use the "build" subdirectory of the package dir,
|
|
|
|
// but we should allow this to be configured
|
|
|
|
let dst_dir = dest_dir(pkgid);
|
2013-04-12 14:49:11 -05:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
let mut src = PkgSrc::new(cwd, &dst_dir, &pkgid);
|
|
|
|
match src.package_script_option(cwd) {
|
|
|
|
Some(script_path) => {
|
|
|
|
let script = PkgScript::parse(script_path, pkgid);
|
|
|
|
let (_, status) = script.run_custom(cmd); // Ignore cfgs?
|
2013-04-17 17:47:24 -05:00
|
|
|
if status == 42 {
|
2013-04-11 19:43:02 -05:00
|
|
|
util::error(~"no fns are listening for that cmd");
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!(~"do_cmd");
|
2013-04-11 19:43:02 -05:00
|
|
|
}
|
2013-01-17 03:05:19 -06:00
|
|
|
}
|
2013-04-11 19:43:02 -05:00
|
|
|
None => {
|
2013-04-12 14:49:11 -05:00
|
|
|
util::error(fmt!("invoked `do`, but there is no package script in %s",
|
|
|
|
cwd.to_str()));
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!(~"do_cmd");
|
2013-01-26 06:00:39 -06:00
|
|
|
}
|
2013-01-17 03:05:19 -06:00
|
|
|
}
|
2013-04-11 19:43:02 -05:00
|
|
|
}
|
2013-01-16 05:59:37 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
fn build(&self, _dir: &Path, _verbose: bool, _opt: bool,
|
|
|
|
_test: bool) -> Option<PkgScript> {
|
|
|
|
// either not needed anymore,
|
|
|
|
// or needed only when we don't have a package script. Not sure which one.
|
|
|
|
fail!();
|
2013-01-22 19:19:13 -06:00
|
|
|
}
|
2013-01-16 05:59:37 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
fn compile(&self, _crate: &Path, _dir: &Path, _flags: ~[~str],
|
2013-04-17 17:47:24 -05:00
|
|
|
_cfgs: ~[~str], _opt: bool, _test: bool) {
|
2013-04-11 19:43:02 -05:00
|
|
|
// What's the difference between build and compile?
|
|
|
|
fail!(~"compile not yet implemented");
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn clean(&self, id: PkgId) {
|
|
|
|
// Could also support a custom build hook in the pkg
|
|
|
|
// script for cleaning files rustpkg doesn't know about.
|
|
|
|
// Do something reasonable for now
|
|
|
|
|
|
|
|
let dir = dest_dir(id);
|
|
|
|
util::note(fmt!("Cleaning package %s (removing directory %s)",
|
|
|
|
id.to_str(), dir.to_str()));
|
|
|
|
if os::path_exists(&dir) {
|
|
|
|
util::remove_dir_r(&dir);
|
|
|
|
util::note(fmt!("Removed directory %s", dir.to_str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
util::note(fmt!("Cleaned package %s", id.to_str()));
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-02-04 19:12:31 -06:00
|
|
|
fn info(&self) {
|
2013-04-11 19:43:02 -05:00
|
|
|
// stub
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!(~"info not yet implemented");
|
2013-01-26 02:35:10 -06:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn install(&self, _url: Option<~str>,
|
|
|
|
_target: Option<~str>, _cache: bool) {
|
|
|
|
// stub
|
|
|
|
fail!(~"install not yet implemented");
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn fetch(&self, _dir: &Path, _url: ~str, _target: Option<~str>) {
|
|
|
|
// stub
|
|
|
|
fail!(~"fetch not yet implemented");
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn fetch_curl(&self, dir: &Path, url: ~str) {
|
2013-01-18 02:31:43 -06:00
|
|
|
util::note(fmt!("fetching from %s using curl", url));
|
|
|
|
|
|
|
|
let tar = dir.dir_path().push(&dir.file_path().to_str() + ~".tar");
|
|
|
|
|
2013-01-23 00:38:05 -06:00
|
|
|
if run::program_output(~"curl", ~[~"-f", ~"-s",
|
|
|
|
~"-o", tar.to_str(),
|
|
|
|
url]).status != 0 {
|
2013-01-18 02:31:43 -06:00
|
|
|
util::error(~"fetching failed: downloading using curl failed");
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!();
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
|
2013-01-23 00:38:05 -06:00
|
|
|
if run::program_output(~"tar", ~[~"-x", ~"--strip-components=1",
|
|
|
|
~"-C", dir.to_str(), ~"-f",
|
|
|
|
tar.to_str()]).status != 0 {
|
|
|
|
util::error(~"fetching failed: extracting using tar failed" +
|
|
|
|
~"(is it a valid tar archive?)");
|
2013-01-18 02:31:43 -06:00
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!();
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn fetch_git(&self, dir: &Path, url: ~str, target: Option<~str>) {
|
2013-01-18 02:31:43 -06:00
|
|
|
util::note(fmt!("fetching from %s using git", url));
|
|
|
|
|
|
|
|
// Git can't clone into a non-empty directory
|
2013-01-19 03:59:19 -06:00
|
|
|
util::remove_dir_r(dir);
|
2013-01-18 02:31:43 -06:00
|
|
|
|
2013-01-23 00:38:05 -06:00
|
|
|
if run::program_output(~"git", ~[~"clone", url,
|
|
|
|
dir.to_str()]).status != 0 {
|
2013-01-18 02:31:43 -06:00
|
|
|
util::error(~"fetching failed: can't clone repository");
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!();
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if !target.is_none() {
|
|
|
|
let mut success = true;
|
|
|
|
|
|
|
|
do util::temp_change_dir(dir) {
|
2013-01-23 00:38:05 -06:00
|
|
|
success = run::program_output(~"git",
|
|
|
|
~[~"checkout",
|
|
|
|
target.get()]).status != 0
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if !success {
|
|
|
|
util::error(~"fetching failed: can't checkout target");
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!();
|
2013-01-18 02:31:43 -06:00
|
|
|
}
|
|
|
|
}
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn prefer(&self, id: ~str, vers: Option<~str>) {
|
2013-01-19 03:59:19 -06:00
|
|
|
let package = match util::get_pkg(id, vers) {
|
|
|
|
result::Ok(package) => package,
|
|
|
|
result::Err(err) => {
|
|
|
|
util::error(err);
|
2013-04-17 17:47:24 -05:00
|
|
|
fail!(); // Condition?
|
2013-01-19 03:59:19 -06:00
|
|
|
}
|
|
|
|
};
|
2013-04-11 19:43:02 -05:00
|
|
|
let name = package.id.path.to_str(); // ???
|
2013-01-19 03:59:19 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
util::note(fmt!("preferring %s v%s", name, package.id.version.to_str()));
|
2013-01-19 03:59:19 -06:00
|
|
|
|
|
|
|
let bin_dir = util::root().push(~"bin");
|
|
|
|
|
|
|
|
for package.bins.each |&bin| {
|
|
|
|
let path = Path(bin);
|
2013-03-25 22:39:10 -05:00
|
|
|
let mut name = None;
|
|
|
|
for str::each_split_char(path.file_path().to_str(), '-') |s| {
|
|
|
|
name = Some(s.to_owned());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
let out = bin_dir.push(name.unwrap());
|
2013-01-19 03:59:19 -06:00
|
|
|
|
|
|
|
util::link_exe(&path, &out);
|
|
|
|
util::note(fmt!("linked %s", out.to_str()));
|
|
|
|
}
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
util::note(fmt!("preferred %s v%s", name, package.id.version.to_str()));
|
2013-01-17 03:05:19 -06:00
|
|
|
}
|
2013-01-16 05:59:37 -06:00
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn test(&self) {
|
|
|
|
// stub
|
|
|
|
fail!(~"test not yet implemented");
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn uninstall(&self, _id: ~str, _vers: Option<~str>) {
|
2013-04-11 19:43:02 -05:00
|
|
|
fail!(~"uninstall not yet implemented");
|
2013-01-17 03:05:19 -06:00
|
|
|
}
|
2013-01-16 05:59:37 -06:00
|
|
|
|
2013-04-17 17:47:24 -05:00
|
|
|
fn unprefer(&self, _id: ~str, _vers: Option<~str>) {
|
2013-04-11 19:43:02 -05:00
|
|
|
fail!(~"unprefer not yet implemented");
|
2013-01-16 05:59:37 -06:00
|
|
|
}
|
|
|
|
}
|
2013-01-15 07:57:03 -06:00
|
|
|
|
2013-01-14 04:55:47 -06:00
|
|
|
pub fn main() {
|
2013-04-11 19:43:02 -05:00
|
|
|
io::println("WARNING: The Rust package manager is experimental and may be unstable");
|
2013-03-20 13:44:01 -05:00
|
|
|
|
2013-01-15 07:57:03 -06:00
|
|
|
let args = os::args();
|
2013-01-16 05:59:37 -06:00
|
|
|
let opts = ~[getopts::optflag(~"h"), getopts::optflag(~"help"),
|
2013-01-26 02:35:10 -06:00
|
|
|
getopts::optflag(~"j"), getopts::optflag(~"json"),
|
2013-01-19 03:59:19 -06:00
|
|
|
getopts::optmulti(~"c"), getopts::optmulti(~"cfg")];
|
2013-01-15 07:57:03 -06:00
|
|
|
let matches = &match getopts::getopts(args, opts) {
|
|
|
|
result::Ok(m) => m,
|
|
|
|
result::Err(f) => {
|
2013-01-19 03:59:19 -06:00
|
|
|
util::error(fmt!("%s", getopts::fail_str(f)));
|
|
|
|
|
|
|
|
return;
|
2013-01-15 07:57:03 -06:00
|
|
|
}
|
|
|
|
};
|
2013-01-16 05:59:37 -06:00
|
|
|
let help = getopts::opt_present(matches, ~"h") ||
|
|
|
|
getopts::opt_present(matches, ~"help");
|
2013-01-26 02:35:10 -06:00
|
|
|
let json = getopts::opt_present(matches, ~"j") ||
|
|
|
|
getopts::opt_present(matches, ~"json");
|
2013-01-15 07:57:03 -06:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-01-16 05:59:37 -06:00
|
|
|
let cmd = args.shift();
|
2013-01-15 07:57:03 -06:00
|
|
|
|
2013-01-16 05:59:37 -06:00
|
|
|
if !util::is_cmd(cmd) {
|
2013-01-15 07:57:03 -06:00
|
|
|
return usage::general();
|
|
|
|
} else if help {
|
2013-01-16 05:59:37 -06:00
|
|
|
return match cmd {
|
2013-01-15 07:57:03 -06:00
|
|
|
~"build" => usage::build(),
|
|
|
|
~"clean" => usage::clean(),
|
2013-01-22 20:41:11 -06:00
|
|
|
~"do" => usage::do_cmd(),
|
2013-01-26 02:35:10 -06:00
|
|
|
~"info" => usage::info(),
|
2013-01-15 07:57:03 -06:00
|
|
|
~"install" => usage::install(),
|
|
|
|
~"prefer" => usage::prefer(),
|
|
|
|
~"test" => usage::test(),
|
|
|
|
~"uninstall" => usage::uninstall(),
|
|
|
|
~"unprefer" => usage::unprefer(),
|
|
|
|
_ => usage::general()
|
2013-01-16 05:59:37 -06:00
|
|
|
};
|
2013-01-15 07:57:03 -06:00
|
|
|
}
|
|
|
|
|
2013-01-16 05:59:37 -06:00
|
|
|
Ctx {
|
2013-01-26 02:35:10 -06:00
|
|
|
json: json,
|
2013-04-03 08:28:36 -05:00
|
|
|
dep_cache: @mut HashMap::new()
|
2013-01-17 03:05:19 -06:00
|
|
|
}.run(cmd, args);
|
2013-01-14 04:55:47 -06:00
|
|
|
}
|
2013-01-15 07:57:03 -06:00
|
|
|
|
2013-01-23 00:38:05 -06:00
|
|
|
/// A crate is a unit of Rust code to be compiled into a binary or library
|
|
|
|
pub struct Crate {
|
2013-03-07 16:54:23 -06:00
|
|
|
file: Path,
|
2013-01-23 00:38:05 -06:00
|
|
|
flags: ~[~str],
|
|
|
|
cfgs: ~[~str]
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Listener {
|
|
|
|
cmds: ~[~str],
|
2013-03-01 18:02:22 -06:00
|
|
|
cb: ~fn()
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn run(listeners: ~[Listener]) {
|
|
|
|
let rcmd = os::args()[2];
|
|
|
|
let mut found = false;
|
|
|
|
|
|
|
|
for listeners.each |listener| {
|
|
|
|
for listener.cmds.each |&cmd| {
|
|
|
|
if cmd == rcmd {
|
|
|
|
(listener.cb)();
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !found {
|
2013-01-26 06:00:39 -06:00
|
|
|
os::set_exit_status(42);
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub impl Crate {
|
2013-03-07 16:54:23 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
fn new(p: &Path) -> Crate {
|
2013-03-07 16:54:23 -06:00
|
|
|
Crate {
|
|
|
|
file: copy *p,
|
|
|
|
flags: ~[],
|
|
|
|
cfgs: ~[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn flag(&self, flag: ~str) -> Crate {
|
2013-01-23 00:38:05 -06:00
|
|
|
Crate {
|
|
|
|
flags: vec::append(copy self.flags, ~[flag]),
|
2013-02-04 19:12:31 -06:00
|
|
|
.. copy *self
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
fn flags(&self, flags: ~[~str]) -> Crate {
|
2013-01-23 00:38:05 -06:00
|
|
|
Crate {
|
|
|
|
flags: vec::append(copy self.flags, flags),
|
2013-02-04 19:12:31 -06:00
|
|
|
.. copy *self
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
fn cfg(&self, cfg: ~str) -> Crate {
|
2013-01-23 00:38:05 -06:00
|
|
|
Crate {
|
|
|
|
cfgs: vec::append(copy self.cfgs, ~[cfg]),
|
2013-02-04 19:12:31 -06:00
|
|
|
.. copy *self
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
fn cfgs(&self, cfgs: ~[~str]) -> Crate {
|
2013-01-23 00:38:05 -06:00
|
|
|
Crate {
|
|
|
|
cfgs: vec::append(copy self.cfgs, cfgs),
|
2013-02-04 19:12:31 -06:00
|
|
|
.. copy *self
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the working directory of the package script.
|
|
|
|
* Assumes that the package script has been compiled
|
|
|
|
* in is the working directory.
|
|
|
|
*/
|
2013-01-26 02:35:10 -06:00
|
|
|
pub fn work_dir() -> Path {
|
2013-01-23 00:38:05 -06:00
|
|
|
os::self_exe_path().get()
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the source directory of the package (i.e.
|
|
|
|
* where the crates are located). Assumes
|
|
|
|
* that the cwd is changed to it before
|
|
|
|
* running this executable.
|
|
|
|
*/
|
2013-01-26 02:35:10 -06:00
|
|
|
pub fn src_dir() -> Path {
|
2013-01-23 00:38:05 -06:00
|
|
|
os::getcwd()
|
|
|
|
}
|
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
condition! {
|
2013-04-11 19:43:02 -05:00
|
|
|
bad_pkg_id: (super::Path, ~str) -> ::util::PkgId;
|
2013-03-07 16:54:23 -06:00
|
|
|
}
|
2013-01-23 00:38:05 -06:00
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
// An enumeration of the unpacked source of a package workspace.
|
|
|
|
// This contains a list of files found in the source workspace.
|
|
|
|
pub struct PkgSrc {
|
2013-04-11 19:43:02 -05:00
|
|
|
root: Path, // root of where the package source code lives
|
|
|
|
dst_dir: Path, // directory where we will put the compiled output
|
2013-03-07 16:54:23 -06:00
|
|
|
id: PkgId,
|
|
|
|
libs: ~[Crate],
|
|
|
|
mains: ~[Crate],
|
|
|
|
tests: ~[Crate],
|
|
|
|
benchs: ~[Crate],
|
|
|
|
}
|
2013-01-23 00:38:05 -06:00
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
condition! {
|
|
|
|
build_err: (~str) -> ();
|
|
|
|
}
|
2013-01-23 00:38:05 -06:00
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
impl PkgSrc {
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
fn new(src_dir: &Path, dst_dir: &Path,
|
|
|
|
id: &PkgId) -> PkgSrc {
|
2013-03-07 16:54:23 -06:00
|
|
|
PkgSrc {
|
2013-04-11 19:43:02 -05:00
|
|
|
root: copy *src_dir,
|
|
|
|
dst_dir: copy *dst_dir,
|
2013-03-07 16:54:23 -06:00
|
|
|
id: copy *id,
|
|
|
|
libs: ~[],
|
|
|
|
mains: ~[],
|
|
|
|
tests: ~[],
|
|
|
|
benchs: ~[]
|
|
|
|
}
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
|
|
|
|
fn check_dir(&self) -> Path {
|
2013-04-12 18:15:40 -05:00
|
|
|
use conditions::bad_path::cond;
|
2013-03-07 16:54:23 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Pushing onto root: %s | %s", self.id.path.to_str(),
|
|
|
|
self.root.to_str());
|
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
let dir = self.root.push_rel(&self.id.path).normalize();
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Checking dir: %s", dir.to_str());
|
|
|
|
|
|
|
|
if !os::path_exists(&dir) {
|
2013-03-07 16:54:23 -06:00
|
|
|
return cond.raise((dir, ~"missing package dir"));
|
|
|
|
}
|
2013-04-11 19:43:02 -05:00
|
|
|
|
|
|
|
if !os::path_is_dir(&dir) {
|
|
|
|
return cond.raise((dir, ~"supplied path for package dir is a \
|
|
|
|
non-directory"));
|
2013-03-07 16:54:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
dir
|
|
|
|
}
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
// If a file named "pkg.rs" in the current directory exists,
|
|
|
|
// return the path for it. Otherwise, None
|
|
|
|
fn package_script_option(&self, cwd: &Path) -> Option<Path> {
|
|
|
|
let maybe_path = cwd.push("pkg.rs");
|
|
|
|
if os::path_exists(&maybe_path) {
|
|
|
|
Some(maybe_path)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// True if the given path's stem is self's pkg ID's stem
|
|
|
|
/// or if the pkg ID's stem is <rust-foo> and the given path's
|
|
|
|
/// stem is foo
|
2013-04-17 15:53:34 -05:00
|
|
|
/// Requires that dashes in p have already been normalized to
|
|
|
|
/// underscores
|
2013-04-11 19:43:02 -05:00
|
|
|
fn stem_matches(&self, p: &Path) -> bool {
|
2013-04-17 15:53:34 -05:00
|
|
|
let self_id = normalize(~self.id.path).filestem();
|
2013-04-11 19:43:02 -05:00
|
|
|
if self_id == p.filestem() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for self_id.each |pth| {
|
2013-04-17 15:53:34 -05:00
|
|
|
if pth.starts_with("rust_") // because p is already normalized
|
2013-04-11 19:43:02 -05:00
|
|
|
&& match p.filestem() {
|
|
|
|
Some(s) => str::eq_slice(s, pth.slice(5, pth.len())),
|
|
|
|
None => false
|
|
|
|
} { return true; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
false
|
|
|
|
}
|
2013-03-07 16:54:23 -06:00
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
fn push_crate(cs: &mut ~[Crate], prefix: uint, p: &Path) {
|
|
|
|
assert!(p.components.len() > prefix);
|
2013-03-07 16:54:23 -06:00
|
|
|
let mut sub = Path("");
|
|
|
|
for vec::slice(p.components, prefix,
|
|
|
|
p.components.len()).each |c| {
|
|
|
|
sub = sub.push(*c);
|
|
|
|
}
|
|
|
|
debug!("found crate %s", sub.to_str());
|
|
|
|
cs.push(Crate::new(&sub));
|
|
|
|
}
|
|
|
|
|
2013-04-17 15:53:34 -05:00
|
|
|
/// Infers crates to build. Called only in the case where there
|
|
|
|
/// is no custom build logic
|
2013-03-07 16:54:23 -06:00
|
|
|
fn find_crates(&mut self) {
|
|
|
|
use PkgSrc::push_crate;
|
2013-04-11 19:43:02 -05:00
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
let dir = self.check_dir();
|
|
|
|
let prefix = dir.components.len();
|
2013-04-17 15:53:34 -05:00
|
|
|
debug!("Matching against %?", self.id.path.filestem());
|
2013-03-07 16:54:23 -06:00
|
|
|
for os::walk_dir(&dir) |pth| {
|
|
|
|
match pth.filename() {
|
|
|
|
Some(~"lib.rs") => push_crate(&mut self.libs,
|
|
|
|
prefix, pth),
|
|
|
|
Some(~"main.rs") => push_crate(&mut self.mains,
|
|
|
|
prefix, pth),
|
|
|
|
Some(~"test.rs") => push_crate(&mut self.tests,
|
|
|
|
prefix, pth),
|
|
|
|
Some(~"bench.rs") => push_crate(&mut self.benchs,
|
|
|
|
prefix, pth),
|
2013-04-17 17:47:24 -05:00
|
|
|
_ => ()
|
2013-03-07 16:54:23 -06:00
|
|
|
}
|
|
|
|
}
|
2013-04-17 17:47:24 -05:00
|
|
|
|
|
|
|
if self.libs.is_empty() && self.mains.is_empty()
|
|
|
|
&& self.tests.is_empty() && self.benchs.is_empty() {
|
|
|
|
|
|
|
|
util::note(~"Couldn't infer any crates to build.\n\
|
|
|
|
Try naming a crate `main.rs`, `lib.rs`, \
|
|
|
|
`test.rs`, or `bench.rs`.");
|
|
|
|
fail!(~"Failed to infer crates to build");
|
|
|
|
}
|
2013-04-18 17:24:25 -05:00
|
|
|
|
2013-03-07 16:54:23 -06:00
|
|
|
debug!("found %u libs, %u mains, %u tests, %u benchs",
|
|
|
|
self.libs.len(),
|
|
|
|
self.mains.len(),
|
|
|
|
self.tests.len(),
|
|
|
|
self.benchs.len())
|
|
|
|
}
|
|
|
|
|
2013-04-17 15:53:34 -05:00
|
|
|
fn build_crates(&self, dst_dir: &Path,
|
2013-03-07 16:54:23 -06:00
|
|
|
src_dir: &Path,
|
|
|
|
crates: &[Crate],
|
2013-04-11 19:43:02 -05:00
|
|
|
cfgs: ~[~str],
|
2013-04-17 15:53:34 -05:00
|
|
|
test: bool, crate_type: crate_type) {
|
2013-03-07 16:54:23 -06:00
|
|
|
|
|
|
|
for crates.each |&crate| {
|
|
|
|
let path = &src_dir.push_rel(&crate.file).normalize();
|
2013-04-11 19:43:02 -05:00
|
|
|
util::note(fmt!("build_crates: compiling %s", path.to_str()));
|
|
|
|
util::note(fmt!("build_crates: destination dir is %s", dst_dir.to_str()));
|
|
|
|
|
2013-04-17 15:53:34 -05:00
|
|
|
let result = util::compile_crate(None, self.id, path,
|
2013-03-07 16:54:23 -06:00
|
|
|
dst_dir,
|
|
|
|
crate.flags,
|
2013-04-11 19:43:02 -05:00
|
|
|
crate.cfgs + cfgs,
|
2013-04-17 15:53:34 -05:00
|
|
|
false, test, crate_type);
|
2013-04-12 14:49:11 -05:00
|
|
|
if !result {
|
2013-03-07 16:54:23 -06:00
|
|
|
build_err::cond.raise(fmt!("build failure on %s",
|
|
|
|
path.to_str()));
|
|
|
|
}
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Result of compiling %s was %?",
|
|
|
|
path.to_str(), result);
|
2013-03-07 16:54:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-11 19:43:02 -05:00
|
|
|
fn build(&self, dst_dir: &Path, cfgs: ~[~str]) {
|
2013-03-07 16:54:23 -06:00
|
|
|
let dir = self.check_dir();
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Building libs");
|
2013-04-17 15:53:34 -05:00
|
|
|
self.build_crates(dst_dir, &dir, self.libs, cfgs, false, lib_crate);
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Building mains");
|
2013-04-17 15:53:34 -05:00
|
|
|
self.build_crates(dst_dir, &dir, self.mains, cfgs, false, bin_crate);
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Building tests");
|
2013-04-17 15:53:34 -05:00
|
|
|
self.build_crates(dst_dir, &dir, self.tests, cfgs, true, bin_crate);
|
2013-04-11 19:43:02 -05:00
|
|
|
debug!("Building benches");
|
2013-04-17 15:53:34 -05:00
|
|
|
self.build_crates(dst_dir, &dir, self.benchs, cfgs, true, bin_crate);
|
2013-03-07 16:54:23 -06:00
|
|
|
}
|
2013-01-23 00:38:05 -06:00
|
|
|
}
|