Skip to main content

lux_lib/config/
build.rs

1use serde::{Deserialize, Serialize};
2use strum_macros::Display;
3
4/// Configuration for the build process.
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6pub(super) struct BuildConfig {
7    /// The build profile to use when compiling packages.
8    /// Default: [`BuildProfile::Release`]
9    pub(super) profile: Option<Profile>,
10    /// Command prefix with which to wrap all build commands.
11    ///
12    /// If set, every command spawned by the build backends is invoked as
13    /// `runner + [command, arguments...]`.
14    ///
15    /// If unset, no wrapping is performed.
16    #[serde(default)]
17    pub(super) runner: Vec<String>,
18}
19
20/// The build profile to use when compiling packages.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Display)]
22#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
23#[serde(rename_all = "lowercase")]
24#[strum(serialize_all = "lowercase")]
25pub enum Profile {
26    Release,
27    Dev,
28}
29
30impl Profile {
31    /// The C compiler optimization level for this profile.
32    pub fn opt_level(self) -> u32 {
33        match self {
34            Self::Release => 3,
35            Self::Dev => 0,
36        }
37    }
38}