Problem
|
fn replace_relative_path_with_absolute( |
|
cargo_toml_path: &Path, |
|
crate_name: &str, |
|
abs_path: &Path, |
|
) -> anyhow::Result<()> { |
|
let cargo_toml_content = |
|
fs::read_to_string(cargo_toml_path).context("Failed to read Cargo.toml")?; |
|
let mut cargo_toml: Value = cargo_toml_content |
|
.parse::<Value>() |
|
.context("Failed to parse Cargo.toml")?; |
|
|
|
// If the `name` under [lib] section is set, using the `name` as library name. |
|
// Otherwise, using the package name. |
|
let crate_path = cargo_toml |
|
.get_mut("dependencies") |
|
.and_then(|pkg| pkg.get_mut(crate_name)); |
|
|
|
if let Some(Value::Table(table)) = crate_path { |
|
table.insert( |
|
"path".to_string(), |
|
Value::String(abs_path.to_string_lossy().to_string()), |
|
); |
|
} |
The bindings generator takes the crate as third party from a local absolute path
So it cannot be reproduced in other device by default
Or we have to manually upload the crate to git
and import the crate from git
Details
Ideally we can copy the whole rust crate and make the flutter_rust_bridge generate the bindings from this rust crate
so we don't have to have the third party dependencies
Acceptance criteria
- the flutter bindings can be used cross the devices without worried about the path
Next steps (optional)
Problem
mopro/mopro-ffi/src/app_config/flutter.rs
Lines 165 to 187 in 20cb4b5
The bindings generator takes the crate as third party from a local absolute path
So it cannot be reproduced in other device by default
Or we have to manually upload the crate to git
and import the crate from git
Details
Ideally we can copy the whole rust crate and make the
flutter_rust_bridgegenerate the bindings from this rust crateso we don't have to have the third party dependencies
Acceptance criteria
Next steps (optional)