flowey_lib_hvlite/
build_vmm_perf.rs1use crate::common::CommonProfile;
7use crate::common::CommonTriple;
8use flowey::node::prelude::*;
9
10#[derive(Serialize, Deserialize)]
11#[serde(untagged)]
12pub enum VmmPerfOutput {
13 WindowsBin {
14 #[serde(rename = "vmm_perf.exe")]
15 exe: PathBuf,
16 #[serde(rename = "vmm_perf.pdb")]
17 #[serde(default, skip_serializing_if = "Option::is_none")]
18 pdb: Option<PathBuf>,
19 },
20 LinuxBin {
21 #[serde(rename = "vmm_perf")]
22 bin: PathBuf,
23 #[serde(rename = "vmm_perf.dbg")]
24 dbg: PathBuf,
25 },
26}
27
28impl Artifact for VmmPerfOutput {}
29
30flowey_request! {
31 pub struct Request {
32 pub target: CommonTriple,
33 pub profile: CommonProfile,
34 pub vmm_perf: WriteVar<VmmPerfOutput>,
35 }
36}
37
38new_flow_node!(struct Node);
39
40impl FlowNode for Node {
41 type Request = Request;
42
43 fn imports(ctx: &mut ImportCtx<'_>) {
44 ctx.import::<crate::run_cargo_build::Node>();
45 }
46
47 fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
48 for Request {
49 target,
50 profile,
51 vmm_perf,
52 } in requests
53 {
54 let output = ctx.reqv(|v| crate::run_cargo_build::Request {
55 crate_name: "vmm_perf".into(),
56 out_name: "vmm_perf".into(),
57 crate_type: flowey_lib_common::run_cargo_build::CargoCrateType::Bin,
58 profile: profile.into(),
59 features: Default::default(),
60 target: target.as_triple(),
61 no_split_dbg_info: false,
62 extra_env: None,
63 pre_build_deps: Vec::new(),
64 output: v,
65 });
66
67 ctx.emit_minor_rust_step("report built VMM.Perf runner", |ctx| {
68 let output = output.claim(ctx);
69 let vmm_perf = vmm_perf.claim(ctx);
70 move |rt| {
71 let output = match rt.read(output) {
72 crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
73 VmmPerfOutput::WindowsBin { exe, pdb }
74 }
75 crate::run_cargo_build::CargoBuildOutput::ElfBin { bin, dbg } => {
76 VmmPerfOutput::LinuxBin {
77 bin,
78 dbg: dbg.unwrap(),
79 }
80 }
81 _ => unreachable!(),
82 };
83 rt.write(vmm_perf, &output);
84 }
85 });
86 }
87
88 Ok(())
89 }
90}