flowey_lib_hvlite/
build_vmgstool.rs1use crate::run_cargo_build::common::CommonProfile;
7use crate::run_cargo_build::common::CommonTriple;
8use flowey::node::prelude::*;
9use flowey_lib_common::run_cargo_build::CargoCrateType;
10use flowey_lib_common::run_cargo_build::CargoFeatureSet;
11
12#[derive(Serialize, Deserialize)]
13#[serde(untagged)]
14pub enum VmgstoolOutput {
15 LinuxBin {
16 #[serde(rename = "vmgstool")]
17 bin: PathBuf,
18 #[serde(rename = "vmgstool.dbg")]
19 dbg: PathBuf,
20 },
21 WindowsBin {
22 #[serde(rename = "vmgstool.exe")]
23 exe: PathBuf,
24 #[serde(rename = "vmgstool.pdb")]
25 pdb: PathBuf,
26 },
27}
28
29impl Artifact for VmgstoolOutput {}
30
31flowey_request! {
32 pub struct Request {
33 pub target: CommonTriple,
34 pub profile: CommonProfile,
35 pub with_crypto: bool,
36 pub with_test_helpers: bool,
37 pub vmgstool: WriteVar<VmgstoolOutput>,
38 }
39}
40
41new_simple_flow_node!(struct Node);
42
43impl SimpleFlowNode for Node {
44 type Request = Request;
45
46 fn imports(ctx: &mut ImportCtx<'_>) {
47 ctx.import::<crate::run_cargo_build::Node>();
48 ctx.import::<flowey_lib_common::install_dist_pkg::Node>();
49 }
50
51 fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
52 let Request {
53 target,
54 profile,
55 with_crypto,
56 with_test_helpers,
57 vmgstool,
58 } = request;
59
60 let mut pre_build_deps = Vec::new();
61
62 if with_crypto {
63 pre_build_deps.push(ctx.reqv(|v| {
64 flowey_lib_common::install_dist_pkg::Request::Install {
65 package_names: vec!["libssl-dev".into()],
66 done: v,
67 }
68 }));
69 }
70
71 let mut features = Vec::new();
72 if with_crypto {
73 match target.as_triple().operating_system {
74 target_lexicon::OperatingSystem::Windows => features.push("encryption_win".into()),
75 target_lexicon::OperatingSystem::Linux => features.push("encryption_ossl".into()),
76 _ => unreachable!(),
77 };
78 }
79 if with_test_helpers {
80 features.push("test_helpers".into());
81 }
82
83 let output = ctx.reqv(|v| crate::run_cargo_build::Request {
84 crate_name: "vmgstool".into(),
85 out_name: "vmgstool".into(),
86 crate_type: CargoCrateType::Bin,
87 profile: profile.into(),
88 features: CargoFeatureSet::Specific(features),
89 target: target.as_triple(),
90 no_split_dbg_info: false,
91 extra_env: None,
92 pre_build_deps,
93 output: v,
94 });
95
96 ctx.emit_minor_rust_step("report built vmgstool", |ctx| {
97 let vmgstool = vmgstool.claim(ctx);
98 let output = output.claim(ctx);
99 move |rt| {
100 let output = match rt.read(output) {
101 crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
102 VmgstoolOutput::WindowsBin { exe, pdb }
103 }
104 crate::run_cargo_build::CargoBuildOutput::ElfBin { bin, dbg } => {
105 VmgstoolOutput::LinuxBin {
106 bin,
107 dbg: dbg.unwrap(),
108 }
109 }
110 _ => unreachable!(),
111 };
112
113 rt.write(vmgstool, &output);
114 }
115 });
116
117 Ok(())
118 }
119}