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

[Don't merge] Seperate bindings #1205

Closed
wants to merge 11 commits into from
Closed

Conversation

bendk
Copy link
Contributor

@bendk bendk commented Apr 4, 2022

This PR is my attempt to separate the current bindings generators into their own crates (but still in the UniFFI repo).

Let's not merge this one until we figure out the issue of versioning mismatches between the bindings and scaffolding code (#1203). Having separate bindings crates will probably just make that worse.

The main reason I'm sharing this code is that I want to merge the very first commit which adds a testing framework for this. That's going to be very useful for the desktop JS bindings. The other commits can hopefully serve as a example of how that framework would be used.

For each language, I:

  • Moved code from uniffi_bindgen/src/bindings/[lang]/ to uniffi_bindgen_[lang]/src/
  • Added uniffi_bindgen_[lang]/src/lib.rs that creates the CLI by leveraging the BindingGenerator trait
  • Refactored the Config-related code in uniffi_bindgen_[lang]/src/gen_[lang]/mod.rs. Removed the old code and added a BindingGeneratorConfig impl.
  • Extracted the test-related code from uniffi_bindgen_[lang]/src/mod.rs and put it into uniffi_bindgen_[lang]/tests/fixtures.rs, then deleted the mod.rs file

bendk added 11 commits April 5, 2022 10:03
Added code to allow external bindings crates to find the UDL files and
cdylibs for examples/fixtures.  Made a new crate for this, since I
didn't want to pull in `serde` as a dependency for `uniffi`.
Eventually, this can replace `uniffi/testing.rs` and we can remove some
other dependencies from `uniffi` like `cargo_metadata`.

Standardized the crate names for fixtures/examples.  I think we're going
to need to publish these to crates.io eventually.

Added `Cargo.toml` config section that lists external clates for
`ext-types`

We copy the dylibs for external crates as well as our own.  I think this
should fix mozilla#1183.
Moved the code to it's own crate and changed it to use
the `BindingGenerator` trait.
Created new test code on Kotlin to run the unit tests using on the
`uniffi_testing` crate.  Moved tests from the examples/fixtures
directories to `uniffi_bindgen_kotlin/tests`.

Updated `uniffi_testing` to include a hash of the script path in the
`out_dir` filename. This prevents issues when we have 2 scripts running
against the same fixture like `test_coverall.kts` and
`test_coverall_handlerace.kts`.

Normalized more fixture crate names.
Moved the code to it's own crate and changed it to use
the `BindingGenerator` trait.

Removed the `exception_name()` filter, which was never used.
Created new test code on Swift to run the unit tests using on the
`uniffi_testing` crate.  Moved tests from the examples/fixtures
directories to `uniffi_bindgen_swift/tests`.

Normalized more fixture crate names.
Moved the code to it's own crate and changed it to use
the `BindingGenerator` trait.

Removed the `filters::exception_name()` and
`PythonWrapper::initialization_code()' functions, which were never used.
Created new test code on Python to run the unit tests using on the
`uniffi_testing` crate.  Moved tests from the examples/fixtures
directories to `uniffi_bindgen_python/tests`.
Moved the code to it's own crate and changed it to use
the `BindingGenerator` trait.
Created new test code on Ruby to run the unit tests using on the
`uniffi_testing` crate.  Moved tests from the examples/fixtures
directories to `uniffi_bindgen_ruby/tests`.

Removed the last bits of the old testing code.
Documented the separate bindings changes.

Added some backwards compatibility to `uniffi-bindgen generate`.  It now
tries to run the binary from the external bindings crate using the same
flags passed to it.
@bendk
Copy link
Contributor Author

bendk commented Apr 26, 2022

This one can't land until we figure out the versioning issue (#1203). I don't think that's going to be any time soon, so let's close this one.

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

Successfully merging this pull request may close these issues.

1 participant