Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple .rsh file support #70

Open
canewsin opened this issue Feb 23, 2022 · 0 comments
Open

Multiple .rsh file support #70

canewsin opened this issue Feb 23, 2022 · 0 comments

Comments

@canewsin
Copy link

canewsin commented Feb 23, 2022

Screenshot 2022-02-23 215433

build.rs

fn main() {
    let dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
    let bind_path = dir.join("bindings");
    let bindings = [
        bind_path.join("cryptography.rsh"),
        bind_path.join("discovery.rsh"),
        bind_path.join("protocol.rsh"),
    ];

    for path in bindings.iter() {
        let path_str = path.as_path().to_str().unwrap();
        let name = path
            .file_name()
            .unwrap()
            .to_str()
            .unwrap()
            .replacen(".rsh", "", 1);
        print!("{path_str}");
        println!("cargo:rerun-if-changed={}", path_str);
        let ffigen = FfiGen::new(&path).unwrap();
        let dart = dir
            .join("bindings")
            .join("dart")
            .join(format!("bindings_{name}.g.dart"));
        ffigen.generate_dart(dart, "zn", "zn_ffi").unwrap();
    }
}

Error Log on

cargo build

error: symbol `allocate` is already defined
 --> src\discovery\mod.rs:7:1
  |
7 | ffi_gen_macro::ffi_gen!("bindings/discovery.rsh");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `ffi_gen_macro::ffi_gen_native_64` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `zn_ffi` (lib) generated 6 warnings
error: could not compile `zn_ffi` due to previous error; 6 warnings emitted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant