Skip to content

rustpkg: CrateId cleanup #11478

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

Merged
merged 4 commits into from
Jan 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions src/librustpkg/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
use CtxMethods;
use context::*;
use crate::*;
use crate_id::*;
use package_source::*;
use path_util::{platform_library_name, target_build_dir};
use target::*;
use version::Version;
use workspace::pkg_parent_workspaces;
use workcache_support::*;
pub use path_util::default_workspace;
Expand All @@ -27,6 +25,7 @@ use extra::arc::{Arc,RWArc};
use extra::workcache;
use extra::workcache::{Database, FreshnessMap};
use extra::treemap::TreeMap;
use syntax::crateid::CrateId;

// A little sad -- duplicated from rustc::back::*
#[cfg(target_arch = "arm")]
Expand Down Expand Up @@ -79,20 +78,19 @@ pub fn new_workcache_context(p: &Path) -> workcache::Context {
workcache::Context::new_with_freshness(db, cfg, Arc::new(freshness))
}

pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
lib: Path) {
build_lib_with_cfgs(sysroot, root, name, version, lib, ~[])
pub fn build_lib(sysroot: Path, root: Path, name: ~str, lib: Path) {
build_lib_with_cfgs(sysroot, root, name, lib, ~[])
}

pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
version: Version, lib: Path, cfgs: ~[~str]) {
pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str, lib: Path, cfgs: ~[~str]) {
let cx = default_context(sysroot, root.clone());
let crate_id: CrateId = from_str(name).expect("valid crate id");
let pkg_src = PkgSrc {
source_workspace: root.clone(),
build_in_destination: false,
destination_workspace: root.clone(),
start_dir: root.join_many(["src", name.as_slice()]),
id: CrateId{ version: version, ..CrateId::new(name)},
id: crate_id,
// n.b. This assumes the package only has one crate
libs: ~[mk_crate(lib)],
mains: ~[],
Expand All @@ -102,20 +100,19 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
pkg_src.build(&cx, cfgs, []);
}

pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
main: Path) {
build_exe_with_cfgs(sysroot, root, name, version, main, ~[])
pub fn build_exe(sysroot: Path, root: Path, name: ~str, main: Path) {
build_exe_with_cfgs(sysroot, root, name, main, ~[])
}

pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
version: Version, main: Path, cfgs: ~[~str]) {
pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str, main: Path, cfgs: ~[~str]) {
let cx = default_context(sysroot, root.clone());
let crate_id: CrateId = from_str(name).expect("valid crate id");
let pkg_src = PkgSrc {
source_workspace: root.clone(),
build_in_destination: false,
destination_workspace: root.clone(),
start_dir: root.join_many(["src", name.as_slice()]),
id: CrateId{ version: version, ..CrateId::new(name)},
id: crate_id,
libs: ~[],
// n.b. This assumes the package only has one crate
mains: ~[mk_crate(main)],
Expand All @@ -129,11 +126,10 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
pub fn install_pkg(cx: &BuildContext,
workspace: Path,
name: ~str,
version: Version,
// 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),
let crate_id: CrateId = from_str(name).expect("valid crate id");
cx.install(PkgSrc::new(workspace.clone(), workspace, false, crate_id),
&WhatToBuild{ build_type: Inferred,
inputs_to_discover: more_inputs,
sources: Everything });
Expand All @@ -157,10 +153,10 @@ pub fn build_library_in_workspace(exec: &mut workcache::Exec,
let out_name = workspace_build_dir.join_many([package_name.to_str(),
platform_library_name(output)]);
// make paths absolute
let crateid = CrateId::new(package_name);
let crateid: CrateId = from_str(package_name).expect("valid crate id");
let absolute_paths = paths.map(|s| {
let whatever = workspace.join_many([~"src",
crateid.to_str(),
crateid.short_name_with_version(),
s.to_owned()]);
whatever.as_str().unwrap().to_owned()
});
Expand Down Expand Up @@ -190,7 +186,7 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
use bad_pkg_id = conditions::bad_pkg_id::cond;

// (this assumes no particular version is requested)
let crateid = CrateId::new(package_name);
let crateid = from_str(package_name).expect("valid crate id");
let workspaces = pkg_parent_workspaces(context, &crateid);
if workspaces.is_empty() {
bad_pkg_id.raise((Path::new(package_name), package_name.to_owned()));
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// Useful conditions

pub use crate_id::CrateId;
pub use syntax::crateid::CrateId;
pub use std::io::FileStat;
pub use std::io::process::ProcessExit;
pub use std::path::Path;
Expand Down
150 changes: 0 additions & 150 deletions src/librustpkg/crate_id.rs

This file was deleted.

8 changes: 5 additions & 3 deletions src/librustpkg/installed_packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
// Listing installed packages

use rustc::metadata::filesearch::rust_path;
use path_util::*;
use std::os;
use std::io;
use std::io::fs;
use syntax::crateid::CrateId;

pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
let workspaces = rust_path();
Expand All @@ -28,7 +28,8 @@ pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
match exec.filestem_str() {
None => (),
Some(exec_path) => {
if !f(&CrateId::new(exec_path)) {
let crate_id = from_str(exec_path).expect("valid crate id");
if !f(&crate_id) {
return false;
}
}
Expand All @@ -50,7 +51,8 @@ pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
let rel_path = rel_p.join(basename);
rel_path.display().with_str(|s| {
debug!("Rel name: {}", s);
f(&CrateId::new(s));
let crate_id = from_str(s).expect("valid crate id");
f(&crate_id);
});
}
None => ()
Expand Down
Loading