Skip to content

Commit

Permalink
rustpkg::crate_id: Remove CrateId
Browse files Browse the repository at this point in the history
There is no significant difference between `rustpkg::crate_id::CrateId`
and `syntax::crateid::CrateId`. rustpkg's one is replaced by syntax's
one.
  • Loading branch information
klutzy committed Jan 22, 2014
1 parent df9067c commit a6a31ec
Show file tree
Hide file tree
Showing 11 changed files with 413 additions and 499 deletions.
35 changes: 16 additions & 19 deletions src/librustpkg/api.rs
Expand Up @@ -11,7 +11,6 @@
use CtxMethods;
use context::*;
use crate::*;
use crate_id::*;
use package_source::*;
use path_util::{platform_library_name, target_build_dir};
use target::*;
Expand All @@ -26,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 @@ -78,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: Option<~str>,
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: Option<~str>, 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 @@ -101,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: Option<~str>,
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: Option<~str>, 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 @@ -128,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: Option<~str>,
// 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 @@ -156,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 @@ -189,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
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
144 changes: 0 additions & 144 deletions src/librustpkg/crate_id.rs

This file was deleted.

8 changes: 5 additions & 3 deletions src/librustpkg/installed_packages.rs
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

13 comments on commit a6a31ec

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from cmr
at klutzy@a6a31ec

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging klutzy/rust/rustpkg-crate-id = a6a31ec into auto

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klutzy/rust/rustpkg-crate-id = a6a31ec merged ok, testing candidate = cfab631f

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate a6a31ec found, likely manual push to master

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging klutzy/rust/rustpkg-crate-id = a6a31ec into auto

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klutzy/rust/rustpkg-crate-id = a6a31ec merged ok, testing candidate = c6adb91

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from cmr
at klutzy@a6a31ec

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging klutzy/rust/rustpkg-crate-id = a6a31ec into auto

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klutzy/rust/rustpkg-crate-id = a6a31ec merged ok, testing candidate = 2b62371

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a6a31ec Jan 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 2b62371

Please sign in to comment.