mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-15 07:06:36 +00:00
Add a --bin
argument to mirror cargo install --bin
. (#2189)
* Add a --bin argument to mirror cargo install --bin. * Update crates/bin/src/args.rs Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Signed-off-by: Matan Lurey <matanlurey@users.noreply.github.com> * Update crates/binstalk/src/ops.rs Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Signed-off-by: Matan Lurey <matanlurey@users.noreply.github.com> * Address feedback, make e2e-test test both source/non-source. * Update crates/bin/src/entry.rs Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Signed-off-by: Matan Lurey <matanlurey@users.noreply.github.com> * Update crates/binstalk/src/ops/resolve/resolution.rs Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Signed-off-by: Matan Lurey <matanlurey@users.noreply.github.com> * Update crates/binstalk/src/ops/resolve/resolution.rs Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Signed-off-by: Matan Lurey <matanlurey@users.noreply.github.com> * Update crates/binstalk/src/ops/resolve/resolution.rs Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Signed-off-by: Matan Lurey <matanlurey@users.noreply.github.com> * Get everything compiling again. * optimize ResolutionFetch::resolve_bins Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * fix e2e-test on unix due to ordering Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * fix specific-binaries.sh: relax no-compile Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --------- Signed-off-by: Matan Lurey <matanlurey@users.noreply.github.com> Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
parent
ea65a39d2d
commit
8d2b46b8bd
6 changed files with 83 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::{path::PathBuf, sync::Arc, time::Duration};
|
||||
|
||||
use compact_str::CompactString;
|
||||
use semver::VersionReq;
|
||||
|
||||
use crate::{
|
||||
|
@ -45,6 +46,9 @@ pub struct Options {
|
|||
pub resolvers: Vec<Resolver>,
|
||||
pub cargo_install_fallback: bool,
|
||||
|
||||
/// If provided, the names are sorted.
|
||||
pub bins: Option<Vec<CompactString>>,
|
||||
|
||||
pub temp_dir: PathBuf,
|
||||
pub install_path: PathBuf,
|
||||
pub cargo_root: Option<PathBuf>,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::{borrow::Cow, env, ffi::OsStr, fmt, iter, path::Path, sync::Arc};
|
||||
|
||||
use binstalk_bins::BinFile;
|
||||
use command_group::AsyncCommandGroup;
|
||||
use compact_str::{CompactString, ToCompactString};
|
||||
use either::Either;
|
||||
|
@ -87,14 +88,27 @@ impl ResolutionFetch {
|
|||
current_version: self.new_version,
|
||||
source: self.source,
|
||||
target: self.fetcher.target().to_compact_string(),
|
||||
bins: self
|
||||
.bin_files
|
||||
.into_iter()
|
||||
.map(|bin| bin.base_name)
|
||||
.collect(),
|
||||
bins: Self::resolve_bins(&opts.bins, self.bin_files),
|
||||
})
|
||||
}
|
||||
|
||||
fn resolve_bins(
|
||||
user_specified_bins: &Option<Vec<CompactString>>,
|
||||
crate_bin_files: Vec<BinFile>,
|
||||
) -> Vec<CompactString> {
|
||||
// We need to filter crate_bin_files by user_specified_bins in case the prebuilt doesn't
|
||||
// have featured-gated (optional) binary (gated behind feature).
|
||||
crate_bin_files
|
||||
.into_iter()
|
||||
.map(|bin| bin.base_name)
|
||||
.filter(|bin_name| {
|
||||
user_specified_bins
|
||||
.as_ref()
|
||||
.map_or(true, |bins| bins.binary_search(bin_name).is_ok())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn print(&self, opts: &Options) {
|
||||
let fetcher = &self.fetcher;
|
||||
let bin_files = &self.bin_files;
|
||||
|
@ -185,6 +199,12 @@ impl ResolutionSource {
|
|||
cmd.arg("--no-track");
|
||||
}
|
||||
|
||||
if let Some(bins) = &opts.bins {
|
||||
for bin in bins {
|
||||
cmd.arg("--bin").arg(bin);
|
||||
}
|
||||
}
|
||||
|
||||
debug!("Running `{}`", format_cmd(&cmd));
|
||||
|
||||
if !opts.dry_run {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue