Skip to content

Commit b806a9f

Browse files
committed
Use System type WIP
1 parent 78c67e2 commit b806a9f

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

src/attribute_set.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
use {super::*, std::collections};
22

3-
#[derive(Debug, Copy, Clone)]
4-
pub(crate) enum InvertedStatus {
5-
Normal,
6-
Inverted,
7-
}
8-
93
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
104
pub(crate) struct AttributeSet<'src>(BTreeSet<Attribute<'src>>);
115

@@ -18,23 +12,14 @@ impl<'src> AttributeSet<'src> {
1812
self.0.iter().any(|attr| attr.discriminant() == target)
1913
}
2014

21-
pub(crate) fn contains_invertible(
22-
&self,
23-
target: AttributeDiscriminant,
24-
) -> Option<InvertedStatus> {
15+
pub(crate) fn contains_invertible(&self, target: AttributeDiscriminant) -> Option<bool> {
2516
self.get(target).and_then(|attr| {
2617
Some(match attr {
2718
Attribute::Linux { enabled }
2819
| Attribute::Macos { enabled }
2920
| Attribute::Openbsd { enabled }
3021
| Attribute::Unix { enabled }
31-
| Attribute::Windows { enabled } => {
32-
if *enabled {
33-
InvertedStatus::Normal
34-
} else {
35-
InvertedStatus::Inverted
36-
}
37-
}
22+
| Attribute::Windows { enabled } => enabled,
3823
_ => panic!("contains_invertible called with non-invertible attribute"),
3924
})
4025
})

src/recipe.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,38 @@ fn error_from_signal(recipe: &str, line_number: Option<usize>, exit_status: Exit
1616
}
1717
}
1818

19+
#[derive(Debug, Clone, Copy)]
20+
enum System {
21+
Windows,
22+
MacOS,
23+
Linux,
24+
OpenBSD,
25+
Unix,
26+
}
27+
28+
impl System {
29+
fn current() -> &'static [System] {
30+
use System::*;
31+
if cfg!(target_os = "linux") {
32+
return &[Linux, Unix];
33+
}
34+
if cfg!(target_os = "openbsd") {
35+
&[OpenBSD, Unix];
36+
}
37+
if cfg!(target_os = "macos") {
38+
&[MacOS, Unix];
39+
}
40+
if cfg!(target_os = "windows") || cfg!(windows) {
41+
return &[Windows];
42+
}
43+
if cfg!(unix) {
44+
return &[Unix];
45+
}
46+
47+
&[]
48+
}
49+
}
50+
1951
/// A recipe, e.g. `foo: bar baz`
2052
#[derive(PartialEq, Debug, Clone, Serialize)]
2153
pub(crate) struct Recipe<'src, D = Dependency<'src>> {
@@ -116,8 +148,6 @@ impl<'src, D> Recipe<'src, D> {
116148
}
117149

118150
pub(crate) fn enabled(&self) -> bool {
119-
use attribute_set::InvertedStatus;
120-
121151
struct Systems {
122152
linux: bool,
123153
macos: bool,
@@ -149,6 +179,9 @@ impl<'src, D> Recipe<'src, D> {
149179
return true;
150180
}
151181

182+
let current = System::current();
183+
184+
/*
152185
let systems = Systems {
153186
linux: matches!(linux, Some(InvertedStatus::Normal)),
154187
macos: matches!(macos, Some(InvertedStatus::Normal)),
@@ -190,6 +223,7 @@ impl<'src, D> Recipe<'src, D> {
190223
if cfg!(unix) {
191224
return !(disabled.unix) && (systems.unix || !systems.windows);
192225
}
226+
*/
193227
false
194228
}
195229

0 commit comments

Comments
 (0)