Граф коммитов

107 Коммитов

Автор SHA1 Сообщение Дата
Ben Dean-Kawamura f486682ffe chore: Release 2024-06-11 14:17:30 -04:00
Ben Dean-Kawamura fb752f8936 Merging the release-v0.27.x back into main 2024-06-03 12:13:49 -04:00
Ben Dean-Kawamura 051f1291c2 chore: Release 2024-06-03 10:50:43 -04:00
Ben Dean-Kawamura df87af5fcd Remove the unicode-linebreak / unicode-width dependencies
Docstrings rarely have unicode characters so these are not adding much
value.  They present an issue for the downstream moz-central crate
(https://bugzilla.mozilla.org/show_bug.cgi?id=1894888), so let's remove
them.
2024-06-03 10:24:49 -04:00
Ben Dean-Kawamura 5ef30af9fe chore: Release 2024-05-15 15:38:15 -04:00
Mark Hammond 13a1c559cb
TargetLanguage is now just a cli concept, so move it there (#2101) 2024-05-10 10:30:33 -04:00
Ben Dean-Kawamura 8a6948dcde Remove the unicode-linebreak / unicode-width dependencies
Docstrings rarely have unicode characters so these are not adding much
value.  They present an issue for the downstream moz-central crate
(https://bugzilla.mozilla.org/show_bug.cgi?id=1894888), so let's remove
them.
2024-05-06 15:39:36 +02:00
Erich Gubler a82487fada build: upgrade `heck` 0.4.1 → 0.5.0, `clap` 4.3.19 → 4.5.4 2024-05-06 11:14:54 +02:00
Mark Hammond a234cf0dda chore: Release 2024-04-03 17:38:29 -04:00
Ben Dean-Kawamura 6f1f9b71c4 chore: Release 2024-03-26 17:09:42 -04:00
Martin Geisler 075efd96ee
Make `uniffi_build` optional in `uniffi_macros` (#2019)
* Add missing derive feature to serde dependency

The code built without this, but that seems to because of an accident
since the derive feature is not a default serde feature.

I noticed this when trying to make uniffi_build an optional
dependency of uniffi_macros — for some reason I don’t understand, this
would make `cargo build -p uniffi_macros` fail wtih:

    error: cannot find derive macro `Deserialize` in this scope
      --> uniffi_macros/src/util.rs:29:14
       |
    29 |     #[derive(Deserialize)]
       |              ^^^^^^^^^^^
       |

The error makes sense since the derive feature wasn’t enabled. What
does not make sense to me is that the error wasn’t triggered before.

* Make `uniffi_build` optional in `uniffi_macros`

As far as I can see, the dependency on uniffi_build is not needed for
the macros used by regular clients of UniFFI — it is only used to
create a convenience macro for the UI tests.

I named the new feature “trybuild” after the description of the macro.
Please let me know if you have preferences for a better name.

The overall goal here is to minimize the number of crates I need to
vendor to use UniFFI — I’m hoping to get away with checking in the
generated target language sources, so I’m currently focusing on the
dependencies in the rest of the code base.
2024-03-11 09:50:36 -04:00
Ben Dean-Kawamura 4a787e594d chore: Release 2024-01-24 10:42:27 -05:00
Ben Dean-Kawamura 27fbd42daa chore: Release 2024-01-23 13:35:53 -05:00
Mike Hommey 6ca87e41cb Update goblin to 0.8 2024-01-16 12:18:51 -05:00
Ben Dean-Kawamura 803713c105 Merge changes from 'v0.25.3' 2023-12-07 14:31:04 -05:00
Ben Dean-Kawamura afb29ebdc1 Releasing 0.25.3
Added changelog entry for 0.25.3 and ran `cargo release`
2023-12-07 13:38:49 -05:00
Didier Villevalois 9f7c3c4663
add README to published crates (#1866)
Fixes #1860.
2023-11-26 22:48:25 -05:00
Kristupas Antanavicius bf9097cc2f Implement docstrings
Docstrings are declared in .udl file by prefixing a line with three
slashes ///. Docstrings can be placed basically anywhere - functions,
objects, methods, constructors, callbacks, etc.. A docstring placed in
a wrong place will generate UDL parser error.
2023-11-22 14:10:07 +01:00
Mark Hammond ad7a01f803 chore: Release 2023-11-20 10:40:29 -05:00
Ben Dean-Kawamura f7237b7721 chore: Release 2023-11-09 11:41:08 -05:00
Ben Dean-Kawamura 6a2441a5ea chore: Release 2023-10-18 13:27:07 -04:00
Jan-Erik Rediger 1eabe8645c Apply 0.24.3 bump to `main` 2023-09-07 10:45:48 +02:00
Mark Hammond cae8edc45b
Avoid using serde just for printing debug representations (#1719) 2023-08-25 13:59:53 -04:00
Mark Hammond 044b85dcdd
Split UDL parts of uniffi_bindgen into a new uniffi_udl crate. (#1629) 2023-07-03 17:55:20 -04:00
Jan-Erik Rediger 217d4ccbf5 chore: Release 2023-06-23 12:16:38 +02:00
Jan-Erik Rediger ff92540817 chore: Release 2023-06-21 12:26:39 +02:00
Jan-Erik Rediger 6e4170d4da Upgrade to Clap 4 2023-06-05 15:44:47 +02:00
Jan-Erik Rediger c2ab4c8805 Upgrade to askama v0.12 2023-06-01 14:49:47 +02:00
Ben Dean-Kawamura 68bd40fb17 Added "crate-mode" bindings generation
This leverages the new macro metadata feature to simplify bindings
generation.  The new mode is enabled by passing `--crate [main-crate]`
to the `generate` command instead of a UDL file.  UniFFI will then use
the exported metadata symbols cargo metadata to figure out what to
generate.  Bindings will be generated for main crate and all it's
UniFFIed dependencies into a single out dir.

The new system allows us to set defaults for several config values that
should work in virtually all cases.  `cydlib_name` can be calculated
from the dylib path that cargo metadata gives us.
`kotlin.external_packages` can be calculated since we're going to be
generating bindings for those external packages in the same pass.

I think this should improve use-cases like the app-services megazord,
where multiple UniFFI crates, including support crates, are compiled
into one large library.  It makes it much simpler to add new crates or
to move types into a support crate and use the external types feature:

  - No need to add a new `uniffi-bindgen` task to the build process
  - No need to add a `uniffi.toml` config just to spcify the dylib name.
  - No need to figure out the `external_packages` map for external
    packages.

Made the generate command more verbose, for example it now prints out
the files it's generating.  I found this very useful when debugging
generation issues and figured it would be nice going forward.
2023-05-26 12:27:04 -04:00
Ben Dean-Kawamura 5367a3de7b New system for interface metadata
- Added the `uniffi_core::metadata` module, which provides a system for
  building metadata buffers using const code.
- Added the `FfiConverter::TYPE_ID_META` const, which holds metadata
  to identify the type.
- Made the proc-macros generate use the new system to generate metadata
  consts, then export them using static variables.
- Removed the current code to generate/store metadata based on the syn
  parsing.
- Removed the type assertions and the requirement for a `uniffi_types`
  module.  We don't need them now that we`re getting the type ids from
  the type itself.
- Made the `FnMetadata.throws` field a Type rather than a String.
- Calculate module paths with the `module_path!()` macro.  This means we
  get accurate module paths without nightly.  Changed mod_path to be a
  String, rather than a Vec since this is what `module_path!()` outputs.
- Added code to strip the `r#` part out of raw idents before serializing
  it into the metadata.
- Replaced the `collect_params()` function with the `ScaffoldingBits`
  struct.  There was too much complexity for a single function -- for
  example unzip() only works with pairs, not 3-tuples.

In general, the new metadata system is more reliable doing everything in
the proc-macros.  Proc-macros can only see the type identifiers, but
they don't anything about the underlying type, since users can rename
types with type aliases.  It's also simpler since you don't have to walk
the AST so much.

One TODO is getting checksum working again.  One limitation of the const
code is that we can't use it to generate function identifiers.
2023-03-31 11:13:46 -04:00
Ben Dean-Kawamura d42c37628b (cargo-release) version {{version}} 2023-01-27 11:35:00 -05:00
Ben Dean-Kawamura b0aae80e36 Moved the CLI parsing code into the `uniffi` crate.
This removes the clap dependency on `uniffi_bindgen` which is nice for
consumers that want to just use the Rust API.

This completes the migration of the CLI from `uniffi_bindgen` to
`uniffi`
2023-01-12 15:16:19 -05:00
Jan-Erik Rediger 025b9a9cca chore: Release 2022-12-16 16:21:02 +01:00
Jan-Erik Rediger d93a94549e
Merge back release v0.21.1 (#1429)
* Document changed checksum mechanism for release

* (cargo-release) version 0.21.1
2022-12-16 07:50:37 -06:00
messense af7d64aee6
Make clap optional in uniffi_bindgen 2022-11-29 11:37:43 +01:00
messense e6a95eda3e
Upgrade goblin to 0.6 (#1405) 2022-11-17 16:12:46 +11:00
Ben Dean-Kawamura 8d5ff759f2 Use `uniffi_testing` for our tests
The new system has several advantages:
  - It has handling for external crates, which makes the python
    ext-types fixtures work again.
  - It uses the correct suffix for Swift modules (#1194)
  - It doesn't require the `uniffi::testing` module, which I think will
    help #1374

This means that the example/fixture crates need to take a dev-dependency
on `uniffi_bindgen`.  I also updated several to take a dev-dependency on
`uniffi_macros` instead of a regular dependency, since they only needed
it for the tests. The required change was making sure all the crates had
a `lib` crate-type.

While updating the bindings code to use `uniffi_testing`, I also moved
it into its own module.
2022-11-07 09:52:42 -05:00
Ben Dean-Kawamura 7dc595a183 (cargo-release) version 0.21.0 2022-10-14 14:04:51 -04:00
Ben Dean-Kawamura 2c92fa4845 (cargo-release) version 0.20.0 2022-09-13 10:59:22 -04:00
Jan-Erik Rediger 4f33516280
(cargo-release) version 0.19.6 (#1329) 2022-08-31 07:40:17 -05:00
Jan-Erik Rediger 4c8b35966f Remove definitely-unused dependencies 2022-08-31 10:43:18 +02:00
Tarik Eshaq 2808944a32
Merge back release 0.19.4 and 0.19.5 into main (#1319)
* Allow Rust, Python and Kotlin keywords to be used as identifier names. (#1237)

* New regression test: We missed a newline

This is already fixed in `main`, but was an issue in 0.19.1

* Include the askama config file into the build

* Adding changelog entry for the Askama fix

* Disable publish for keyword fixtures (#1289)

* (cargo-release) version 0.19.2

* Extend regression test to Swift, Kotlin & Ruby

* Don't strip newlines around function definitions

Applies to Kotlin, Ruby and Swift.
Kotlin didn't actually break.

Co-authored-by: Travis Long <tlong@mozilla.com>

* (cargo-release) version 0.19.4

* Remove the r# added in 0.19.4

* (cargo-release) version 0.19.5

Co-authored-by: Mark Hammond <mhammond@skippinet.com.au>
Co-authored-by: Jan-Erik Rediger <jrediger@mozilla.com>
Co-authored-by: Jan-Erik Rediger <janerik@fnordig.de>
Co-authored-by: Ben Dean-Kawamura <bdk@mozilla.com>
Co-authored-by: Travis Long <tlong@mozilla.com>
2022-08-29 11:08:48 -07:00
尹吉峰 dc52427124
Upgrade weedle2 to nom 7 (#1304) 2022-08-04 15:21:23 +02:00
Ben Dean-Kawamura ae00abada1 Store macro metadata in the cdylib file
The nice thing about this system is that the metadata is always bundled
together with the build output.  This makes it easier to ensure that the
generated scaffolding matches up with the dylib that it's going to be link to.
This avoids the work that `rebuild_metadata()` needed to do.  Metadata
is serialized with bincode to keep the binary size reasonable.

The downside is that we need to parse a dylib, which feels slightly
risky. However, it seems less risky overall to me, since we don't have
to worry about tracking the JSON files -- especially after fixing the
recent the sccache issue.  Also, extracting the symbol data with the
goblin crate is not that bad, see `macro_metadata/extract.rs` for how
it's done.

In order to use the macro metadata, you now need to specify `--cdylib
[path-to-library]` when running `uniffi-bindgen`.  This is annoying, but it
will be simpler once the proc-macros can handle all parts of the interface.
At that point, we can make `uniffi-bindgen` accept either a UDL path or a cdylib
path as it's positional arg.

I didn't add support for external bindings to pass in a cdylib path, since
adding an argument to that function would be a breaking change, then we would
need to do another breaking change to make the param `udl_or_cdylib_file`.  If
external bindings really want to, they can call
`uniffi_bindgen::interface::macro_metadata::add_to_ci` directly.

Added the `uniffi-bindgen dump-json` command that inputs a cdylib path and
prints the matadata as JSON.

I tested that `dump-json` works properly on the following targets:
  - x86_64-unknown-linux-gnu (ELF 64-bit)
  - i686-unknown-linux-gnu (ELF 32-bit)
  - x86_64-apple-darwin (Mach-O 64-bit)
  - x86_64-pc-windows-gnu (DLL 64-bit)
  - i686-pc-windows-gnu (DLL 32-bit)

This seems like good enough coverage to me, although there are a lot of other
systems that would be nice to test on.  The limiting factor was setting up the
cross-compilation toolchains on my machine.  Maybe we should add some more CI
platforms that just run macro-metadata-related tests.

Updated the testing code to pass the cydlib path, rather than the
directory that contains it.

Added an enum that covers all Metadata types.  This is what we serialize
in the cdylib.
2022-08-03 14:18:33 -04:00
bendk 6ce5d21925
Merge back changes from the 0.19.3 release (#1297)
* Allow Rust, Python and Kotlin keywords to be used as identifier names. (#1237)

* New regression test: We missed a newline

This is already fixed in `main`, but was an issue in 0.19.1

* Include the askama config file into the build

* Adding changelog entry for the Askama fix

* Disable publish for keyword fixtures (#1289)

* (cargo-release) version 0.19.2

* Extend regression test to Swift, Kotlin & Ruby

* Don't strip newlines around function definitions

Applies to Kotlin, Ruby and Swift.
Kotlin didn't actually break.

Co-authored-by: Travis Long <tlong@mozilla.com>

* (cargo-release) version 0.19.3

Co-authored-by: Mark Hammond <mhammond@skippinet.com.au>
Co-authored-by: Jan-Erik Rediger <jrediger@mozilla.com>
Co-authored-by: Jan-Erik Rediger <janerik@fnordig.de>
Co-authored-by: Travis Long <tlong@mozilla.com>
2022-07-08 13:32:34 -04:00
bendk a638146611
Merging changes back from the 0.19.2 release today (#1290)
* Allow Rust, Python and Kotlin keywords to be used as identifier names. (#1237)

* New regression test: We missed a newline

This is already fixed in `main`, but was an issue in 0.19.1

* Include the askama config file into the build

* Adding changelog entry for the Askama fix

* Disable publish for keyword fixtures (#1289)

* (cargo-release) version 0.19.2

Co-authored-by: Mark Hammond <mhammond@skippinet.com.au>
Co-authored-by: Jan-Erik Rediger <jrediger@mozilla.com>
Co-authored-by: Jan-Erik Rediger <janerik@fnordig.de>
2022-07-07 17:00:31 -04:00
Jonas Platte 2da9b9b49a Replace lazy_static with once_cell 2022-06-23 17:15:53 -04:00
Ben Dean-Kawamura 0b6d8c0e57 Merge branch 'release-v0.19.x' 2022-06-20 11:24:27 -04:00
Jonas Platte 6120c02849
Unpin clap
The problematic deprecation warnings are now opt-in.
2022-06-17 14:37:33 +02:00
Ben Dean-Kawamura 4296232a2f (cargo-release) version 0.19.1 2022-06-16 12:19:09 -04:00