Skip to content

Commit

Permalink
flutter: check if dart is installed
Browse files Browse the repository at this point in the history
Ref fzyzcjy/flutter_rust_bridge#2411

Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 19, 2024
1 parent 5745d76 commit 0de58f4
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions bindings/nostr-sdk-flutter/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,33 @@ use lib_flutter_rust_bridge_codegen::codegen::Config;
fn main() {
println!("cargo:rerun-if-changed=src/api");

if is_flutter_installed() {
// Execute code generator with auto-detected config
codegen::generate(
Config::from_config_file("../flutter_rust_bridge.yaml")
.unwrap()
.unwrap(),
Default::default(),
)
.unwrap();
} else {
if !is_dart_installed() {
eprintln!("Warning: dart not installed.");
return;
}

if !is_flutter_installed() {
eprintln!("Warning: flutter not installed.");
return;
}

// Execute code generator with auto-detected config
codegen::generate(
Config::from_config_file("../flutter_rust_bridge.yaml")
.unwrap()
.unwrap(),
Default::default(),
)
.unwrap();
}

fn is_dart_installed() -> bool {
let output = Command::new("dart")
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();
matches!(output, Ok(status) if status.success())
}

fn is_flutter_installed() -> bool {
Expand Down

0 comments on commit 0de58f4

Please sign in to comment.