pub fn install(
    ctx: &BuildCtx,
    name: Result<Spec, PathBuf>,
    targets: &[&str],
    backend: &Backend,
    force: bool,
) -> Res<String> {
    let f = |cache: &Cache, mut retriever: Retriever, solve| -> Res<String> {
        let sources = retriever
            .retrieve_packages(&solve)
            .context(format_err!("package retrieval failed"))?;

        // We drop the Retriever because we want to release our lock on the Indices as soon as we
        // can to avoid stopping other instances of elba from downloading and resolving (even
        // though we don't even need the Retriever anymore).
        drop(retriever);

        let mut contents = String::new();
        let mut manifest = fs::File::open(sources[NodeIndex::new(0)].path().join("elba.toml"))
            .context(format_err!("failed to read maifest file (elba.toml)"))?;
        manifest.read_to_string(&mut contents)?;
        let manifest = Manifest::from_str(&contents)?;

        // By default, we build all bin targets.
        let mut root = vec![];
        let emp = targets.is_empty();
        for (ix, bt) in manifest.targets.bin.iter().enumerate() {
            if emp || targets.contains(&bt.name.as_str()) {
                root.push(Target::Bin(ix));
            }
        }
        let root = Targets::new(root);

        let bctx = BuildContext {
            backend,
            compiler: Compiler::default(),
            config: BuildConfig {},
            cache,
            threads: ctx.threads,
        };

        ctx.shell.println_empty(Verbosity::Normal);
        ctx.shell.println(
            style("[2/3]").dim().bold(),
            "Building targets...",
            Verbosity::Quiet,
        );

        // We unconditionally use a global OutputLayout to force rebuilding of root packages
        // and to avoid dealing with making our own for global/remote packages

        let q = JobQueue::new(sources, &root, None, &bctx, &ctx.logger, ctx.shell)?;
        // Because we're just building, we don't need to do anything after executing the build
        // process. Yay abstraction!
        let bins = q.exec(&bctx)?.1;
        let binc = bins.len();

        ctx.shell.println_empty(Verbosity::Normal);
        ctx.shell.println(
            style("[3/3]").dim().bold(),
            "Installing binaries...",
            Verbosity::Quiet,
        );
        cache.store_bins(&bins, force)?;

        Ok(format!(
            "{} binaries installed into {}",
            binc,
            cache.layout.bin.display()
        ))
    };

    match name {
        Ok(name) => solve_remote(ctx, name, 3, f),
        Err(path) => solve_local(ctx, &path, 3, f),
    }
}
// The name argument is a Result because we want a generic Either type, but that's not in std
// and I don't feel like making a new enum just for this
// Also the Err variant is a PathBuf because I couldn't get it to take &Path without ownership
// problems in the bin code.
The name argument is a Result because we want a generic Either type, but that's not in std
and I don't feel like making a new enum just for this
Also the Err variant is a PathBuf because I couldn't get it to take &Path without ownership
problems in the bin code.
The name argument is a Result because we want a generic Either type but that ' s not in std and I don ' t feel like making a new enum just for this Also the Err variant is a PathBuf because I couldn ' t get it to take &Path without ownership problems in the bin code .
pub fn install(
    ctx: &BuildCtx,
    name: Result<Spec, PathBuf>,
    targets: &[&str],
    backend: &Backend,
    force: bool,
) -> Res<String> {
    let f = |cache: &Cache, mut retriever: Retriever, solve| -> Res<String> {
        let sources = retriever
            .retrieve_packages(&solve)
            .context(format_err!("package retrieval failed"))?;
        // We drop the Retriever because we want to release our lock on the Indices as soon as we
        // can to avoid stopping other instances of elba from downloading and resolving (even
        // though we don't even need the Retriever anymore).
        drop(retriever);
        let mut contents = String::new();
        let mut manifest = fs::File::open(sources[NodeIndex::new(0)].path().join("elba.toml"))
            .context(format_err!("failed to read maifest file (elba.toml)"))?;
        manifest.read_to_string(&mut contents)?;
        let manifest = Manifest::from_str(&contents)?;
        // By default, we build all bin targets.
        let mut root = vec![];
        let emp = targets.is_empty();
        for (ix, bt) in manifest.targets.bin.iter().enumerate() {
            if emp || targets.contains(&bt.name.as_str()) {
                root.push(Target::Bin(ix));
            }
        }
        let root = Targets::new(root);
        let bctx = BuildContext {
            backend,
            compiler: Compiler::default(),
            config: BuildConfig {},
            cache,
            threads: ctx.threads,
        };
        ctx.shell.println_empty(Verbosity::Normal);
        ctx.shell.println(
            style("[2/3]").dim().bold(),
            "Building targets...",
            Verbosity::Quiet,
        );
        // We unconditionally use a global OutputLayout to force rebuilding of root packages
        // and to avoid dealing with making our own for global/remote packages
        let q = JobQueue::new(sources, &root, None, &bctx, &ctx.logger, ctx.shell)?;
        // Because we're just building, we don't need to do anything after executing the build
        // process. Yay abstraction!
        let bins = q.exec(&bctx)?.1;
        let binc = bins.len();
        ctx.shell.println_empty(Verbosity::Normal);
        ctx.shell.println(
            style("[3/3]").dim().bold(),
            "Installing binaries...",
            Verbosity::Quiet,
        );
        cache.store_bins(&bins, force)?;
        Ok(format!(
            "{} binaries installed into {}",
            binc,
            cache.layout.bin.display()
        ))
    };
    match name {
        Ok(name) => solve_remote(ctx, name, 3, f),
        Err(path) => solve_local(ctx, &path, 3, f),
    }
}
pub fn install ( ctx : & BuildCtx , name : Result < Spec , PathBuf > , targets : & [ & str ] , backend : & Backend , force : bool , ) -> Res < String > { let f = | cache : & Cache , mut retriever : Retriever , solve | -> Res < String > { let sources = retriever . retrieve_packages ( & solve ) . context ( format_err ! ( " " ) ) ? ; // We drop the Retriever because we want to release our lock on the Indices as soon as we // can to avoid stopping other instances of elba from downloading and resolving (even // though we don't even need the Retriever anymore). drop ( retriever ) ; let mut contents = String :: new ( ) ; let mut manifest = fs :: File :: open ( sources [ NodeIndex :: new ( 0 ) ] . path ( ) . join ( " " ) ) . context ( format_err ! ( " " ) ) ? ; manifest . read_to_string ( & mut contents ) ? ; let manifest = Manifest :: from_str ( & contents ) ? ; // By default, we build all bin targets. let mut root = vec ! [ ] ; let emp = targets . is_empty ( ) ; for ( ix , bt ) in manifest . targets . bin . iter ( ) . enumerate ( ) { if emp || targets . contains ( & bt . name . as_str ( ) ) { root . push ( Target :: Bin ( ix ) ) ; } } let root = Targets :: new ( root ) ; let bctx = BuildContext { backend , compiler : Compiler :: default ( ) , config : BuildConfig { } , cache , threads : ctx . threads , } ; ctx . shell . println_empty ( Verbosity :: Normal ) ; ctx . shell . println ( style ( " " ) . dim ( ) . bold ( ) , " " , Verbosity :: Quiet , ) ; // We unconditionally use a global OutputLayout to force rebuilding of root packages // and to avoid dealing with making our own for global/remote packages let q = JobQueue :: new ( sources , & root , None , & bctx , & ctx . logger , ctx . shell ) ? ; // Because we're just building, we don't need to do anything after executing the build // process. Yay abstraction! let bins = q . exec ( & bctx ) ? . 1 ; let binc = bins . len ( ) ; ctx . shell . println_empty ( Verbosity :: Normal ) ; ctx . shell . println ( style ( " " ) . dim ( ) . bold ( ) , " " , Verbosity :: Quiet , ) ; cache . store_bins ( & bins , force ) ? ; Ok ( format ! ( " " binc cache layout bin display ( ) ) ) } ; match name { Ok ( name ) => solve_remote ( ctx , name , 3 , f ) , Err ( path ) => solve_local ( ctx , & path , 3 , f ) , } }
The name argument is a Result because we want a generic Either type, but that's not in std
and I don't feel like making a new enum just for this
Also the Err variant is a PathBuf because I couldn't get it to take &Path without ownership
problems in the bin code.
The name argument is a Result because we want a generic Either type but that ' s not in std and I don ' t feel like making a new enum just for this Also the Err variant is a PathBuf because I couldn ' t get it to take &Path without ownership problems in the bin code .
ctx
&BuildCtx
name
Result<Spec, PathBuf>
targets
&[&str]
backend
&Backend
force
bool