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

Refactor uniffi structure #205

Merged
merged 1 commit into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

version: 2.1

commands:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should allow CI to run properly with the current bindgen version.

make_install_uniffi_bindgen:
steps:
- run:
name: Build and install uniffi-bindgen
command: cargo install --path uniffi_bindgen
jobs:
Check Rust formatting:
docker:
Expand All @@ -19,6 +25,7 @@ jobs:
steps:
- checkout
- run: rustup component add clippy
- make_install_uniffi_bindgen
- run: cargo clippy --version
- run: cargo clippy --all --all-targets
Rust and Foreign Language tests:
Expand All @@ -28,6 +35,7 @@ jobs:
steps:
- run: cat ~/.profile >> $BASH_ENV
- checkout
- make_install_uniffi_bindgen
- run: cargo test

workflows:
Expand All @@ -40,4 +48,4 @@ workflows:
- Lint Rust with clippy
run-tests:
jobs:
- Rust and Foreign Language tests
- Rust and Foreign Language tests
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[workspace]
members = [
"uniffi",
"uniffi_bindgen",
"uniffi_build",
"uniffi_macros",
"uniffi",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the risk of veering into bikeshed territory, I would be tempted to name this "uniffi_runtime" or similar to give a more direct indication that it contains the run-time support infra. We don't need to change it though, just sharing my reaction to the names here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually named it uniffi_runtime first, then I figured it would be sad if we didn't have any uniffi crate at all 😝 @tarikeshaq any opinion here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, yeah, needing uniffi crate of some sort makes sense! I guess if/when we eventually move to a macro-based approach we'll also want that in a top-level uniffi crate if possible, so I'm happy to keep it this like.

"examples/arithmetic",
"examples/geometry",
"examples/rondpoint",
Expand Down
7 changes: 2 additions & 5 deletions examples/arithmetic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ crate-type = ["cdylib"]
name = "uniffi_arithmetic"

[dependencies]
anyhow = "1.0"
log = "0.4"
ffi-support = "0.4"
uniffi = {path = "../../uniffi"}
uniffi_macros = {path = "../../uniffi_macros"}
uniffi = {path = "../../uniffi"}

[build-dependencies]
uniffi = {path = "../../uniffi"}
uniffi_build = {path = "../../uniffi_build"}
Comment on lines +14 to +17
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See how we depend on 1 crate for the bytebuffer traits/methods + tests helpers, and 1 for build time.

2 changes: 1 addition & 1 deletion examples/arithmetic/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

fn main() {
uniffi::generate_component_scaffolding("./src/arithmetic.idl").unwrap();
uniffi_build::generate_scaffolding("./src/arithmetic.idl").unwrap();
}
7 changes: 0 additions & 7 deletions examples/arithmetic/src/main.rs

This file was deleted.

9 changes: 6 additions & 3 deletions examples/arithmetic/tests/test_generated_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
uniffi_macros::build_foreign_language_testcases!(
"tests/bindings/test_arithmetic.py",
"tests/bindings/test_arithmetic.kts",
"tests/bindings/test_arithmetic.swift",
"src/arithmetic.idl",
eoger marked this conversation as resolved.
Show resolved Hide resolved
[
"tests/bindings/test_arithmetic.py",
"tests/bindings/test_arithmetic.kts",
"tests/bindings/test_arithmetic.swift",
]
);
7 changes: 2 additions & 5 deletions examples/geometry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ crate-type = ["cdylib"]
name = "uniffi_geometry"

[dependencies]
anyhow = "1.0"
log = "0.4"
ffi-support = "0.4"
uniffi = {path = "../../uniffi"}
uniffi_macros = {path = "../../uniffi_macros"}
uniffi = {path = "../../uniffi"}

[build-dependencies]
uniffi = {path = "../../uniffi"}
uniffi_build = {path = "../../uniffi_build"}
2 changes: 1 addition & 1 deletion examples/geometry/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

fn main() {
uniffi::generate_component_scaffolding("./src/geometry.idl").unwrap();
uniffi_build::generate_scaffolding("./src/geometry.idl").unwrap();
}
7 changes: 0 additions & 7 deletions examples/geometry/src/main.rs

This file was deleted.

9 changes: 6 additions & 3 deletions examples/geometry/tests/test_generated_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
uniffi_macros::build_foreign_language_testcases!(
"tests/bindings/test_geometry.py",
"tests/bindings/test_geometry.kts",
"tests/bindings/test_geometry.swift",
"src/geometry.idl",
[
"tests/bindings/test_geometry.py",
"tests/bindings/test_geometry.kts",
"tests/bindings/test_geometry.swift",
]
);
8 changes: 2 additions & 6 deletions examples/rondpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ crate-type = ["cdylib"]
name = "uniffi_rondpoint"

[dependencies]
anyhow = "1.0"
log = "0.4"
ffi-support = "0.4"
lazy_static = "1.4"
uniffi = {path = "../../uniffi"}
uniffi_macros = {path = "../../uniffi_macros"}
uniffi = {path = "../../uniffi"}

[build-dependencies]
uniffi = {path = "../../uniffi"}
uniffi_build = {path = "../../uniffi_build"}
2 changes: 1 addition & 1 deletion examples/rondpoint/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

fn main() {
uniffi::generate_component_scaffolding("./src/rondpoint.idl").unwrap();
uniffi_build::generate_scaffolding("./src/rondpoint.idl").unwrap();
}
7 changes: 0 additions & 7 deletions examples/rondpoint/src/main.rs

This file was deleted.

9 changes: 6 additions & 3 deletions examples/rondpoint/tests/test_generated_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
uniffi_macros::build_foreign_language_testcases!(
"tests/bindings/test_rondpoint.kts",
"tests/bindings/test_rondpoint.swift",
// "tests/bindings/test_rondpoint.py"
"src/rondpoint.idl",
[
"tests/bindings/test_rondpoint.kts",
"tests/bindings/test_rondpoint.swift",
// "tests/bindings/test_rondpoint.py",
]
);
8 changes: 2 additions & 6 deletions examples/sprites/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ crate-type = ["cdylib"]
name = "uniffi_sprites"

[dependencies]
anyhow = "1.0"
log = "0.4"
ffi-support = "0.4"
lazy_static = "1.4"
uniffi = {path = "../../uniffi"}
uniffi_macros = {path = "../../uniffi_macros"}
uniffi = {path = "../../uniffi"}

[build-dependencies]
uniffi = {path = "../../uniffi"}
uniffi_build = {path = "../../uniffi_build"}
2 changes: 1 addition & 1 deletion examples/sprites/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

fn main() {
uniffi::generate_component_scaffolding("./src/sprites.idl").unwrap();
uniffi_build::generate_scaffolding("./src/sprites.idl").unwrap();
}
7 changes: 0 additions & 7 deletions examples/sprites/src/main.rs

This file was deleted.

9 changes: 6 additions & 3 deletions examples/sprites/tests/test_generated_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
uniffi_macros::build_foreign_language_testcases!(
// "tests/bindings/test_sprites.py",
"tests/bindings/test_sprites.kts",
"tests/bindings/test_sprites.swift",
"src/sprites.idl",
[
// "tests/bindings/test_sprites.py",
"tests/bindings/test_sprites.kts",
"tests/bindings/test_sprites.swift",
]
);
8 changes: 2 additions & 6 deletions examples/todolist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ crate-type = ["cdylib"]
name = "uniffi_todolist"

[dependencies]
anyhow = "1.0"
log = "0.4"
ffi-support = "0.4"
lazy_static = "1.4"
uniffi = {path = "../../uniffi"}
uniffi_macros = {path = "../../uniffi_macros"}
uniffi = {path = "../../uniffi"}
thiserror = "1.0"

[build-dependencies]
uniffi = {path = "../../uniffi"}
uniffi_build = {path = "../../uniffi_build"}
2 changes: 1 addition & 1 deletion examples/todolist/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

fn main() {
uniffi::generate_component_scaffolding("./src/todolist.idl").unwrap();
uniffi_build::generate_scaffolding("./src/todolist.idl").unwrap();
}
7 changes: 0 additions & 7 deletions examples/todolist/src/main.rs

This file was deleted.

9 changes: 6 additions & 3 deletions examples/todolist/tests/test_generated_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
uniffi_macros::build_foreign_language_testcases!(
"tests/bindings/test_todolist.kts",
"tests/bindings/test_todolist.swift",
// "tests/bindings/test_todolist.py"
"src/todolist.idl",
[
"tests/bindings/test_todolist.kts",
"tests/bindings/test_todolist.swift",
// "tests/bindings/test_todolist.py"
]
);
18 changes: 5 additions & 13 deletions uniffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
license = "MPL-2.0"
edition = "2018"

[[bin]]
name = "uniffi-bindgen"
path = "src/main.rs"

[dependencies]
weedle = "0.11"
# Re-exported dependencies used in generated Rust scaffolding files.
anyhow = "1"
bytes = "0.5"
ffi-support = "0.4"
anyhow = "1.0"
askama = "0.9"
heck = "0.3"
clap = "2.33"
object = "0.20"
serde = "1.0"
bincode = "1.3"
cargo_metadata = "0.10.0"
lazy_static = "1.4"
log = "0.4"
# Regular dependencies
cargo_metadata = "0.11"
Loading