Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,9 @@ change their behavior.
| `[no-exit-message]`<sup>1.7.0</sup> | recipe | Don't print an error message if recipe fails. |
| `[no-quiet]`<sup>1.23.0</sup> | recipe | Override globally quiet recipes and always echo out the recipe. |
| `[openbsd]`<sup>1.38.0</sup> | recipe | Enable recipe on OpenBSD. |
| `[freebsd]`<sup>master</sup> | recipe | Enable recipe on FreeBSD. |
| `[dragonfly]`<sup>master</sup> | recipe | Enable recipe on Dragonfly. |
| `[netbsd]`<sup>master</sup> | recipe | Enable recipe on NetBSD. |
| `[parallel]`<sup>1.42.0</sup> | recipe | Run this recipe's dependencies in parallel. |
| `[positional-arguments]`<sup>1.29.0</sup> | recipe | Turn on [positional arguments](#positional-arguments) for this recipe. |
| `[private]`<sup>1.10.0</sup> | alias, recipe | Make recipe, alias, or variable private. See [Private Recipes](#private-recipes). |
Expand Down
12 changes: 12 additions & 0 deletions src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub(crate) enum Attribute<'src> {
NoExitMessage,
NoQuiet,
Openbsd,
Freebsd,
Dragonfly,
Netbsd,
Parallel,
PositionalArguments,
Private,
Expand All @@ -54,6 +57,9 @@ impl AttributeDiscriminant {
| Self::NoExitMessage
| Self::NoQuiet
| Self::Openbsd
| Self::Freebsd
| Self::Dragonfly
| Self::Netbsd
| Self::Parallel
| Self::PositionalArguments
| Self::Private
Expand Down Expand Up @@ -195,6 +201,9 @@ impl<'src> Attribute<'src> {
AttributeDiscriminant::NoExitMessage => Self::NoExitMessage,
AttributeDiscriminant::NoQuiet => Self::NoQuiet,
AttributeDiscriminant::Openbsd => Self::Openbsd,
AttributeDiscriminant::Freebsd => Self::Freebsd,
AttributeDiscriminant::Dragonfly => Self::Dragonfly,
AttributeDiscriminant::Netbsd => Self::Netbsd,
AttributeDiscriminant::Parallel => Self::Parallel,
AttributeDiscriminant::PositionalArguments => Self::PositionalArguments,
AttributeDiscriminant::Private => Self::Private,
Expand Down Expand Up @@ -302,6 +311,9 @@ impl Display for Attribute<'_> {
| Self::NoExitMessage
| Self::NoQuiet
| Self::Openbsd
| Self::Freebsd
| Self::Dragonfly
| Self::Netbsd
| Self::Parallel
| Self::PositionalArguments
| Self::Private
Expand Down
8 changes: 7 additions & 1 deletion src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,19 @@ impl<'src, D> Recipe<'src, D> {
let linux = self.attributes.contains(AttributeDiscriminant::Linux);
let macos = self.attributes.contains(AttributeDiscriminant::Macos);
let openbsd = self.attributes.contains(AttributeDiscriminant::Openbsd);
let freebsd = self.attributes.contains(AttributeDiscriminant::Freebsd);
let dragonfly = self.attributes.contains(AttributeDiscriminant::Dragonfly);
let netbsd = self.attributes.contains(AttributeDiscriminant::Netbsd);
let unix = self.attributes.contains(AttributeDiscriminant::Unix);
let windows = self.attributes.contains(AttributeDiscriminant::Windows);

(!windows && !linux && !macos && !openbsd && !unix)
(!windows && !linux && !macos && !openbsd && !freebsd && !dragonfly && !netbsd && !unix)
|| (cfg!(target_os = "linux") && (linux || unix))
|| (cfg!(target_os = "macos") && (macos || unix))
|| (cfg!(target_os = "openbsd") && (openbsd || unix))
|| (cfg!(target_os = "freebsd") && (freebsd || unix))
|| (cfg!(target_os = "dragonfly") && (dragonfly || unix))
|| (cfg!(target_os = "netbsd") && (netbsd || unix))
|| (cfg!(target_os = "windows") && windows)
|| (cfg!(unix) && unix)
|| (cfg!(windows) && windows)
Expand Down
11 changes: 7 additions & 4 deletions tests/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ fn all() {
[macos]
[linux]
[openbsd]
[freebsd]
[dragonfly]
[netbsd]
[unix]
[windows]
[no-exit-message]
Expand Down Expand Up @@ -47,7 +50,7 @@ fn multiple_attributes_one_line() {
Test::new()
.justfile(
"
[macos,windows,linux,openbsd]
[macos,windows,linux,openbsd,freebsd,dragonfly,netbsd]
[no-exit-message]
foo:
exit 1
Expand All @@ -62,7 +65,7 @@ fn multiple_attributes_one_line_error_message() {
Test::new()
.justfile(
"
[macos,windows linux,openbsd]
[macos,windows linux,openbsd,freebsd,dragonfly,netbsd]
[no-exit-message]
foo:
exit 1
Expand All @@ -73,7 +76,7 @@ fn multiple_attributes_one_line_error_message() {
error: Expected ']', ':', ',', or '(', but found identifier
——▶ justfile:1:16
1 │ [macos,windows linux,openbsd]
1 │ [macos,windows linux,openbsd,freebsd,dragonfly,netbsd]
│ ^^^^^
",
)
Expand All @@ -85,7 +88,7 @@ fn multiple_attributes_one_line_duplicate_check() {
Test::new()
.justfile(
"
[macos, windows, linux, openbsd]
[macos, windows, linux, openbsd, freebsd, dragonfly, netbsd]
[linux]
foo:
exit 1
Expand Down
27 changes: 27 additions & 0 deletions tests/os_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ fn os() {
[openbsd]
foo:
echo bob

[freebsd]
foo:
echo corge

[dragonfly]
foo:
echo grault

[netbsd]
foo:
echo garply
",
)
.stdout(if cfg!(target_os = "macos") {
Expand All @@ -61,6 +73,12 @@ fn os() {
"quxx\n"
} else if cfg!(target_os = "openbsd") {
"bob\n"
} else if cfg!(target_os = "freebsd") {
"corge\n"
} else if cfg!(target_os = "dragonfly") {
"grault\n"
} else if cfg!(target_os = "netbsd") {
"garply\n"
} else {
panic!("unexpected os family")
})
Expand All @@ -72,6 +90,12 @@ fn os() {
"echo quxx\n"
} else if cfg!(target_os = "openbsd") {
"echo bob\n"
} else if cfg!(target_os = "freebsd") {
"echo corge\n"
} else if cfg!(target_os = "dragonfly") {
"echo grault\n"
} else if cfg!(target_os = "netbsd") {
"echo garply\n"
} else {
panic!("unexpected os family")
})
Expand All @@ -86,6 +110,9 @@ fn all() {
[linux]
[macos]
[openbsd]
[freebsd]
[dragonfly]
[netbsd]
[unix]
[windows]
foo:
Expand Down