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