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 #[serde(default, skip_serializing_if = "Option::is_none")]
26 pdb: Option<PathBuf>,
27 },
28}
29
30impl Artifact for VmgstoolOutput {}
31
32flowey_request! {
33 pub struct Request {
34 pub target: CommonTriple,
35 pub profile: CommonProfile,
36 pub with_crypto: bool,
37 pub with_test_helpers: bool,
38 pub vmgstool: WriteVar<VmgstoolOutput>,
39 }
40}
41
42new_simple_flow_node!(struct Node);
43
44impl SimpleFlowNode for Node {
45 type Request = Request;
46
47 fn imports(ctx: &mut ImportCtx<'_>) {
48 ctx.import::<crate::run_cargo_build::Node>();
49 ctx.import::<flowey_lib_common::install_dist_pkg::Node>();
50 }
51
52 fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
53 let Request {
54 target,
55 profile,
56 with_crypto,
57 with_test_helpers,
58 vmgstool,
59 } = request;
60
61 let mut pre_build_deps = Vec::new();
62
63 if with_crypto {
64 let ssl_pkgs = match ctx.platform() {
65 FlowPlatform::Linux(
66 FlowPlatformLinuxDistro::Fedora | FlowPlatformLinuxDistro::AzureLinux,
67 ) => vec!["openssl-devel".into(), "perl".into()],
68 _ => vec!["libssl-dev".into()],
69 };
70 pre_build_deps.push(ctx.reqv(|v| {
71 flowey_lib_common::install_dist_pkg::Request::Install {
72 package_names: ssl_pkgs,
73 done: v,
74 }
75 }));
76 }
77
78 let mut features = Vec::new();
79 if with_crypto {
80 features.push("encryption".into());
81 }
82 if with_test_helpers {
83 features.push("test_helpers".into());
84 }
85
86 let output = ctx.reqv(|v| crate::run_cargo_build::Request {
87 crate_name: "vmgstool".into(),
88 out_name: "vmgstool".into(),
89 crate_type: CargoCrateType::Bin,
90 profile: profile.into(),
91 features: CargoFeatureSet::Specific(features),
92 target: target.as_triple(),
93 no_split_dbg_info: false,
94 extra_env: None,
95 pre_build_deps,
96 output: v,
97 });
98
99 ctx.emit_minor_rust_step("report built vmgstool", |ctx| {
100 let vmgstool = vmgstool.claim(ctx);
101 let output = output.claim(ctx);
102 move |rt| {
103 let output = match rt.read(output) {
104 crate::run_cargo_build::CargoBuildOutput::WindowsBin { exe, pdb } => {
105 VmgstoolOutput::WindowsBin { exe, pdb }
106 }
107 crate::run_cargo_build::CargoBuildOutput::ElfBin { bin, dbg } => {
108 VmgstoolOutput::LinuxBin {
109 bin,
110 dbg: dbg.unwrap(),
111 }
112 }
113 _ => unreachable!(),
114 };
115
116 rt.write(vmgstool, &output);
117 }
118 });
119
120 Ok(())
121 }
122}