Add field desired_targets to binstall::Options

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-21 15:05:12 +10:00
parent aa88dce215
commit 6a95bb07e0
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
4 changed files with 6 additions and 11 deletions

View file

@ -1,6 +1,6 @@
use std::path::PathBuf; use std::path::PathBuf;
use crate::PkgOverride; use crate::{DesiredTargets, PkgOverride};
mod resolve; mod resolve;
pub use resolve::*; pub use resolve::*;
@ -14,4 +14,5 @@ pub struct Options {
pub version: Option<String>, pub version: Option<String>,
pub manifest_path: Option<PathBuf>, pub manifest_path: Option<PathBuf>,
pub cli_overrides: PkgOverride, pub cli_overrides: PkgOverride,
pub desired_targets: DesiredTargets,
} }

View file

@ -11,7 +11,6 @@ use crate::{bins, fetchers::Fetcher, *};
pub async fn install( pub async fn install(
resolution: Resolution, resolution: Resolution,
opts: Arc<Options>, opts: Arc<Options>,
desired_targets: DesiredTargets,
jobserver_client: LazyJobserverClient, jobserver_client: LazyJobserverClient,
) -> Result<()> { ) -> Result<()> {
match resolution { match resolution {
@ -32,7 +31,7 @@ pub async fn install(
install_from_package(fetcher, opts, cvs, version, bin_path, bin_files).await install_from_package(fetcher, opts, cvs, version, bin_path, bin_files).await
} }
Resolution::InstallFromSource { package } => { Resolution::InstallFromSource { package } => {
let desired_targets = desired_targets.get().await; let desired_targets = opts.desired_targets.get().await;
let target = desired_targets let target = desired_targets
.first() .first()
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?; .ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;

View file

@ -75,7 +75,6 @@ impl Resolution {
pub async fn resolve( pub async fn resolve(
opts: Arc<Options>, opts: Arc<Options>,
crate_name: CrateName, crate_name: CrateName,
desired_targets: DesiredTargets,
temp_dir: Arc<Path>, temp_dir: Arc<Path>,
install_path: Arc<Path>, install_path: Arc<Path>,
client: Client, client: Client,
@ -123,7 +122,7 @@ pub async fn resolve(
let mut fetchers = MultiFetcher::default(); let mut fetchers = MultiFetcher::default();
let desired_targets = desired_targets.get().await; let desired_targets = opts.desired_targets.get().await;
for target in desired_targets { for target in desired_targets {
debug!("Building metadata for target: {target}"); debug!("Building metadata for target: {target}");

View file

@ -266,6 +266,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
version: opts.version.take(), version: opts.version.take(),
manifest_path: opts.manifest_path.take(), manifest_path: opts.manifest_path.take(),
cli_overrides, cli_overrides,
desired_targets,
}); });
let tasks: Vec<_> = if !opts.dry_run && !opts.no_confirm { let tasks: Vec<_> = if !opts.dry_run && !opts.no_confirm {
@ -276,7 +277,6 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
tokio::spawn(binstall::resolve( tokio::spawn(binstall::resolve(
binstall_opts.clone(), binstall_opts.clone(),
crate_name, crate_name,
desired_targets.clone(),
temp_dir_path.clone(), temp_dir_path.clone(),
install_path.clone(), install_path.clone(),
client.clone(), client.clone(),
@ -300,7 +300,6 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
tokio::spawn(binstall::install( tokio::spawn(binstall::install(
resolution, resolution,
binstall_opts.clone(), binstall_opts.clone(),
desired_targets.clone(),
jobserver_client.clone(), jobserver_client.clone(),
)) ))
}) })
@ -312,9 +311,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
.map(|crate_name| { .map(|crate_name| {
let opts = binstall_opts.clone(); let opts = binstall_opts.clone();
let temp_dir_path = temp_dir_path.clone(); let temp_dir_path = temp_dir_path.clone();
let desired_target = desired_targets.clone();
let jobserver_client = jobserver_client.clone(); let jobserver_client = jobserver_client.clone();
let desired_targets = desired_targets.clone();
let client = client.clone(); let client = client.clone();
let crates_io_api_client = crates_io_api_client.clone(); let crates_io_api_client = crates_io_api_client.clone();
let install_path = install_path.clone(); let install_path = install_path.clone();
@ -323,7 +320,6 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
let resolution = binstall::resolve( let resolution = binstall::resolve(
opts.clone(), opts.clone(),
crate_name, crate_name,
desired_targets.clone(),
temp_dir_path, temp_dir_path,
install_path, install_path,
client, client,
@ -331,7 +327,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
) )
.await?; .await?;
binstall::install(resolution, opts, desired_target, jobserver_client).await binstall::install(resolution, opts, jobserver_client).await
}) })
}) })
.collect() .collect()