flowey_lib_hvlite/
build_tmk_vmm.rs1use crate::run_cargo_build::common::CommonProfile;
7use crate::run_cargo_build::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 pdb: PathBuf,
19 },
20 LinuxBin {
21 #[serde(rename = "tmk_vmm")]
22 bin: PathBuf,
23 #[serde(rename = "tmk_vmm.dbg")]
24 dbg: PathBuf,
25 },
26}
27
28impl Artifact for TmkVmmOutput {}
29
30flowey_request! {
31 pub struct Request {
32 pub profile: CommonProfile,
33 pub target: CommonTriple,
34 pub unstable_whp: bool,
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 unstable_whp,
57 tmk_vmm,
58 } = r;
59 m.entry((target, profile, unstable_whp))
60 .or_default()
61 .push(tmk_vmm);
62 m
63 });
64
65 for ((target, profile, unstable_whp), tmk_vmm) in requests {
66 let features = if unstable_whp && target == CommonTriple::AARCH64_WINDOWS_MSVC {
67 ["unstable_whp".to_owned()].into()
68 } else {
69 [].into()
70 };
71
72 let output = ctx.reqv(|v| crate::run_cargo_build::Request {
73 crate_name: "tmk_vmm".into(),
74 out_name: "tmk_vmm".into(),
75 crate_type: flowey_lib_common::run_cargo_build::CargoCrateType::Bin,
76 profile: profile.into(),
77 features,
78 target: target.as_triple(),
79 no_split_dbg_info: false,
80 extra_env: None,
81 pre_build_deps: Vec::new(),
82 output: v,
83 });
84
85 ctx.emit_minor_rust_step("report built tmk_vmm", |ctx| {
86 let tmk_vmm = tmk_vmm.claim(ctx);
87 let output = output.claim(ctx);
88 move |rt| {
89 let output = match rt.read(output) {
90 crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
91 TmkVmmOutput::WindowsBin { exe, pdb }
92 }
93 crate::run_cargo_build::CargoBuildOutput::ElfBin { bin, dbg } => {
94 TmkVmmOutput::LinuxBin {
95 bin,
96 dbg: dbg.unwrap(),
97 }
98 }
99 _ => unreachable!(),
100 };
101
102 for var in tmk_vmm {
103 rt.write(var, &output);
104 }
105 }
106 });
107 }
108
109 Ok(())
110 }
111}