microsoft/openvmm

Public

mirrored fromhttps://github.com/microsoft/openvmmAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
16fae73c998d0e83402a585b541eb78f9fcb53fa

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

flowey/flowey_lib_common/src/cfg_persistent_dir_cargo_install.rs

40lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! A node which returns a PathBuf to a single shared persistent-dir that can be
5//! used by any nodes invoking `cargo install` in order to share a single cargo
6//! build cache.
7
8use flowey::node::prelude::*;
9
10flowey_request! {
11 pub struct Request(pub WriteVar<Option<PathBuf>>);
12}
13
14new_flow_node!(struct Node);
15
16impl FlowNode for Node {
17 type Request = Request;
18
19 fn imports(_ctx: &mut ImportCtx<'_>) {}
20
21 fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
22 let persistent_dir = ctx.persistent_dir();
23 ctx.emit_rust_step("report cargo install persistent dir", |ctx| {
24 let persistent_dir = persistent_dir.claim(ctx);
25 let requests = requests
26 .into_iter()
27 .map(|x| x.0.claim(ctx))
28 .collect::<Vec<_>>();
29 |rt| {
30 let persistent_dir = persistent_dir.map(|x| rt.read(x));
31 for var in requests {
32 rt.write(var, &persistent_dir)
33 }
34 Ok(())
35 }
36 });
37
38 Ok(())
39 }
40}
41