-
Notifications
You must be signed in to change notification settings - Fork 274
Support extracting metadata from WASM files #2640
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
base: main
Are you sure you want to change the base?
Conversation
We have a WASM example here that demonstrates WASM transformations required to implement the FFI logic of UniFFI: https://github.com/gobley/gobley/blob/536fd52d1209c1ab09da54187db2484297e071b4/tests/gradle/js-only/src/jsMain/kotlin/RustLibrary.kt |
I support the idea, but this new dependency is likely to be a problem for us - even without the new crate duplicates this introduces. I wonder if we can work out how to sanely push this out to the consumer (ie, so crates can reasonably have their own uniffi_bindgen with this capability)? |
this is somewhat similar to https://github.com/jrmuizel/uniffi-rust-parse (unpolished, helped by cursor via an unrelated proejct), which is an experiment using Rust Analyzer to create metadata and avoid using a .so - but it's a similarly shaped problem. All metadata collection should maybe be shifted? Not sure how or really what I mean though :) |
My general feeling is that external bindings might want to move away from functions like generate_bindings() that input a One advantage of that is that it's easy to alter the process. You could replace the call to Would something like that work for Gobley? |
In mozilla#2640 I speculated that maybe external bindings would want to roll their own metadata-extraction functions. I'm not sure if it'll work for that case, but it seems like a good thing in general. Making these functions `pub` is a step in that direction. I could see external bindings code try their specialized `extract_from_foo` function first, then fallback to calling `extract_from_bytes` to see if one of the standard cases works.
@bendk Thanks for the comment! For now, we only need to alter the metadata parsing logic, so a helper function similar to Speaking of customizing the entire process that extracts metadata and builds CIs, I'm investigating name obfuscation features (for Android/WASM, using |
I think that would be possible, we could add something like If you had to write and maintain your own |
It would be trivial if the code range that needs rewriting and and maintaining is confined to |
In #2640 I speculated that maybe external bindings would want to roll their own metadata-extraction functions. I'm not sure if it'll work for that case, but it seems like a good thing in general. Making these functions `pub` is a step in that direction. I could see external bindings code try their specialized `extract_from_foo` function first, then fallback to calling `extract_from_bytes` to see if one of the standard cases works.
I don't think it should be hard and I also remembered that we have a |
This is a new way for binding generators to load the CIs, Configs, metadata, etc. I'm hoping that this can replace the `generate_bindings` and `generate_external_bindings` functions, as well some other functions like `library_mode::find_components`. The goal for the new design is to let bindings generators drive the process instead of a function like `generate_external_bindings`. The advantage of this is that it's easier to customize and we don't need to keep adding new hook methods. It also feels simpler overall to me. See mozilla#2640 for a discussion of this. If we adopt this new system, then I think we can use it to remove a bunch of duplicate code. We can keep around the old functions for backwards-compatibility, but I think they can just be wrappers around `BindgenLoader`. Also, we should figure out a nice way to hook this up to the pipeline code. Made `uniffi-bindgen-swift` use the new system. This was mostly to test the code and to serve as an example, but a nice side-benefit is that `uniffi-bindgen-swift` now can handle UDL files. I also added a `uniffi-bindgen-swift` binary file to go with the `uniffi-bindgen` binary.
This is a new way for binding generators to load the CIs, Configs, metadata, etc. I'm hoping that this can replace the `generate_bindings` and `generate_external_bindings` functions, as well some other functions like `library_mode::find_components`. The goal for the new design is to let bindings generators drive the process instead of a function like `generate_external_bindings`. The advantage of this is that it's easier to customize and we don't need to keep adding new hook methods. It also feels simpler overall to me. See mozilla#2640 for a discussion of this. If we adopt this new system, then I think we can use it to remove a bunch of duplicate code. We can keep around the old functions for backwards-compatibility, but I think they can just be wrappers around `BindgenLoader`. Also, we should figure out a nice way to hook this up to the pipeline code. Made `uniffi-bindgen-swift` use the new system. This was mostly to test the code and to serve as an example, but a nice side-benefit is that `uniffi-bindgen-swift` now can handle UDL files. I also added a `uniffi-bindgen-swift` binary file to go with the `uniffi-bindgen` binary.
This is a new way for binding generators to load the CIs, Configs, metadata, etc. I'm hoping that this can replace the `generate_bindings` and `generate_external_bindings` functions, as well some other functions like `library_mode::find_components`. The goal for the new design is to let bindings generators drive the process instead of a function like `generate_external_bindings`. The advantage of this is that it's easier to customize and we don't need to keep adding new hook methods. It also feels simpler overall to me. See mozilla#2640 for a discussion of this. If we adopt this new system, then I think we can use it to remove a bunch of duplicate code. We can keep around the old functions for backwards-compatibility, but I think they can just be wrappers around `BindgenLoader`. Also, we should figure out a nice way to hook this up to the pipeline code. Made `uniffi-bindgen-swift` use the new system. This was mostly to test the code and to serve as an example, but a nice side-benefit is that `uniffi-bindgen-swift` now can handle UDL files. I also added a `uniffi-bindgen-swift` binary file to go with the `uniffi-bindgen` binary.
This is a new way for binding generators to load the CIs, Configs, metadata, etc. I'm hoping that this can replace the `generate_bindings` and `generate_external_bindings` functions, as well some other functions like `library_mode::find_components`. The goal for the new design is to let bindings generators drive the process instead of a function like `generate_external_bindings`. The advantage of this is that it's easier to customize and we don't need to keep adding new hook methods. It also feels simpler overall to me. See mozilla#2640 for a discussion of this. If we adopt this new system, then I think we can use it to remove a bunch of duplicate code. We can keep around the old functions for backwards-compatibility, but I think they can just be wrappers around `BindgenLoader`. Also, we should figure out a nice way to hook this up to the pipeline code. Made `uniffi-bindgen-swift` use the new system. This was mostly to test the code and to serve as an example, but a nice side-benefit is that `uniffi-bindgen-swift` now can handle UDL files. I also added a `uniffi-bindgen-swift` binary file to go with the `uniffi-bindgen` binary.
This is a new way for binding generators to load the CIs, Configs, metadata, etc. I'm hoping that this can replace the `generate_bindings` and `generate_external_bindings` functions, as well some other functions like `library_mode::find_components`. The goal for the new design is to let bindings generators drive the process instead of a function like `generate_external_bindings`. The advantage of this is that it's easier to customize and we don't need to keep adding new hook methods. It also feels simpler overall to me. See mozilla#2640 for a discussion of this. If we adopt this new system, then I think we can use it to remove a bunch of duplicate code. We can keep around the old functions for backwards-compatibility, but I think they can just be wrappers around `BindgenLoader`. Also, we should figure out a nice way to hook this up to the pipeline code. Made `uniffi-bindgen-swift` use the new system. This was mostly to test the code and to serve as an example, but a nice side-benefit is that `uniffi-bindgen-swift` now can handle UDL files. I also added a `uniffi-bindgen-swift` binary file to go with the `uniffi-bindgen` binary.
This is a new way for binding generators to load the CIs, Configs, metadata, etc. I'm hoping that this can replace the `generate_bindings` and `generate_external_bindings` functions, as well some other functions like `library_mode::find_components`. The goal for the new design is to let bindings generators drive the process instead of a function like `generate_external_bindings`. The advantage of this is that it's easier to customize and we don't need to keep adding new hook methods. It also feels simpler overall to me. See #2640 for a discussion of this. If we adopt this new system, then I think we can use it to remove a bunch of duplicate code. We can keep around the old functions for backwards-compatibility, but I think they can just be wrappers around `BindgenLoader`. Also, we should figure out a nice way to hook this up to the pipeline code. Made `uniffi-bindgen-swift` use the new system. This was mostly to test the code and to serve as an example, but a nice side-benefit is that `uniffi-bindgen-swift` now can handle UDL files. I also added a `uniffi-bindgen-swift` binary file to go with the `uniffi-bindgen` binary.
We're trying to add UniFFI WASM support without
wasm-bindgen
in the next version of Gobley. This PR adds support for extracting metadata from WASM files using thewalrus
crate ofwasm-bindgen
, so the next version of UniFFI can generate bindings without building other kinds of cdylib files.Tested with the following procedure:
fixtures/coverall/Cargo.toml
.diff -r out out-wasm # exit code: 0