Skip to main content

flowey_lib_hvlite/
build_mshv_host_boot.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Build the development-only x64 mshv UEFI host boot application.
5
6use crate::common::CommonProfile;
7use flowey::node::prelude::*;
8use flowey_lib_common::run_cargo_build::CargoCrateType;
9
10#[derive(Serialize, Deserialize)]
11pub struct MshvHostBootOutput {
12    #[serde(rename = "mshv_host_boot.efi")]
13    pub efi: PathBuf,
14    #[serde(rename = "mshv_host_boot.pdb")]
15    pub pdb: PathBuf,
16}
17
18impl Artifact for MshvHostBootOutput {}
19
20flowey_request! {
21    pub struct Request {
22        pub profile: CommonProfile,
23        pub host_boot: WriteVar<MshvHostBootOutput>,
24    }
25}
26
27new_simple_flow_node!(struct Node);
28
29impl SimpleFlowNode for Node {
30    type Request = Request;
31
32    fn imports(ctx: &mut ImportCtx<'_>) {
33        ctx.import::<crate::run_cargo_build::Node>();
34    }
35
36    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
37        let Request { profile, host_boot } = request;
38        let target = "x86_64-unknown-uefi".parse()?;
39        let output = ctx.reqv(|output| crate::run_cargo_build::Request {
40            crate_name: "mshv_host_boot".into(),
41            out_name: "mshv_host_boot".into(),
42            crate_type: CargoCrateType::Bin,
43            profile: profile.into(),
44            features: Default::default(),
45            target,
46            no_split_dbg_info: false,
47            extra_env: None,
48            pre_build_deps: Vec::new(),
49            output,
50        });
51        ctx.emit_minor_rust_step("report mshv UEFI host boot application", |ctx| {
52            let output = output.claim(ctx);
53            let host_boot = host_boot.claim(ctx);
54            move |rt| {
55                let crate::run_cargo_build::CargoBuildOutput::UefiBin { efi, pdb } =
56                    rt.read(output)
57                else {
58                    unreachable!()
59                };
60                rt.write(host_boot, &MshvHostBootOutput { efi, pdb });
61            }
62        });
63        Ok(())
64    }
65}