Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustpkg: Move code from lib.rs to run_cmd.rs and perform.rs #11379

Closed
wants to merge 8 commits into from
9 changes: 6 additions & 3 deletions src/librustpkg/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::*;
use crate_id::*;
use package_source::*;
use path_util::{platform_library_name, target_build_dir};
use perform::{install};
use target::*;
use version::Version;
use workspace::pkg_parent_workspaces;
Expand Down Expand Up @@ -49,6 +50,7 @@ pub fn new_default_context(c: workcache::Context, p: Path) -> BuildContext {
cfgs: ~[],
rustc_flags: RustcFlags::default(),
use_rust_path_hack: false,
supplied_sysroot: None
},
sysroot: p,
workcache_context: c
Expand Down Expand Up @@ -133,10 +135,11 @@ pub fn install_pkg(cx: &BuildContext,
// For now, these inputs are assumed to be inputs to each of the crates
more_inputs: ~[(~str, Path)]) { // pairs of Kind and Path
let crateid = CrateId{ version: version, ..CrateId::new(name)};
cx.install(PkgSrc::new(workspace.clone(), workspace, false, crateid),
&WhatToBuild{ build_type: Inferred,
let pkg_src = PkgSrc::new(workspace.clone(), workspace, false, crateid);
let what = WhatToBuild{ build_type: Inferred,
inputs_to_discover: more_inputs,
sources: Everything });
sources: Everything };
install(pkg_src, &what, cx);
}

/// Builds an arbitrary library whose short name is `output`,
Expand Down
24 changes: 24 additions & 0 deletions src/librustpkg/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

// Context data structure used by rustpkg

use api;
use extra::workcache;
use path_util::{default_workspace};
use rustc::driver::session;
use rustc::metadata::filesearch;
use rustc::metadata::filesearch::rustlibdir;

use std::hashmap::HashSet;
Expand All @@ -27,6 +30,8 @@ pub struct Context {
// FOO/src/bar-0.1 instead of FOO). The flag doesn't affect where
// rustpkg stores build artifacts.
use_rust_path_hack: bool,
// The root directory containing the Rust standard libraries
supplied_sysroot: Option<~str>
}

#[deriving(Clone)]
Expand Down Expand Up @@ -75,6 +80,25 @@ impl BuildContext {
pub fn additional_library_paths(&self) -> HashSet<Path> {
self.context.rustc_flags.additional_library_paths.clone()
}

pub fn from_context(context: &Context) -> BuildContext{

let sysroot = match context.supplied_sysroot.clone() {
Some(ref s) => Path::new(s.clone()),
_ => filesearch::get_or_default_sysroot()
};
debug!("Using sysroot: {}", sysroot.display());

let ws = default_workspace();
debug!("Will store workcache in {}", ws.display());

BuildContext {
context: context.clone(),
sysroot: sysroot.clone(),
workcache_context: api::default_context(sysroot.clone(),
default_workspace()).workcache_context
}
}
}

/*
Expand Down
Loading