1111use CtxMethods ;
1212use context:: * ;
1313use crate :: * ;
14- use crate_id:: * ;
1514use package_source:: * ;
1615use path_util:: { platform_library_name, target_build_dir} ;
1716use target:: * ;
18- use version:: Version ;
1917use workspace:: pkg_parent_workspaces;
2018use workcache_support:: * ;
2119pub use path_util:: default_workspace;
@@ -27,6 +25,7 @@ use extra::arc::{Arc,RWArc};
2725use extra:: workcache;
2826use extra:: workcache:: { Database , FreshnessMap } ;
2927use extra:: treemap:: TreeMap ;
28+ use syntax:: crateid:: CrateId ;
3029
3130// A little sad -- duplicated from rustc::back::*
3231#[ cfg( target_arch = "arm" ) ]
@@ -79,20 +78,19 @@ pub fn new_workcache_context(p: &Path) -> workcache::Context {
7978 workcache:: Context :: new_with_freshness ( db, cfg, Arc :: new ( freshness) )
8079}
8180
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, ~[ ] )
8583}
8684
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 ] ) {
8986 let cx = default_context ( sysroot, root. clone ( ) ) ;
87+ let crate_id: CrateId = from_str ( name) . expect ( "valid crate id" ) ;
9088 let pkg_src = PkgSrc {
9189 source_workspace : root. clone ( ) ,
9290 build_in_destination : false ,
9391 destination_workspace : root. clone ( ) ,
9492 start_dir : root. join_many ( [ "src" , name. as_slice ( ) ] ) ,
95- id : CrateId { version : version , .. CrateId :: new ( name ) } ,
93+ id : crate_id ,
9694 // n.b. This assumes the package only has one crate
9795 libs : ~[ mk_crate ( lib) ] ,
9896 mains : ~[ ] ,
@@ -102,20 +100,19 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
102100 pkg_src. build ( & cx, cfgs, [ ] ) ;
103101}
104102
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, ~[ ] )
108105}
109106
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 ] ) {
112108 let cx = default_context ( sysroot, root. clone ( ) ) ;
109+ let crate_id: CrateId = from_str ( name) . expect ( "valid crate id" ) ;
113110 let pkg_src = PkgSrc {
114111 source_workspace : root. clone ( ) ,
115112 build_in_destination : false ,
116113 destination_workspace : root. clone ( ) ,
117114 start_dir : root. join_many ( [ "src" , name. as_slice ( ) ] ) ,
118- id : CrateId { version : version , .. CrateId :: new ( name ) } ,
115+ id : crate_id ,
119116 libs : ~[ ] ,
120117 // n.b. This assumes the package only has one crate
121118 mains : ~[ mk_crate ( main) ] ,
@@ -129,11 +126,10 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
129126pub fn install_pkg ( cx : & BuildContext ,
130127 workspace : Path ,
131128 name : ~str ,
132- version : Version ,
133129 // For now, these inputs are assumed to be inputs to each of the crates
134130 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 ) ,
137133 & WhatToBuild { build_type : Inferred ,
138134 inputs_to_discover : more_inputs,
139135 sources : Everything } ) ;
@@ -157,10 +153,10 @@ pub fn build_library_in_workspace(exec: &mut workcache::Exec,
157153 let out_name = workspace_build_dir. join_many ( [ package_name. to_str ( ) ,
158154 platform_library_name ( output) ] ) ;
159155 // make paths absolute
160- let crateid = CrateId :: new ( package_name) ;
156+ let crateid: CrateId = from_str ( package_name) . expect ( "valid crate id" ) ;
161157 let absolute_paths = paths. map ( |s| {
162158 let whatever = workspace. join_many ( [ ~"src",
163- crateid. to_str ( ) ,
159+ crateid. short_name_with_version ( ) ,
164160 s. to_owned ( ) ] ) ;
165161 whatever. as_str ( ) . unwrap ( ) . to_owned ( )
166162 } ) ;
@@ -190,7 +186,7 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
190186 use bad_pkg_id = conditions:: bad_pkg_id:: cond;
191187
192188 // (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" ) ;
194190 let workspaces = pkg_parent_workspaces ( context, & crateid) ;
195191 if workspaces. is_empty ( ) {
196192 bad_pkg_id. raise ( ( Path :: new ( package_name) , package_name. to_owned ( ) ) ) ;
0 commit comments