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