Skip to main content

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::common::CommonProfile;
7use crate::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    #[serde(default, skip_serializing_if = "Option::is_none")]
16    pub pdb: Option<PathBuf>,
17}
18
19impl Artifact for HypestvOutput {}
20
21flowey_request! {
22    pub struct Request {
23        pub target: CommonTriple,
24        pub profile: CommonProfile,
25        pub hypestv: WriteVar<HypestvOutput>,
26    }
27}
28
29new_simple_flow_node!(struct Node);
30
31impl SimpleFlowNode for Node {
32    type Request = Request;
33
34    fn imports(ctx: &mut ImportCtx<'_>) {
35        ctx.import::<crate::run_cargo_build::Node>();
36        ctx.import::<flowey_lib_common::install_dist_pkg::Node>();
37    }
38
39    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
40        let Request {
41            target,
42            profile,
43            hypestv,
44        } = request;
45        let output = ctx.reqv(|v| crate::run_cargo_build::Request {
46            crate_name: "hypestv".into(),
47            out_name: "hypestv".into(),
48            crate_type: flowey_lib_common::run_cargo_build::CargoCrateType::Bin,
49            profile: profile.into(),
50            features: Default::default(),
51            target: target.as_triple(),
52            no_split_dbg_info: false,
53            extra_env: None,
54            pre_build_deps: Vec::new(),
55            output: v,
56        });
57
58        ctx.emit_minor_rust_step("report built hypestv", |ctx| {
59            let hypestv = hypestv.claim(ctx);
60            let output = output.claim(ctx);
61            move |rt| {
62                let output = match rt.read(output) {
63                    crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
64                        HypestvOutput { exe, pdb }
65                    }
66                    _ => unreachable!(),
67                };
68
69                rt.write(hypestv, &output);
70            }
71        });
72
73        Ok(())
74    }
75}