Skip to content

Commit a6a31ec

Browse files
committed
rustpkg::crate_id: Remove CrateId
There is no significant difference between `rustpkg::crate_id::CrateId` and `syntax::crateid::CrateId`. rustpkg's one is replaced by syntax's one.
1 parent df9067c commit a6a31ec

File tree

11 files changed

+413
-499
lines changed

11 files changed

+413
-499
lines changed

src/librustpkg/api.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use CtxMethods;
1212
use context::*;
1313
use crate::*;
14-
use crate_id::*;
1514
use package_source::*;
1615
use path_util::{platform_library_name, target_build_dir};
1716
use target::*;
@@ -26,6 +25,7 @@ use extra::arc::{Arc,RWArc};
2625
use extra::workcache;
2726
use extra::workcache::{Database, FreshnessMap};
2827
use extra::treemap::TreeMap;
28+
use syntax::crateid::CrateId;
2929

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

81-
pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Option<~str>,
82-
lib: Path) {
83-
build_lib_with_cfgs(sysroot, root, name, version, lib, ~[])
81+
pub fn build_lib(sysroot: Path, root: Path, name: ~str, lib: Path) {
82+
build_lib_with_cfgs(sysroot, root, name, lib, ~[])
8483
}
8584

86-
pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
87-
version: Option<~str>, lib: Path, cfgs: ~[~str]) {
85+
pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str, lib: Path, cfgs: ~[~str]) {
8886
let cx = default_context(sysroot, root.clone());
87+
let crate_id: CrateId = from_str(name).expect("valid crate id");
8988
let pkg_src = PkgSrc {
9089
source_workspace: root.clone(),
9190
build_in_destination: false,
9291
destination_workspace: root.clone(),
9392
start_dir: root.join_many(["src", name.as_slice()]),
94-
id: CrateId{ version: version, ..CrateId::new(name)},
93+
id: crate_id,
9594
// n.b. This assumes the package only has one crate
9695
libs: ~[mk_crate(lib)],
9796
mains: ~[],
@@ -101,20 +100,19 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
101100
pkg_src.build(&cx, cfgs, []);
102101
}
103102

104-
pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Option<~str>,
105-
main: Path) {
106-
build_exe_with_cfgs(sysroot, root, name, version, main, ~[])
103+
pub fn build_exe(sysroot: Path, root: Path, name: ~str, main: Path) {
104+
build_exe_with_cfgs(sysroot, root, name, main, ~[])
107105
}
108106

109-
pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
110-
version: Option<~str>, main: Path, cfgs: ~[~str]) {
107+
pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str, main: Path, cfgs: ~[~str]) {
111108
let cx = default_context(sysroot, root.clone());
109+
let crate_id: CrateId = from_str(name).expect("valid crate id");
112110
let pkg_src = PkgSrc {
113111
source_workspace: root.clone(),
114112
build_in_destination: false,
115113
destination_workspace: root.clone(),
116114
start_dir: root.join_many(["src", name.as_slice()]),
117-
id: CrateId{ version: version, ..CrateId::new(name)},
115+
id: crate_id,
118116
libs: ~[],
119117
// n.b. This assumes the package only has one crate
120118
mains: ~[mk_crate(main)],
@@ -128,11 +126,10 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
128126
pub fn install_pkg(cx: &BuildContext,
129127
workspace: Path,
130128
name: ~str,
131-
version: Option<~str>,
132129
// For now, these inputs are assumed to be inputs to each of the crates
133130
more_inputs: ~[(~str, Path)]) { // pairs of Kind and Path
134-
let crateid = CrateId{ version: version, ..CrateId::new(name)};
135-
cx.install(PkgSrc::new(workspace.clone(), workspace, false, crateid),
131+
let crate_id: CrateId = from_str(name).expect("valid crate id");
132+
cx.install(PkgSrc::new(workspace.clone(), workspace, false, crate_id),
136133
&WhatToBuild{ build_type: Inferred,
137134
inputs_to_discover: more_inputs,
138135
sources: Everything });
@@ -156,10 +153,10 @@ pub fn build_library_in_workspace(exec: &mut workcache::Exec,
156153
let out_name = workspace_build_dir.join_many([package_name.to_str(),
157154
platform_library_name(output)]);
158155
// make paths absolute
159-
let crateid = CrateId::new(package_name);
156+
let crateid: CrateId = from_str(package_name).expect("valid crate id");
160157
let absolute_paths = paths.map(|s| {
161158
let whatever = workspace.join_many([~"src",
162-
crateid.to_str(),
159+
crateid.short_name_with_version(),
163160
s.to_owned()]);
164161
whatever.as_str().unwrap().to_owned()
165162
});
@@ -189,7 +186,7 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
189186
use bad_pkg_id = conditions::bad_pkg_id::cond;
190187

191188
// (this assumes no particular version is requested)
192-
let crateid = CrateId::new(package_name);
189+
let crateid = from_str(package_name).expect("valid crate id");
193190
let workspaces = pkg_parent_workspaces(context, &crateid);
194191
if workspaces.is_empty() {
195192
bad_pkg_id.raise((Path::new(package_name), package_name.to_owned()));

src/librustpkg/conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Useful conditions
1212

13-
pub use crate_id::CrateId;
13+
pub use syntax::crateid::CrateId;
1414
pub use std::io::FileStat;
1515
pub use std::io::process::ProcessExit;
1616
pub use std::path::Path;

src/librustpkg/crate_id.rs

Lines changed: 0 additions & 144 deletions
This file was deleted.

src/librustpkg/installed_packages.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
// Listing installed packages
1212

1313
use rustc::metadata::filesearch::rust_path;
14-
use path_util::*;
1514
use std::os;
1615
use std::io;
1716
use std::io::fs;
17+
use syntax::crateid::CrateId;
1818

1919
pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
2020
let workspaces = rust_path();
@@ -28,7 +28,8 @@ pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
2828
match exec.filestem_str() {
2929
None => (),
3030
Some(exec_path) => {
31-
if !f(&CrateId::new(exec_path)) {
31+
let crate_id = from_str(exec_path).expect("valid crate id");
32+
if !f(&crate_id) {
3233
return false;
3334
}
3435
}
@@ -50,7 +51,8 @@ pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
5051
let rel_path = rel_p.join(basename);
5152
rel_path.display().with_str(|s| {
5253
debug!("Rel name: {}", s);
53-
f(&CrateId::new(s));
54+
let crate_id = from_str(s).expect("valid crate id");
55+
f(&crate_id);
5456
});
5557
}
5658
None => ()

0 commit comments

Comments
 (0)