Use get_desired_targets in entry

instead of `detect_targets`, so that if `opts.targets` is
`None`, the future returned by `detect_targets` can be run
in parallel by using `tokio::spawn` with other async code
in `entry`, such as `fetch_crate_cratesio`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-23 14:47:59 +10:00
parent be4b3ead97
commit 68d111f946
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -193,6 +193,8 @@ async fn entry() -> Result<()> {
let mut uithread = UIThread::new(!opts.no_confirm);
let desired_targets = get_desired_targets(&opts.targets);
// Compute install directory
let install_path = get_install_path(opts.install_path.as_deref()).ok_or_else(|| {
error!("No viable install path found of specified, try `--install-path`");
@ -242,22 +244,11 @@ async fn entry() -> Result<()> {
manifest.bin,
);
let desired_targets = {
let from_opts = opts
.targets
.as_ref()
.map(|ts| ts.split(',').map(|t| t.to_string()).collect());
if let Some(ts) = from_opts {
ts
} else {
detect_targets().await
}
};
let mut fetchers = MultiFetcher::default();
for target in &desired_targets {
let desired_targets = desired_targets.get().await;
for target in desired_targets {
debug!("Building metadata for target: {target}");
let mut target_meta = meta.clone();