Skip to content

Mopro flutter bindings generator takes the rust crate from local path #647

Description

@vivianjeng

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions