@@ -439,26 +439,30 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
439439 let pkg_id = PkgId :: new ( lib_name) ;
440440 let workspaces = pkg_parent_workspaces ( & self . context . context ,
441441 & pkg_id) ;
442- let dep_workspace = if workspaces. is_empty ( ) {
443- error ( fmt ! ( "Couldn't find package %s, which is needed by %s, \
444- in any of the workspaces in the RUST_PATH (%?)",
445- lib_name,
446- self . parent. to_str( ) ,
447- rust_path( ) ) ) ;
442+ let source_workspace = if workspaces. is_empty ( ) {
443+ error ( fmt ! ( "Couldn't find package %s \
444+ in any of the workspaces in the RUST_PATH (%s)",
445+ lib_name,
446+ rust_path( ) . map( |s| s. to_str( ) ) . connect( ":" ) ) ) ;
448447 cond. raise ( ( pkg_id. clone ( ) , ~"Dependency not found") )
449448 }
450- else {
449+ else {
451450 workspaces[ 0 ]
452451 } ;
453452 let ( outputs_disc, inputs_disc) =
454- self . context . install ( PkgSrc :: new ( dep_workspace. clone ( ) ,
455- false ,
453+ self . context . install ( PkgSrc :: new ( source_workspace. clone ( ) ,
454+ // Use the rust_path_hack to search for dependencies iff
455+ // we were already using it
456+ self . context . context . use_rust_path_hack ,
456457 pkg_id) ,
457458 & JustOne ( Path (
458- lib_crate_filename) ) ) ;
459+ lib_crate_filename) ) ) ;
459460 debug ! ( "Installed %s, returned %? dependencies and \
460461 %? transitive dependencies",
461462 lib_name, outputs_disc. len( ) , inputs_disc. len( ) ) ;
463+ // It must have installed *something*...
464+ assert ! ( !outputs_disc. is_empty( ) ) ;
465+ let target_workspace = outputs_disc[ 0 ] . pop ( ) ;
462466 for dep in outputs_disc. iter ( ) {
463467 debug ! ( "Discovering a binary input: %s" , dep. to_str( ) ) ;
464468 self . exec . discover_input ( "binary" ,
@@ -471,31 +475,24 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
471475 * dep,
472476 digest_file_with_date ( & Path ( * dep) ) ) ;
473477 }
474- else if * what == ~"binary" {
478+ else if * what == ~"binary" {
475479 self . exec . discover_input ( * what,
476480 * dep,
477481 digest_only_date ( & Path ( * dep) ) ) ;
478482 }
479- else {
483+ else {
480484 fail ! ( "Bad kind: %s" , * what) ;
481485 }
482486 }
483487 // Also, add an additional search path
484- debug ! ( "Adding additional search path: %s" , lib_name) ;
485- let installed_library =
486- installed_library_in_workspace ( & Path ( lib_name) , & dep_workspace)
487- . expect ( fmt ! ( "rustpkg failed to install dependency %s" ,
488- lib_name) ) ;
489- let install_dir = installed_library. pop ( ) ;
490- debug ! ( "Installed %s into %s [%?]" , lib_name, install_dir. to_str( ) ,
491- datestamp( & installed_library) ) ;
492- ( self . save ) ( install_dir) ;
488+ debug ! ( "Installed %s into %s" , lib_name, target_workspace. to_str( ) ) ;
489+ ( self . save ) ( target_workspace) ;
493490 }
494- } }
491+ }
492+ }
495493 // Ignore `use`s
496494 _ => ( )
497495 }
498-
499496 visit:: walk_view_item ( self , vi, env)
500497 }
501498}
0 commit comments