-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.rs
33 lines (30 loc) · 1.14 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use lib_flutter_rust_bridge_codegen::{
config_parse, frb_codegen, get_symbols_if_no_duplicates, RawOpts,
};
/// Path of input Rust code
const RUST_INPUT: &str = "src/api.rs";
/// Path of output generated Dart code
const DART_OUTPUT: &str = "../lib/rust/bridge_generated.dart";
fn main() {
// Tell Cargo that if the input Rust code changes, to rerun this build script.
println!("cargo:rerun-if-changed={}", RUST_INPUT);
// Options for frb_codegen
let raw_opts = RawOpts {
// Path of input Rust code
rust_input: vec![RUST_INPUT.to_string()],
// Path of output generated Dart code
dart_output: vec![DART_OUTPUT.to_string()],
wasm: true,
dart_decl_output: Some("../lib/rust/bridge_definitions.dart".into()),
dart_format_line_length: 120,
// for other options use defaults
..Default::default()
};
// 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();
}
}