flowey_lib_hvlite/
build_pipette.rs1use crate::common::CommonProfile;
7use crate::common::CommonTriple;
8use flowey::node::prelude::*;
9
10#[derive(Serialize, Deserialize)]
11#[serde(untagged)]
12pub enum PipetteOutput {
13 LinuxBin {
14 #[serde(rename = "pipette")]
15 bin: PathBuf,
16 #[serde(rename = "pipette.dbg")]
17 dbg: PathBuf,
18 },
19 WindowsBin {
20 #[serde(rename = "pipette.exe")]
21 exe: PathBuf,
22 #[serde(rename = "pipette.pdb")]
23 #[serde(default, skip_serializing_if = "Option::is_none")]
24 pdb: Option<PathBuf>,
25 },
26}
27
28impl Artifact for PipetteOutput {}
29
30flowey_request! {
31 pub struct Request {
32 pub target: CommonTriple,
33 pub profile: CommonProfile,
34 pub pipette: WriteVar<PipetteOutput>,
35 }
36}
37
38new_simple_flow_node!(struct Node);
39
40impl SimpleFlowNode for Node {
41 type Request = Request;
42
43 fn imports(ctx: &mut ImportCtx<'_>) {
44 ctx.import::<crate::run_cargo_build::Node>();
45 }
46
47 fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
48 let Request {
49 target,
50 profile,
51 pipette,
52 } = request;
53
54 let output = ctx.reqv(|v| crate::run_cargo_build::Request {
55 crate_name: "pipette".into(),
56 out_name: "pipette".into(),
57 crate_type: flowey_lib_common::run_cargo_build::CargoCrateType::Bin,
58 profile: profile.into(),
59 features: Default::default(),
60 target: target.as_triple(),
61 no_split_dbg_info: false,
62 extra_env: None,
63 pre_build_deps: Vec::new(),
64 output: v,
65 });
66
67 ctx.emit_minor_rust_step("report built pipette", |ctx| {
68 let pipette = pipette.claim(ctx);
69 let output = output.claim(ctx);
70 move |rt| {
71 let output = match rt.read(output) {
72 crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
73 PipetteOutput::WindowsBin { exe, pdb }
74 }
75 crate::run_cargo_build::CargoBuildOutput::ElfBin { bin, dbg } => {
76 PipetteOutput::LinuxBin {
77 bin,
78 dbg: dbg.unwrap(),
79 }
80 }
81 _ => unreachable!(),
82 };
83
84 rt.write(pipette, &output);
85 }
86 });
87
88 Ok(())
89 }
90}