Skip to content

Commit

Permalink
Adding support for external fixture/example tests
Browse files Browse the repository at this point in the history
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 #1183.
  • Loading branch information
bendk committed Apr 4, 2022
1 parent f9bd97a commit d6e92d3
Show file tree
Hide file tree
Showing 17 changed files with 287 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"uniffi_bindgen",
"uniffi_build",
"uniffi_macros",
"uniffi_testing",
"uniffi",
"examples/arithmetic",
"examples/callbacks",
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "custom-types"
name = "uniffi-example-custom-types"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand Down
2 changes: 1 addition & 1 deletion fixtures/callbacks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "callbacks"
name = "uniffi-fixture-callbacks"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion fixtures/coverall/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "coverall"
name = "uniffi-fixture-coverall"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion fixtures/ext-types/guid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ext-types-guid"
name = "uniffi-fixture-ext-types-guid"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand Down
17 changes: 13 additions & 4 deletions fixtures/ext-types/lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
[package]
name = "ext-types-lib"
name = "uniffi-fixture-ext-types"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
license = "MPL-2.0"
publish = false

[package.metadata.uniffi.testing]
external-crates = [
"uniffi-fixture-ext-types-guid",
"uniffi-fixture-ext-types-lib-one",
"uniffi-example-custom-types",
]

[lib]
crate-type = ["cdylib"]
name = "uniffi_ext_types_lib"
Expand All @@ -16,13 +23,15 @@ bytes = "1.0"
uniffi_macros = {path = "../../../uniffi_macros"}
uniffi = {path = "../../../uniffi", features=["builtin-bindgen"]}

uniffi-one = {path = "../uniffi-one"}
ext-types-guid = {path = "../guid"}
uniffi-fixture-ext-types-lib-one = {path = "../uniffi-one"}
uniffi-fixture-ext-types-guid = {path = "../guid"}

# Reuse one of our examples.
custom-types = {path = "../../../examples/custom-types"}
uniffi-example-custom-types = {path = "../../../examples/custom-types"}

url = "2.2"

[build-dependencies]
uniffi_build = {path = "../../../uniffi_build", features=["builtin-bindgen"]}


3 changes: 2 additions & 1 deletion fixtures/ext-types/uniffi-one/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
# TODO: modify the crate name to test non-default names.
name = "uniffi-one"
name = "uniffi-fixture-ext-types-lib-one"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand All @@ -9,6 +9,7 @@ publish = false

[lib]
crate-type = ["cdylib", "lib"]
name = "uniffi_one"

[dependencies]
anyhow = "1"
Expand Down
2 changes: 1 addition & 1 deletion fixtures/external-types/lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "external_types_lib"
name = "uniffi-fixture-external-types"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand Down
4 changes: 2 additions & 2 deletions fixtures/reexport-scaffolding-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ name = "reexport_scaffolding_macro"
crate-type = ["cdylib"]

[dependencies]
callbacks = { path = "../callbacks" }
coverall = { path = "../coverall" }
uniffi-fixture-callbacks = { path = "../callbacks" }
uniffi-fixture-coverall = { path = "../coverall" }
uniffi = { path = "../../uniffi", features=["builtin-bindgen"] }

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "cdylib-dependency"
name = "uniffi-fixture-regression-cdylib-dependency"
version = "0.17.0"
authors = ["king6cong <king6cong@gmail.com>"]
edition = "2018"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ffi-crate"
name = "uniffi-fixture-regression-cdylib-dependency-ffi-crate"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand All @@ -13,7 +13,7 @@ name = "uniffi_empty"
[dependencies]
uniffi_macros = {path = "../../../../uniffi_macros"}
uniffi = {path = "../../../../uniffi", features=["builtin-bindgen"]}
cdylib-dependency = {path = "../cdylib-dependency"}
uniffi-fixture-regression-cdylib-dependency = {path = "../cdylib-dependency"}

[build-dependencies]
uniffi_build = {path = "../../../../uniffi_build", features=["builtin-bindgen"]}
2 changes: 1 addition & 1 deletion fixtures/regressions/enum-without-i32-helpers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "i356-enum-without-int-helpers"
name = "uniffi-fixture-regression-i356-enum-without-int-helpers"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand Down
2 changes: 1 addition & 1 deletion fixtures/regressions/fully-qualified-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "i1015-fully-qualified-types"
name = "uniffi-fixture-regression-i1015-fully-qualified-types"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "kotlin-experimental-unsigned-types"
name = "uniffi-fixture-regression-kotlin-experimental-unsigned-types"
edition = "2018"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
Expand Down
2 changes: 1 addition & 1 deletion fixtures/swift-omit-labels/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "omit_argument_labels"
name = "uniffi-fixture-swift-omit-argument-labels"
version = "0.17.0"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
edition = "2018"
Expand Down
11 changes: 11 additions & 0 deletions uniffi_testing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "uniffi_testing"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1"
cargo_metadata = "0.13"
lazy_static = "1.4"
serde = "1"
serde_json = "1"
Loading

0 comments on commit d6e92d3

Please sign in to comment.