Skip to content

Commit

Permalink
feat: allow custom build to have gcc deps (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 authored Dec 29, 2024
2 parents 2eb6770 + 97627e2 commit e7d6ae9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
13 changes: 6 additions & 7 deletions src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ use itertools::Itertools;
use rayon::prelude::*;
use solvent::DepGraph;

use crate::{model::Rule, utils::ContainingPath};

use super::{
use crate::{
build::Build,
data::{load, FileTreeState},
download,
model::BlockAllow,
nested_env,
nested_env::{Env, EnvKey, IfMissing},
model::{BlockAllow, Rule},
nested_env::{self, Env, EnvKey, IfMissing},
ninja::{NinjaBuildBuilder, NinjaRule, NinjaRuleBuilder},
utils, Context, ContextBag, Dependency, Module, Task, TaskError,
utils::{self, ContainingPath},
Context, ContextBag, Dependency, Module, Task, TaskError,
};

#[derive(Deserialize, Serialize, Debug)]
Expand Down Expand Up @@ -736,6 +734,7 @@ fn configure_build(
.name("BUILD")
.description(Cow::from("BUILD ${out}"))
.command(expanded)
.deps(build.gcc_deps.as_ref())
.build()
.unwrap()
.named();
Expand Down
1 change: 1 addition & 0 deletions src/model/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ impl fmt::Display for Module {

#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct CustomBuild {
pub gcc_deps: Option<String>,
pub cmd: Vec<String>,
pub out: Option<Vec<String>>,
}
7 changes: 2 additions & 5 deletions src/model/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl PartialEq for Rule {
}
}

use crate::ninja::{NinjaRule, NinjaRuleBuilder, NinjaRuleDeps};
use crate::ninja::{NinjaRule, NinjaRuleBuilder};

use super::VarExportSpec;

Expand All @@ -77,10 +77,7 @@ impl<'a> From<&'a Rule> for crate::ninja::NinjaRuleBuilder<'a> {
.pool(rule.pool.as_deref().map(Cow::from))
.always(rule.always)
.export(&rule.export)
.deps(match &rule.gcc_deps {
None => NinjaRuleDeps::None,
Some(s) => NinjaRuleDeps::GCC(s.into()),
});
.deps(rule.gcc_deps.as_ref());

builder
}
Expand Down
13 changes: 13 additions & 0 deletions src/ninja/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ pub enum NinjaRuleDeps {
GCC(String),
}

impl<T> From<Option<T>> for NinjaRuleDeps
where
T: AsRef<str>,
{
fn from(value: Option<T>) -> Self {
if let Some(s) = value {
Self::GCC(String::from(s.as_ref()))
} else {
Self::None
}
}
}

#[derive(Builder, Clone)]
#[builder(setter(into))]
pub struct NinjaRule<'a> {
Expand Down

0 comments on commit e7d6ae9

Please sign in to comment.