1
Fork 0

Rename derive_merge macro to define_config and move Deserialize impl into it

This commit is contained in:
bjorn3 2022-03-02 18:38:40 +01:00
parent 4800c7816e
commit 88609e5126

View file

@ -362,11 +362,13 @@ impl Merge for TomlConfig {
// We are using a decl macro instead of a derive proc macro here to reduce the compile time of // We are using a decl macro instead of a derive proc macro here to reduce the compile time of
// rustbuild. // rustbuild.
macro_rules! derive_merge { macro_rules! define_config {
($(#[$attr:meta])* struct $name:ident { ($(#[$attr:meta])* struct $name:ident {
$($field:ident: $field_ty:ty,)* $($field:ident: $field_ty:ty,)*
}) => { }) => {
$(#[$attr])* $(#[$attr])*
#[derive(Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
struct $name { struct $name {
$($field: $field_ty,)* $($field: $field_ty,)*
} }
@ -383,10 +385,9 @@ macro_rules! derive_merge {
} }
} }
derive_merge! { define_config! {
/// TOML representation of various global build decisions. /// TOML representation of various global build decisions.
#[derive(Deserialize, Default)] #[derive(Default)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
struct Build { struct Build {
build: Option<String>, build: Option<String>,
host: Option<Vec<String>>, host: Option<Vec<String>>,
@ -429,10 +430,8 @@ derive_merge! {
} }
} }
derive_merge! { define_config! {
/// TOML representation of various global install decisions. /// TOML representation of various global install decisions.
#[derive(Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
struct Install { struct Install {
prefix: Option<String>, prefix: Option<String>,
sysconfdir: Option<String>, sysconfdir: Option<String>,
@ -444,10 +443,8 @@ derive_merge! {
} }
} }
derive_merge! { define_config! {
/// TOML representation of how the LLVM build is configured. /// TOML representation of how the LLVM build is configured.
#[derive(Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
struct Llvm { struct Llvm {
skip_rebuild: Option<bool>, skip_rebuild: Option<bool>,
optimize: Option<bool>, optimize: Option<bool>,
@ -479,9 +476,7 @@ derive_merge! {
} }
} }
derive_merge! { define_config! {
#[derive(Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
struct Dist { struct Dist {
sign_folder: Option<String>, sign_folder: Option<String>,
gpg_password_file: Option<String>, gpg_password_file: Option<String>,
@ -505,10 +500,8 @@ impl Default for StringOrBool {
} }
} }
derive_merge! { define_config! {
/// TOML representation of how the Rust build is configured. /// TOML representation of how the Rust build is configured.
#[derive(Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
struct Rust { struct Rust {
optimize: Option<bool>, optimize: Option<bool>,
debug: Option<bool>, debug: Option<bool>,
@ -560,10 +553,8 @@ derive_merge! {
} }
} }
derive_merge! { define_config! {
/// TOML representation of how each build target is configured. /// TOML representation of how each build target is configured.
#[derive(Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
struct TomlTarget { struct TomlTarget {
cc: Option<String>, cc: Option<String>,
cxx: Option<String>, cxx: Option<String>,