flowey_lib_hvlite/_jobs/
local_restore_packages.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use crate::download_lxutil::LxutilArch;
use crate::download_uefi_mu_msvm::MuMsvmArch;
use crate::init_openvmm_magicpath_linux_test_kernel::OpenvmmLinuxTestKernelArch;
use crate::init_openvmm_magicpath_openhcl_sysroot::OpenvmmSysrootArch;
use crate::run_cargo_build::common::CommonArch;
use flowey::node::prelude::*;

flowey_request! {
    pub struct Request{
        pub arch: CommonArch,
        pub done: WriteVar<SideEffect>,
    }
}

new_simple_flow_node!(struct Node);

impl SimpleFlowNode for Node {
    type Request = Request;

    fn imports(ctx: &mut ImportCtx<'_>) {
        ctx.import::<crate::init_openvmm_magicpath_linux_test_kernel::Node>();
        ctx.import::<crate::init_openvmm_magicpath_lxutil::Node>();
        ctx.import::<crate::init_openvmm_magicpath_openhcl_sysroot::Node>();
        ctx.import::<crate::init_openvmm_magicpath_protoc::Node>();
        ctx.import::<crate::init_openvmm_magicpath_uefi_mu_msvm::Node>();
    }

    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
        let Request { arch, done } = request;

        let mut deps = vec![ctx.reqv(crate::init_openvmm_magicpath_protoc::Request)];

        match arch {
            CommonArch::X86_64 => {
                if matches!(ctx.platform(), FlowPlatform::Linux(_)) {
                    deps.extend_from_slice(&[ctx
                        .reqv(|v| crate::init_openvmm_magicpath_openhcl_sysroot::Request {
                            arch: OpenvmmSysrootArch::X64,
                            path: v,
                        })
                        .into_side_effect()]);
                }
                deps.extend_from_slice(&[
                    ctx.reqv(|done| crate::init_openvmm_magicpath_lxutil::Request {
                        arch: LxutilArch::X86_64,
                        done,
                    }),
                    ctx.reqv(|done| crate::init_openvmm_magicpath_uefi_mu_msvm::Request {
                        arch: MuMsvmArch::X86_64,
                        done,
                    }),
                    ctx.reqv(
                        |done| crate::init_openvmm_magicpath_linux_test_kernel::Request {
                            arch: OpenvmmLinuxTestKernelArch::X64,
                            done,
                        },
                    ),
                ]);
            }
            CommonArch::Aarch64 => {
                if matches!(ctx.platform(), FlowPlatform::Linux(_)) {
                    deps.extend_from_slice(&[ctx
                        .reqv(|v| crate::init_openvmm_magicpath_openhcl_sysroot::Request {
                            arch: OpenvmmSysrootArch::Aarch64,
                            path: v,
                        })
                        .into_side_effect()]);
                }
                deps.extend_from_slice(&[
                    ctx.reqv(|done| crate::init_openvmm_magicpath_lxutil::Request {
                        arch: LxutilArch::Aarch64,
                        done,
                    }),
                    ctx.reqv(|done| crate::init_openvmm_magicpath_uefi_mu_msvm::Request {
                        arch: MuMsvmArch::Aarch64,
                        done,
                    }),
                    ctx.reqv(
                        |done| crate::init_openvmm_magicpath_linux_test_kernel::Request {
                            arch: OpenvmmLinuxTestKernelArch::Aarch64,
                            done,
                        },
                    ),
                ]);
            }
        }

        ctx.emit_side_effect_step(deps, [done]);

        Ok(())
    }
}