Skip to main content

flowey_hvlite/pipelines/
restore_packages.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use crate::pipelines_shared::cfg_common_params::CommonArchCli;
5use flowey::node::prelude::ReadVar;
6use flowey::pipeline::prelude::*;
7
8/// Download and restore packages needed for building the specified architectures.
9#[derive(clap::Args)]
10pub 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
17impl 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::Init)
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                    ignore_rust_version: true,
41                }),
42                verbose: ReadVar::from_static(true),
43                locked: false,
44                deny_warnings: false,
45                no_incremental: false,
46            });
47
48        let arches = {
49            if self.arch.is_empty() {
50                vec![FlowArch::host(backend_hint).try_into()?]
51            } else {
52                self.arch
53            }
54        };
55
56        let arches = arches.into_iter().map(|arch| arch.into()).collect();
57
58        job = job.dep_on(
59            |ctx| flowey_lib_hvlite::_jobs::local_restore_packages::Request {
60                arches,
61                done: ctx.new_done_handle(),
62            },
63        );
64        job.finish();
65        Ok(pipeline)
66    }
67}