@@ -27,10 +27,8 @@ use context::{in_target, StopBefore, Link, Assemble, BuildContext};
27
27
use package_id:: PkgId ;
28
28
use package_source:: PkgSrc ;
29
29
use workspace:: pkg_parent_workspaces;
30
- use path_util:: { installed_library_in_workspace, U_RWX , rust_path, system_library, target_build_dir} ;
31
- use messages:: error;
32
- use conditions:: nonexistent_package:: cond;
33
-
30
+ use path_util:: { installed_library_in_workspace, U_RWX , system_library, target_build_dir} ;
31
+ use path_util:: default_workspace;
34
32
pub use target:: { OutputType , Main , Lib , Bench , Test , JustOne , lib_name_of, lib_crate_filename} ;
35
33
use workcache_support:: { digest_file_with_date, digest_only_date} ;
36
34
@@ -432,26 +430,26 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
432
430
lib_name. to_str( ) ) ;
433
431
// Try to install it
434
432
let pkg_id = PkgId :: new ( lib_name) ;
433
+ // Find all the workspaces in the RUST_PATH that contain this package.
435
434
let workspaces = pkg_parent_workspaces ( & self . context . context ,
436
435
& pkg_id) ;
437
- let source_workspace = if workspaces. is_empty ( ) {
438
- error ( format ! ( "Couldn't find package {} \
439
- in any of the workspaces in the RUST_PATH ({})",
440
- lib_name,
441
- rust_path( ) . map( |s| s. to_str( ) ) . connect( ":" ) ) ) ;
442
- cond. raise ( ( pkg_id. clone ( ) , ~"Dependency not found") )
443
- }
444
- else {
445
- workspaces[ 0 ]
446
- } ;
436
+ // Two cases:
437
+ // (a) `workspaces` is empty. That means there's no local source
438
+ // for this package. In that case, we pass the default workspace
439
+ // into `PkgSrc::new`, so that if it exists as a remote repository,
440
+ // its sources will be fetched into it.
441
+ // (b) `workspaces` is non-empty -- we found a local source for this
442
+ // package.
443
+ let dest_workspace = if workspaces. is_empty ( ) {
444
+ default_workspace ( )
445
+ } else { workspaces[ 0 ] } ;
446
+ let pkg_src = PkgSrc :: new ( dest_workspace,
447
+ // Use the rust_path_hack to search for dependencies iff
448
+ // we were already using it
449
+ self . context . context . use_rust_path_hack ,
450
+ pkg_id) ;
447
451
let ( outputs_disc, inputs_disc) =
448
- self . context . install ( PkgSrc :: new ( source_workspace. clone ( ) ,
449
- // Use the rust_path_hack to search for dependencies iff
450
- // we were already using it
451
- self . context . context . use_rust_path_hack ,
452
- pkg_id) ,
453
- & JustOne ( Path (
454
- lib_crate_filename) ) ) ;
452
+ self . context . install ( pkg_src, & JustOne ( Path ( lib_crate_filename) ) ) ;
455
453
debug2 ! ( "Installed {}, returned {:?} dependencies and \
456
454
{:?} transitive dependencies",
457
455
lib_name, outputs_disc. len( ) , inputs_disc. len( ) ) ;
0 commit comments