Skip to main content

flowey_lib_hvlite/_jobs/
local_custom_vmfirmwareigvm_dll.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use crate::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_bin: ReadVar::from_static(igvm_payload),
38            // fixed version to signal that this is a custom dll
39            dll_version: ReadVar::from_static((1, 0, 1337, 0)),
40            internal_dll_name: "vmfirmwareigvm.dll".into(),
41            vmfirmwareigvm_dll: v,
42        });
43
44        ctx.emit_rust_step("copy resulting vmfirmwareigvm.dll", |ctx| {
45            done.claim(ctx);
46            let artifact_dir = artifact_dir.claim(ctx);
47            let built_dll = built_dll.claim(ctx);
48            |rt| {
49                let artifact_dir = rt.read(artifact_dir);
50                let built_dll = rt.read(built_dll);
51
52                fs_err::copy(built_dll.dll, artifact_dir.join("vmfirmwareigvm.dll"))?;
53
54                for e in fs_err::read_dir(artifact_dir)? {
55                    let e = e?;
56                    log::info!("{}", e.path().display());
57                }
58                Ok(())
59            }
60        });
61
62        Ok(())
63    }
64}