11
11
use CtxMethods ;
12
12
use context:: * ;
13
13
use crate :: * ;
14
- use crate_id:: * ;
15
14
use package_source:: * ;
16
15
use path_util:: { platform_library_name, target_build_dir} ;
17
16
use target:: * ;
18
- use version:: Version ;
19
17
use workspace:: pkg_parent_workspaces;
20
18
use workcache_support:: * ;
21
19
pub use path_util:: default_workspace;
@@ -27,6 +25,7 @@ use extra::arc::{Arc,RWArc};
27
25
use extra:: workcache;
28
26
use extra:: workcache:: { Database , FreshnessMap } ;
29
27
use extra:: treemap:: TreeMap ;
28
+ use syntax:: crateid:: CrateId ;
30
29
31
30
// A little sad -- duplicated from rustc::back::*
32
31
#[ cfg( target_arch = "arm" ) ]
@@ -79,20 +78,19 @@ pub fn new_workcache_context(p: &Path) -> workcache::Context {
79
78
workcache:: Context :: new_with_freshness ( db, cfg, Arc :: new ( freshness) )
80
79
}
81
80
82
- pub fn build_lib ( sysroot : Path , root : Path , name : ~str , version : Version ,
83
- lib : Path ) {
84
- 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, ~[ ] )
85
83
}
86
84
87
- pub fn build_lib_with_cfgs ( sysroot : Path , root : Path , name : ~str ,
88
- version : Version , lib : Path , cfgs : ~[ ~str ] ) {
85
+ pub fn build_lib_with_cfgs ( sysroot : Path , root : Path , name : ~str , lib : Path , cfgs : ~[ ~str ] ) {
89
86
let cx = default_context ( sysroot, root. clone ( ) ) ;
87
+ let crate_id: CrateId = from_str ( name) . expect ( "valid crate id" ) ;
90
88
let pkg_src = PkgSrc {
91
89
source_workspace : root. clone ( ) ,
92
90
build_in_destination : false ,
93
91
destination_workspace : root. clone ( ) ,
94
92
start_dir : root. join_many ( [ "src" , name. as_slice ( ) ] ) ,
95
- id : CrateId { version : version , .. CrateId :: new ( name ) } ,
93
+ id : crate_id ,
96
94
// n.b. This assumes the package only has one crate
97
95
libs : ~[ mk_crate ( lib) ] ,
98
96
mains : ~[ ] ,
@@ -102,20 +100,19 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
102
100
pkg_src. build ( & cx, cfgs, [ ] ) ;
103
101
}
104
102
105
- pub fn build_exe ( sysroot : Path , root : Path , name : ~str , version : Version ,
106
- main : Path ) {
107
- 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, ~[ ] )
108
105
}
109
106
110
- pub fn build_exe_with_cfgs ( sysroot : Path , root : Path , name : ~str ,
111
- version : Version , main : Path , cfgs : ~[ ~str ] ) {
107
+ pub fn build_exe_with_cfgs ( sysroot : Path , root : Path , name : ~str , main : Path , cfgs : ~[ ~str ] ) {
112
108
let cx = default_context ( sysroot, root. clone ( ) ) ;
109
+ let crate_id: CrateId = from_str ( name) . expect ( "valid crate id" ) ;
113
110
let pkg_src = PkgSrc {
114
111
source_workspace : root. clone ( ) ,
115
112
build_in_destination : false ,
116
113
destination_workspace : root. clone ( ) ,
117
114
start_dir : root. join_many ( [ "src" , name. as_slice ( ) ] ) ,
118
- id : CrateId { version : version , .. CrateId :: new ( name ) } ,
115
+ id : crate_id ,
119
116
libs : ~[ ] ,
120
117
// n.b. This assumes the package only has one crate
121
118
mains : ~[ mk_crate ( main) ] ,
@@ -129,11 +126,10 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
129
126
pub fn install_pkg ( cx : & BuildContext ,
130
127
workspace : Path ,
131
128
name : ~str ,
132
- version : Version ,
133
129
// For now, these inputs are assumed to be inputs to each of the crates
134
130
more_inputs : ~[ ( ~str , Path ) ] ) { // pairs of Kind and Path
135
- let crateid = CrateId { version : version , .. CrateId :: new ( name) } ;
136
- 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 ) ,
137
133
& WhatToBuild { build_type : Inferred ,
138
134
inputs_to_discover : more_inputs,
139
135
sources : Everything } ) ;
@@ -157,10 +153,10 @@ pub fn build_library_in_workspace(exec: &mut workcache::Exec,
157
153
let out_name = workspace_build_dir. join_many ( [ package_name. to_str ( ) ,
158
154
platform_library_name ( output) ] ) ;
159
155
// make paths absolute
160
- let crateid = CrateId :: new ( package_name) ;
156
+ let crateid: CrateId = from_str ( package_name) . expect ( "valid crate id" ) ;
161
157
let absolute_paths = paths. map ( |s| {
162
158
let whatever = workspace. join_many ( [ ~"src",
163
- crateid. to_str ( ) ,
159
+ crateid. short_name_with_version ( ) ,
164
160
s. to_owned ( ) ] ) ;
165
161
whatever. as_str ( ) . unwrap ( ) . to_owned ( )
166
162
} ) ;
@@ -190,7 +186,7 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
190
186
use bad_pkg_id = conditions:: bad_pkg_id:: cond;
191
187
192
188
// (this assumes no particular version is requested)
193
- let crateid = CrateId :: new ( package_name) ;
189
+ let crateid = from_str ( package_name) . expect ( "valid crate id" ) ;
194
190
let workspaces = pkg_parent_workspaces ( context, & crateid) ;
195
191
if workspaces. is_empty ( ) {
196
192
bad_pkg_id. raise ( ( Path :: new ( package_name) , package_name. to_owned ( ) ) ) ;
0 commit comments