Skip to content

Commit d7b2c70

Browse files
committed
rustpkg: Fix fetching remote packages
Closes #9193
1 parent 0114ab6 commit d7b2c70

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/librustpkg/util.rs

+19-21
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ use context::{in_target, StopBefore, Link, Assemble, BuildContext};
2727
use package_id::PkgId;
2828
use package_source::PkgSrc;
2929
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;
3432
pub use target::{OutputType, Main, Lib, Bench, Test, JustOne, lib_name_of, lib_crate_filename};
3533
use workcache_support::{digest_file_with_date, digest_only_date};
3634

@@ -432,26 +430,26 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
432430
lib_name.to_str());
433431
// Try to install it
434432
let pkg_id = PkgId::new(lib_name);
433+
// Find all the workspaces in the RUST_PATH that contain this package.
435434
let workspaces = pkg_parent_workspaces(&self.context.context,
436435
&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);
447451
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)));
455453
debug2!("Installed {}, returned {:?} dependencies and \
456454
{:?} transitive dependencies",
457455
lib_name, outputs_disc.len(), inputs_disc.len());

0 commit comments

Comments
 (0)