microsoft/openvmm
Publicmirrored fromhttps://github.com/microsoft/openvmmAvailable
flowey/flowey_hvlite/src/pipelines/restore_packages.rs
68lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | use crate::pipelines_shared::cfg_common_params::CommonArchCli; |
| 5 | use flowey::node::prelude::ReadVar; |
| 6 | use flowey::pipeline::prelude::*; |
| 7 | |
| 8 | /// Download and restore packages needed for building the specified architectures. |
| 9 | #[derive(clap::Args)] |
| 10 | pub struct RestorePackagesCli { |
| 11 | /// Specify what architectures to restore packages for. |
| 12 | /// |
| 13 | /// If none are specified, defaults to just the current host architecture. |
| 14 | arch: Vec<CommonArchCli>, |
| 15 | } |
| 16 | |
| 17 | impl IntoPipeline for RestorePackagesCli { |
| 18 | fn into_pipeline(self, backend_hint: PipelineBackendHint) -> anyhow::Result<Pipeline> { |
| 19 | let openvmm_repo = flowey_lib_common::git_checkout::RepoSource::ExistingClone( |
| 20 | ReadVar::from_static(crate::repo_root()), |
| 21 | ); |
| 22 | |
| 23 | let mut pipeline = Pipeline::new(); |
| 24 | let mut job = pipeline |
| 25 | .new_job( |
| 26 | FlowPlatform::host(backend_hint), |
| 27 | FlowArch::host(backend_hint), |
| 28 | "restore packages", |
| 29 | ) |
| 30 | .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_versions::Request {}) |
| 31 | .dep_on( |
| 32 | |_| flowey_lib_hvlite::_jobs::cfg_hvlite_reposource::Params { |
| 33 | hvlite_repo_source: openvmm_repo, |
| 34 | }, |
| 35 | ) |
| 36 | .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_common::Params { |
| 37 | local_only: Some(flowey_lib_hvlite::_jobs::cfg_common::LocalOnlyParams { |
| 38 | interactive: true, |
| 39 | auto_install: true, |
| 40 | force_nuget_mono: false, |
| 41 | external_nuget_auth: false, |
| 42 | ignore_rust_version: true, |
| 43 | }), |
| 44 | verbose: ReadVar::from_static(true), |
| 45 | locked: false, |
| 46 | deny_warnings: false, |
| 47 | }); |
| 48 | |
| 49 | let arches = { |
| 50 | if self.arch.is_empty() { |
| 51 | vec![FlowArch::host(backend_hint).try_into()?] |
| 52 | } else { |
| 53 | self.arch |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | for arch in arches { |
| 58 | job = job.dep_on( |
| 59 | |ctx| flowey_lib_hvlite::_jobs::local_restore_packages::Request { |
| 60 | arch: arch.into(), |
| 61 | done: ctx.new_done_handle(), |
| 62 | }, |
| 63 | ); |
| 64 | } |
| 65 | job.finish(); |
| 66 | Ok(pipeline) |
| 67 | } |
| 68 | } |
| 69 | |