diff --git a/README.md b/README.md
index 4992661c44..2cc9a0ed65 100644
--- a/README.md
+++ b/README.md
@@ -2114,6 +2114,7 @@ change their behavior.
| `[doc(DOC)]`1.27.0 | module, recipe | Set recipe or module's [documentation comment](#documentation-comments) to `DOC`. |
| `[extension(EXT)]`1.32.0 | recipe | Set shebang recipe script's file extension to `EXT`. `EXT` should include a period if one is desired. |
| `[group(NAME)]`1.27.0 | module, recipe | Put recipe or module in in [group](#groups) `NAME`. |
+| `[android]`1.43.0 | recipe | Enable recipe on Android. |
| `[linux]`1.8.0 | recipe | Enable recipe on Linux. |
| `[macos]`1.8.0 | recipe | Enable recipe on MacOS. |
| `[metadata(METADATA)]`1.42.0 | recipe | Attach `METADATA` to recipe. |
diff --git a/src/attribute.rs b/src/attribute.rs
index e37f1f5101..793fb9bfad 100644
--- a/src/attribute.rs
+++ b/src/attribute.rs
@@ -9,6 +9,7 @@ use super::*;
#[strum_discriminants(derive(EnumString, Ord, PartialOrd))]
#[strum_discriminants(strum(serialize_all = "kebab-case"))]
pub(crate) enum Attribute<'src> {
+ Android,
Confirm(Option>),
Default,
Doc(Option>),
@@ -35,7 +36,8 @@ impl AttributeDiscriminant {
fn argument_range(self) -> RangeInclusive {
match self {
Self::Confirm | Self::Doc => 0..=1,
- Self::Default
+ Self::Android
+ | Self::Default
| Self::ExitMessage
| Self::Linux
| Self::Macos
@@ -84,6 +86,7 @@ impl<'src> Attribute<'src> {
}
Ok(match discriminant {
+ AttributeDiscriminant::Android => Self::Android,
AttributeDiscriminant::Confirm => Self::Confirm(arguments.into_iter().next()),
AttributeDiscriminant::Default => Self::Default,
AttributeDiscriminant::Doc => Self::Doc(arguments.into_iter().next()),
@@ -133,7 +136,8 @@ impl Display for Attribute<'_> {
write!(f, "{}", self.name())?;
match self {
- Self::Confirm(None)
+ Self::Android
+ | Self::Confirm(None)
| Self::Default
| Self::Doc(None)
| Self::ExitMessage
diff --git a/src/recipe.rs b/src/recipe.rs
index 11b8f2edac..a3f03b7636 100644
--- a/src/recipe.rs
+++ b/src/recipe.rs
@@ -134,13 +134,15 @@ impl<'src, D> Recipe<'src, D> {
}
pub(crate) fn enabled(&self) -> bool {
+ let android = self.attributes.contains(AttributeDiscriminant::Android);
let linux = self.attributes.contains(AttributeDiscriminant::Linux);
let macos = self.attributes.contains(AttributeDiscriminant::Macos);
let openbsd = self.attributes.contains(AttributeDiscriminant::Openbsd);
let unix = self.attributes.contains(AttributeDiscriminant::Unix);
let windows = self.attributes.contains(AttributeDiscriminant::Windows);
- (!windows && !linux && !macos && !openbsd && !unix)
+ (!windows && !android && !linux && !macos && !openbsd && !unix)
+ || (cfg!(target_os = "android") && (android || unix))
|| (cfg!(target_os = "linux") && (linux || unix))
|| (cfg!(target_os = "macos") && (macos || unix))
|| (cfg!(target_os = "openbsd") && (openbsd || unix))
diff --git a/tests/attributes.rs b/tests/attributes.rs
index f109bc58f6..388a0dc07a 100644
--- a/tests/attributes.rs
+++ b/tests/attributes.rs
@@ -8,6 +8,7 @@ fn all() {
[macos]
[linux]
[openbsd]
+ [android]
[unix]
[windows]
[no-exit-message]
@@ -49,7 +50,7 @@ fn multiple_attributes_one_line() {
Test::new()
.justfile(
"
- [macos,windows,linux,openbsd]
+ [macos,windows,linux,openbsd,android]
[no-exit-message]
foo:
exit 1
@@ -65,7 +66,7 @@ fn multiple_attributes_one_line_error_message() {
Test::new()
.justfile(
"
- [macos,windows linux,openbsd]
+ [macos,windows linux,openbsd,android]
[no-exit-message]
foo:
exit 1
@@ -76,7 +77,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,android]
│ ^^^^^
",
)
@@ -89,7 +90,7 @@ fn multiple_attributes_one_line_duplicate_check() {
Test::new()
.justfile(
"
- [macos, windows, linux, openbsd]
+ [macos, windows, linux, openbsd, android]
[linux]
foo:
exit 1
diff --git a/tests/os_attributes.rs b/tests/os_attributes.rs
index de74058043..9e5ea80ce0 100644
--- a/tests/os_attributes.rs
+++ b/tests/os_attributes.rs
@@ -51,6 +51,10 @@ fn os() {
[openbsd]
foo:
echo bob
+
+ [android]
+ foo:
+ echo babs
",
)
.stdout(if cfg!(target_os = "macos") {
@@ -61,6 +65,8 @@ fn os() {
"quxx\n"
} else if cfg!(target_os = "openbsd") {
"bob\n"
+ } else if cfg!(target_os = "android") {
+ "babs\n"
} else {
panic!("unexpected os family")
})
@@ -72,6 +78,8 @@ fn os() {
"echo quxx\n"
} else if cfg!(target_os = "openbsd") {
"echo bob\n"
+ } else if cfg!(target_os = "android") {
+ "echo babs\n"
} else {
panic!("unexpected os family")
})
@@ -83,6 +91,7 @@ fn all() {
Test::new()
.justfile(
"
+ [android]
[linux]
[macos]
[openbsd]