aboutsummaryrefslogtreecommitdiff
path: root/release/src/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'release/src/build.rs')
-rw-r--r--release/src/build.rs45
1 files changed, 43 insertions, 2 deletions
diff --git a/release/src/build.rs b/release/src/build.rs
index adf251b4d..d1abb2aa1 100644
--- a/release/src/build.rs
+++ b/release/src/build.rs
@@ -1,5 +1,46 @@
1use anyhow::Result; 1use anyhow::Result;
2 2
3pub(crate) fn build(ctx: &crate::Context) -> Result<()> { 3use crate::cargo::{CargoArgsBuilder, CargoBatchBuilder};
4 todo!() 4
5pub(crate) fn build(ctx: &crate::Context, crate_name: Option<&str>) -> Result<()> {
6 let mut batch_builder = CargoBatchBuilder::new();
7
8 // Process either specific crate or all crates
9 let crates_to_build: Vec<_> = if let Some(name) = crate_name {
10 // Build only the specified crate
11 if let Some(krate) = ctx.crates.get(name) {
12 vec![krate]
13 } else {
14 return Err(anyhow::anyhow!("Crate '{}' not found", name));
15 }
16 } else {
17 // Build all crates
18 ctx.crates.values().collect()
19 };
20
21 // Process selected crates and add their build configurations to the batch
22 for krate in crates_to_build {
23 for config in &krate.configs {
24 let mut args_builder = CargoArgsBuilder::new()
25 .subcommand("build")
26 .arg("--release")
27 .arg(format!("--manifest-path={}/Cargo.toml", krate.path.to_string_lossy()));
28
29 if let Some(ref target) = config.target {
30 args_builder = args_builder.target(target);
31 }
32
33 if !config.features.is_empty() {
34 args_builder = args_builder.features(&config.features);
35 }
36
37 batch_builder.add_command(args_builder.build());
38 }
39 }
40
41 // Execute the cargo batch command
42 let batch_args = batch_builder.build();
43 crate::cargo::run(&batch_args, &ctx.root)?;
44
45 Ok(())
5} 46}