bricks/config/
overrides.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Serialize, Deserialize, Clone, Default)]
6pub struct Overrides {
7    /// the command that will be used to build the library instead of `bricks build`
8    pub build: Option<String>,
9    /// the command that will be used to run the binary instead of `bricks run`
10    pub run: Option<String>,
11    /// the directory where the includes (headers) are, instead of the default <lib>/build/include
12    pub include_dir: Option<String>,
13    /// the directory where the compiled objects are, instead of the default <lib>/build/lib
14    pub lib_dir: Option<String>,
15}
16
17#[derive(Debug, Serialize, Deserialize)]
18#[serde(transparent)]
19pub struct OverrideDatabase(HashMap<String, Overrides>);
20
21impl OverrideDatabase {
22    pub fn new() -> Self {
23        Self(HashMap::new())
24    }
25
26    pub fn insert(&mut self, key: String, ov: Overrides) {
27        self.0.insert(key, ov);
28    }
29
30    pub fn get(&self, key: &str) -> Option<&Overrides> {
31        self.0.get(key)
32    }
33}
34
35impl Default for OverrideDatabase {
36    fn default() -> Self {
37        Self::new()
38    }
39}