aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/macro.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-11-11 17:15:08 -0700
committerMelody Horn <melody@boringcactus.com>2024-11-11 17:15:08 -0700
commit4f9299b4639802e05e1cb27d8eb40305ff8e110e (patch)
tree0da5529c68c82e97aed67d842e50f6285e79e6c2 /src/makefile/macro.rs
parentfbbcf325b8bbe72f924da6a7cdb128d973ef0026 (diff)
downloadmakers-4f9299b4639802e05e1cb27d8eb40305ff8e110e.tar.gz
makers-4f9299b4639802e05e1cb27d8eb40305ff8e110e.zip
implement rule-specific macros for targets
Diffstat (limited to 'src/makefile/macro.rs')
-rw-r--r--src/makefile/macro.rs32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/makefile/macro.rs b/src/makefile/macro.rs
index b2a1510..3b472a3 100644
--- a/src/makefile/macro.rs
+++ b/src/makefile/macro.rs
@@ -14,7 +14,7 @@ use super::{ItemSource, TokenString};
#[cfg(feature = "full")]
use eyre::Result;
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Macro {
pub source: ItemSource,
pub text: TokenString,
@@ -23,7 +23,7 @@ pub struct Macro {
}
#[cfg(feature = "full")]
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ExportConfig {
Only(HashSet<String>),
AllBut(HashSet<String>),
@@ -73,7 +73,7 @@ impl ExportConfig {
}
}
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Set {
pub data: HashMap<String, Macro>,
#[cfg(feature = "full")]
@@ -128,13 +128,9 @@ impl Set {
self.data.insert(name, r#macro);
}
- pub fn extend(
- &mut self,
- other: HashMap<String, Macro>,
- #[cfg(feature = "full")] other_exports: ExportConfig,
- ) {
+ pub fn extend(&mut self, other: Self) {
#[cfg(feature = "full")]
- match (&mut self.exported, other_exports) {
+ match (&mut self.exported, other.exported) {
(ExportConfig::Only(se), ExportConfig::Only(oe)) => {
se.extend(oe);
}
@@ -142,13 +138,25 @@ impl Set {
sne.extend(one);
}
(ExportConfig::Only(se), ExportConfig::AllBut(one)) => {
- se.extend(other.keys().filter(|name| !one.contains(*name)).cloned());
+ se.extend(
+ other
+ .data
+ .keys()
+ .filter(|name| !one.contains(*name))
+ .cloned(),
+ );
}
(ExportConfig::AllBut(sne), ExportConfig::Only(oe)) => {
- sne.extend(other.keys().filter(|name| !oe.contains(*name)).cloned());
+ sne.extend(
+ other
+ .data
+ .keys()
+ .filter(|name| !oe.contains(*name))
+ .cloned(),
+ );
}
}
- self.data.extend(other);
+ self.data.extend(other.data);
}
#[cfg(feature = "full")]