flowey_lib_hvlite/
build_vmgstool.rs1use crate::common::CommonProfile;
7use crate::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 let ssl_pkgs = match ctx.platform() {
64 FlowPlatform::Linux(
65 FlowPlatformLinuxDistro::Fedora | FlowPlatformLinuxDistro::AzureLinux,
66 ) => vec!["openssl-devel".into(), "perl".into()],
67 _ => vec!["libssl-dev".into()],
68 };
69 pre_build_deps.push(ctx.reqv(|v| {
70 flowey_lib_common::install_dist_pkg::Request::Install {
71 package_names: ssl_pkgs,
72 done: v,
73 }
74 }));
75 }
76
77 let mut features = Vec::new();
78 if with_crypto {
79 features.push("encryption".into());
80 }
81 if with_test_helpers {
82 features.push("test_helpers".into());
83 }
84
85 let output = ctx.reqv(|v| crate::run_cargo_build::Request {
86 crate_name: "vmgstool".into(),
87 out_name: "vmgstool".into(),
88 crate_type: CargoCrateType::Bin,
89 profile: profile.into(),
90 features: CargoFeatureSet::Specific(features),
91 target: target.as_triple(),
92 no_split_dbg_info: false,
93 extra_env: None,
94 pre_build_deps,
95 output: v,
96 });
97
98 ctx.emit_minor_rust_step("report built vmgstool", |ctx| {
99 let vmgstool = vmgstool.claim(ctx);
100 let output = output.claim(ctx);
101 move |rt| {
102 let output = match rt.read(output) {
103 crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
104 VmgstoolOutput::WindowsBin { exe, pdb }
105 }
106 crate::run_cargo_build::CargoBuildOutput::ElfBin { bin, dbg } => {
107 VmgstoolOutput::LinuxBin {
108 bin,
109 dbg: dbg.unwrap(),
110 }
111 }
112 _ => unreachable!(),
113 };
114
115 rt.write(vmgstool, &output);
116 }
117 });
118
119 Ok(())
120 }
121}