flowey_lib_hvlite/
build_hypestv.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Build `hypestv` binaries
5
6use crate::run_cargo_build::common::CommonProfile;
7use crate::run_cargo_build::common::CommonTriple;
8use flowey::node::prelude::*;
9
10#[derive(Serialize, Deserialize)]
11pub struct HypestvOutput {
12    #[serde(rename = "hypestv.exe")]
13    pub exe: PathBuf,
14    #[serde(rename = "hypestv.pdb")]
15    pub pdb: PathBuf,
16}
17
18impl Artifact for HypestvOutput {}
19
20flowey_request! {
21    pub struct Request {
22        pub target: CommonTriple,
23        pub profile: CommonProfile,
24        pub hypestv: WriteVar<HypestvOutput>,
25    }
26}
27
28new_simple_flow_node!(struct Node);
29
30impl SimpleFlowNode for Node {
31    type Request = Request;
32
33    fn imports(ctx: &mut ImportCtx<'_>) {
34        ctx.import::<crate::run_cargo_build::Node>();
35        ctx.import::<flowey_lib_common::install_dist_pkg::Node>();
36    }
37
38    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
39        let Request {
40            target,
41            profile,
42            hypestv,
43        } = request;
44        let output = ctx.reqv(|v| crate::run_cargo_build::Request {
45            crate_name: "hypestv".into(),
46            out_name: "hypestv".into(),
47            crate_type: flowey_lib_common::run_cargo_build::CargoCrateType::Bin,
48            profile: profile.into(),
49            features: [].into(),
50            target: target.as_triple(),
51            no_split_dbg_info: false,
52            extra_env: None,
53            pre_build_deps: Vec::new(),
54            output: v,
55        });
56
57        ctx.emit_minor_rust_step("report built hypestv", |ctx| {
58            let hypestv = hypestv.claim(ctx);
59            let output = output.claim(ctx);
60            move |rt| {
61                let output = match rt.read(output) {
62                    crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
63                        HypestvOutput { exe, pdb }
64                    }
65                    _ => unreachable!(),
66                };
67
68                rt.write(hypestv, &output);
69            }
70        });
71
72        Ok(())
73    }
74}