flowey_lib_hvlite/
build_ohcldiag_dev.rs1use crate::common::CommonProfile;
7use crate::common::CommonTriple;
8use flowey::node::prelude::*;
9
10#[derive(Serialize, Deserialize)]
11#[serde(untagged)]
12pub enum OhcldiagDevOutput {
13 LinuxBin {
14 #[serde(rename = "ohcldiag-dev")]
15 bin: PathBuf,
16 #[serde(rename = "ohcldiag-dev.dbg")]
17 dbg: PathBuf,
18 },
19 WindowsBin {
20 #[serde(rename = "ohcldiag-dev.exe")]
21 exe: PathBuf,
22 #[serde(rename = "ohcldiag-dev.pdb")]
23 #[serde(default, skip_serializing_if = "Option::is_none")]
24 pdb: Option<PathBuf>,
25 },
26}
27
28impl Artifact for OhcldiagDevOutput {}
29
30flowey_request! {
31 pub struct Request {
32 pub target: CommonTriple,
33 pub profile: CommonProfile,
34 pub ohcldiag_dev: WriteVar<OhcldiagDevOutput>,
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 ctx.import::<flowey_lib_common::install_dist_pkg::Node>();
46 }
47
48 fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
49 let Request {
50 target,
51 profile,
52 ohcldiag_dev,
53 } = request;
54 let output = ctx.reqv(|v| crate::run_cargo_build::Request {
55 crate_name: "ohcldiag-dev".into(),
56 out_name: "ohcldiag-dev".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 ohcldiag_dev", |ctx| {
68 let ohcldiag_dev = ohcldiag_dev.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 OhcldiagDevOutput::WindowsBin { exe, pdb }
74 }
75 crate::run_cargo_build::CargoBuildOutput::ElfBin { bin, dbg } => {
76 OhcldiagDevOutput::LinuxBin {
77 bin,
78 dbg: dbg.unwrap(),
79 }
80 }
81 _ => unreachable!(),
82 };
83
84 rt.write(ohcldiag_dev, &output);
85 }
86 });
87
88 Ok(())
89 }
90}