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