flowey_hvlite/pipelines_shared/
ado_flowey_bootstrap_template.rs1use flowey::node::prelude::AdoResourcesRepositoryId;
7use flowey::pipeline::prelude::FlowArch;
8use flowey::pipeline::prelude::FlowPlatform;
9
10const COMMON_TEMPLATE: &str = include_str!("ado_flowey_bootstrap_template.yml");
11const LINUX_TEMPLATE: &str = include_str!("ado_flowey_bootstrap_template_linux.yml");
12const WINDOWS_TEMPLATE: &str = include_str!("ado_flowey_bootstrap_template_windows.yml");
13
14pub fn get_template_for_platform(
22 platform: FlowPlatform,
23 arch: FlowArch,
24 ado_hvlite_repo_resource_id: &AdoResourcesRepositoryId,
25) -> anyhow::Result<String> {
26 let installer = match (platform, arch) {
27 (FlowPlatform::Windows, FlowArch::X86_64) => windows_template("x86_64", "X64"),
28 (FlowPlatform::Windows, FlowArch::Aarch64) => windows_template("aarch64", "ARM64"),
29 (FlowPlatform::Linux(_), FlowArch::X86_64 | FlowArch::Aarch64) => LINUX_TEMPLATE.into(),
30 (platform, arch) => {
31 anyhow::bail!("unsupported bootstrap platform {platform} / arch {arch}")
32 }
33 };
34
35 Ok(with_repo_and_toolchain(
36 format!("{installer}\n{COMMON_TEMPLATE}"),
37 ado_hvlite_repo_resource_id,
38 ))
39}
40
41fn windows_template(host_arch: &str, runner_arch: &str) -> String {
42 WINDOWS_TEMPLATE
43 .replace("{{RUSTUP_HOST_ARCH}}", host_arch)
44 .replace("{{RUNNER_ARCH}}", runner_arch)
45}
46
47fn with_repo_and_toolchain(
48 template: String,
49 ado_hvlite_repo_resource_id: &AdoResourcesRepositoryId,
50) -> String {
51 template
54 .replace(
57 "{{FLOWEY_ADO_REPO_ID}}",
58 ado_hvlite_repo_resource_id.dangerous_get_raw_id(),
59 )
60 .replace(
61 "{{RUSTUP_TOOLCHAIN}}",
62 flowey_lib_hvlite::cfg_rustup_version::RUSTUP_TOOLCHAIN,
63 )
64}