flowey_lib_hvlite/
cfg_openvmm_magicpath.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! A node which returns a PathBuf to the "magic path" where OpenVMM code
5//! expects certain binary dependencies to be symlinked / extracted into.
6//!
7//! NOTE: This must remain a separate node, as out-of-tree pipelines will
8//! override this node to specify a different magicpath when building openhcl
9//! from an overlay repo!
10
11use flowey::node::prelude::*;
12
13flowey_request! {
14    pub struct Request(pub WriteVar<PathBuf>);
15}
16
17new_flow_node!(struct Node);
18
19impl FlowNode for Node {
20    type Request = Request;
21
22    fn imports(ctx: &mut ImportCtx<'_>) {
23        ctx.import::<crate::git_checkout_openvmm_repo::Node>();
24    }
25
26    fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
27        let repo_path = ctx.reqv(crate::git_checkout_openvmm_repo::req::GetRepoDir);
28
29        ctx.emit_minor_rust_step("report openvmm magicpath dir", |ctx| {
30            let repo_path = repo_path.claim(ctx);
31            let requests = requests
32                .into_iter()
33                .map(|x| x.0.claim(ctx))
34                .collect::<Vec<_>>();
35            |rt| {
36                let path = rt.read(repo_path).join(".packages");
37                rt.write_all(requests, &path);
38            }
39        });
40
41        Ok(())
42    }
43}