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