Skip to content

Commit

Permalink
fix: ignore log lines in avd_list, fix docs.rs build (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir authored Oct 23, 2024
1 parent 310e23c commit c4d420f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/avd-list-log-lines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-mobile2": "patch"
---

Fix `android::emulator::avd_list` function interpreting log lines from `emulator -list-avd` as valid `Emulator`
13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ keywords = [ "cargo", "mobile", "ios", "android", "tauri" ]
categories = [ "development-tools::cargo-plugins" ]
license = "Apache-2.0 OR MIT"


[package.metadata.docs.rs]
no-default-features = true
features = ["native-tls"]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
]

[[bin]]
name = "cargo-mobile"
required-features = [ "cli" ]
Expand Down Expand Up @@ -42,7 +53,7 @@ cli = [
brainium = [ ]
rustls = [ "ureq/tls" ]
native-tls = [ "ureq/native-tls" ]
default = [ "cli", "ureq/native-tls" ]
default = [ "cli", "native-tls" ]

[dependencies]
handlebars = "6.0"
Expand Down
8 changes: 7 additions & 1 deletion src/android/emulator/avd_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn avd_list(env: &Env) -> Result<BTreeSet<Emulator>, Error> {
raw_list
.split('\n')
.filter_map(|name| {
if name.is_empty() {
if name.is_empty() || is_emulator_log_line(name) {
None
} else {
Some(Emulator::new(name.trim().into()))
Expand All @@ -31,3 +31,9 @@ pub fn avd_list(env: &Env) -> Result<BTreeSet<Emulator>, Error> {
})
.map_err(Error::ListAvdsFailed)
}

fn is_emulator_log_line(name: &str) -> bool {
["INFO |", "WARNING |", "ERROR |"]
.iter()
.any(|prefix| name.starts_with(prefix))
}

0 comments on commit c4d420f

Please sign in to comment.