1111use CtxMethods ;
1212use context:: * ;
1313use crate :: * ;
14- use crate_id:: * ;
1514use package_source:: * ;
1615use path_util:: { platform_library_name, target_build_dir} ;
1716use target:: * ;
@@ -26,6 +25,7 @@ use extra::arc::{Arc,RWArc};
2625use extra:: workcache;
2726use extra:: workcache:: { Database , FreshnessMap } ;
2827use 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,
128126pub 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 ( ) ) ) ;
0 commit comments