update flutter_rust_bridge to latest

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-01-19 21:21:28 +08:00
parent b7844d1175
commit ee0e84be37
10 changed files with 122 additions and 103 deletions

View File

@@ -85,26 +85,35 @@ fn install_oboe() {
#[cfg(feature = "flutter")]
fn gen_flutter_rust_bridge() {
use lib_flutter_rust_bridge_codegen::{
config_parse, frb_codegen, get_symbols_if_no_duplicates, RawOpts,
};
let llvm_path = match std::env::var("LLVM_HOME") {
Ok(path) => Some(vec![path]),
Err(_) => None,
};
// Tell Cargo that if the given file changes, to rerun this build script.
println!("cargo:rerun-if-changed=src/flutter_ffi.rs");
// settings for fbr_codegen
let opts = lib_flutter_rust_bridge_codegen::Opts {
// Options for frb_codegen
let raw_opts = RawOpts {
// Path of input Rust code
rust_input: "src/flutter_ffi.rs".to_string(),
rust_input: vec!["src/flutter_ffi.rs".to_string()],
// Path of output generated Dart code
dart_output: "flutter/lib/generated_bridge.dart".to_string(),
dart_output: vec!["flutter/lib/generated_bridge.dart".to_string()],
// Path of output generated C header
c_output: Some(vec!["flutter/macos/Runner/bridge_generated.h".to_string()]),
// for other options lets use default
/// Path to the installed LLVM
llvm_path,
// for other options use defaults
..Default::default()
};
// run fbr_codegen
lib_flutter_rust_bridge_codegen::frb_codegen(opts).unwrap();
// get opts from raw opts
let configs = config_parse(raw_opts);
// generation of rust api for ffi
let all_symbols = get_symbols_if_no_duplicates(&configs).unwrap();
for config in configs.iter() {
frb_codegen(config, &all_symbols).unwrap();
}
}
fn main() {