flowey_lib_hvlite/_jobs/
local_custom_vmfirmwareigvm_dll.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use crate::run_cargo_build::common::CommonArch;
5use flowey::node::prelude::*;
6
7flowey_request! {
8    pub struct Params {
9        pub igvm_payload: PathBuf,
10        pub arch: CommonArch,
11
12        pub artifact_dir: ReadVar<PathBuf>,
13        pub done: WriteVar<SideEffect>,
14    }
15}
16
17new_simple_flow_node!(struct Node);
18
19impl SimpleFlowNode for Node {
20    type Request = Params;
21
22    fn imports(ctx: &mut ImportCtx<'_>) {
23        ctx.import::<crate::build_vmfirmwareigvm_dll::Node>();
24    }
25
26    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
27        let Params {
28            arch,
29            igvm_payload,
30
31            artifact_dir,
32            done,
33        } = request;
34
35        let built_dll = ctx.reqv(|v| crate::build_vmfirmwareigvm_dll::Request {
36            arch,
37            igvm: ReadVar::from_static(crate::run_igvmfilegen::IgvmOutput {
38                igvm_bin: igvm_payload,
39                igvm_map: None,
40                igvm_tdx_json: None,
41                igvm_snp_json: None,
42                igvm_vbs_json: None,
43            }),
44            // fixed version to signal that this is a custom dll
45            dll_version: ReadVar::from_static((1, 0, 1337, 0)),
46            internal_dll_name: "vmfirmwareigvm.dll".into(),
47            vmfirmwareigvm_dll: v,
48        });
49
50        ctx.emit_rust_step("copy resulting vmfirmwareigvm.dll", |ctx| {
51            done.claim(ctx);
52            let artifact_dir = artifact_dir.claim(ctx);
53            let built_dll = built_dll.claim(ctx);
54            |rt| {
55                let artifact_dir = rt.read(artifact_dir);
56                let built_dll = rt.read(built_dll);
57
58                fs_err::copy(built_dll.dll, artifact_dir.join("vmfirmwareigvm.dll"))?;
59
60                for e in fs_err::read_dir(artifact_dir)? {
61                    let e = e?;
62                    log::info!("{}", e.path().display());
63                }
64                Ok(())
65            }
66        });
67
68        Ok(())
69    }
70}