flowey_lib_common/
install_cargo_nextest.rs1use flowey::node::prelude::*;
7
8flowey_request! {
9 pub struct Request(pub WriteVar<SideEffect>);
10}
11
12new_flow_node!(struct Node);
13
14impl FlowNode for Node {
15 type Request = Request;
16
17 fn imports(ctx: &mut ImportCtx<'_>) {
18 ctx.import::<crate::install_rust::Node>();
19 ctx.import::<crate::download_cargo_nextest::Node>();
20 }
21
22 fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
23 let mut done = Vec::new();
24
25 for req in requests {
26 done.push(req.0);
27 }
28
29 let done = done;
30
31 if done.is_empty() {
34 return Ok(());
35 }
36
37 let cargo_nextest_bin = ctx.platform().binary("cargo-nextest");
38
39 let nextest_path = ctx.reqv(|v| {
40 crate::download_cargo_nextest::Request::Get(target_lexicon::Triple::host(), v)
41 });
42 let cargo_home = ctx.reqv(crate::install_rust::Request::GetCargoHome);
43 let rust_installed = ctx.reqv(crate::install_rust::Request::EnsureInstalled);
44
45 ctx.emit_rust_step("installing cargo-nextest", |ctx| {
46 let nextest_path = nextest_path.claim(ctx);
47 let cargo_home = cargo_home.claim(ctx);
48 rust_installed.claim(ctx);
49 done.claim(ctx);
50
51 move |rt| {
52 let nextest_path = rt.read(nextest_path);
53 let cargo_home = rt.read(cargo_home);
54
55 fs_err::copy(
58 &nextest_path,
59 cargo_home.join("bin").join(&cargo_nextest_bin),
60 )?;
61
62 Ok(())
63 }
64 });
65
66 Ok(())
67 }
68}