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

Consolidate examples READMEs #264

Merged
merged 1 commit into from Sep 8, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions examples/README.md
Expand Up @@ -15,3 +15,40 @@ Newcomers are recommended to explore them in the following order:
* [`./todolist`](./todolist/) Simple todolist that only adds items and shows the last item, meant to show how interacting with strings works.
* [`./fxa-client`](./fxa-client/) doesn't work yet, but it contains aspirational example of what the IDL
might look like for an actual real-world component.

Each example has the following structure:

* `src/<namespace>.idl`, the component interface definition which defines the main object and its methods. This is processed by functions in `build.rs`
to generate Rust scaffolding for the component.
* `src/lib.rs`, the core implementation of the component in Rust. This basically
pulls in the generated Rust scaffolding via `include!()` and fills in function implementations.
* `src/main.rs` generates a helper executable that can be used for working with
foreign language bindings, while guaranteeing that those bindings use the same version of `uniffi`
as the compiled component.
* Some small test scripts that double as API examples in each target foreign language:
* Kotlin `tests/bindings/test_<namespace>.kts`
* Swift `tests/bindings/test_<namespace>.swift`
* Python `tests/bindings/test_<namespace>.py`

If you want to try them out, you will need:

* The [Kotlin command-line tools](https://kotlinlang.org/docs/tutorials/command-line.html), particularly `kotlinc`.
* The [Java Native Access](https://github.com/java-native-access/jna#download) JAR downloaded and its path
added to your `$CLASSPATH` environment variable.
* Python 3
* The [Swift command-line tools](https://swift.org/download/), particularly `swift`, `swiftc` and
the `Foundation` package.

With that in place, try the following:

* Run `cargo build`. That compiles the component implementation into a native library named `uniffi_<namespace>`
in `target/debug/`.
* Run `cargo run -- generate`. That generates component bindings for each target language:
* `target/debug/uniffi/<namespace>/<namespace>.kt` for Kotlin
* `target/debug/<namespace>.swift` for Swift
* `target/debug/<namespace>.py` for Python
* Run `cargo test`. This exercises the foreign language bindings via the scripts in `tests/bindings/`.
* Run `cargo run -- exec tests/bindings/test_<namespace>.kts`. This will directly execute the Kotlin
test script. Try the same for the other languages.
* Run `cargo. run -- exec -l python` to get a Python shell in which you can import the generated
module for yourself and play around with it. Try `import <namespace>` and go from there!
42 changes: 0 additions & 42 deletions examples/geometry/README.md

This file was deleted.

35 changes: 0 additions & 35 deletions examples/rondpoint/README.md
@@ -1,38 +1,3 @@
# Example uniffi component: "Rondpoint"

This example is to exercise complex data types through roundtripping.

* [`./src/rondpoint.idl`](./src/rondpoint.idl), the component interface definition which defines the main object and its methods. This is processed by functions in [`./build.rs`](./build.rs)
to generate Rust scaffolding for the component.
* [`./src/lib.rs`](./src/lib.rs), the core implementation of the component in Rust. This basically
pulls in the generated Rust scaffolding via `include!()` and fills in function implementations.
* [`./src/main.rs`](./src/main.rs) generates a helper executable that can be used for working with
foreign language bindings, while guaranteeing that those bindings use the same version of `uniffi`
as the compiled component.
* Some small test scripts that double as API examples in each target foreign language:
* Kotlin [`./tests/bindings/test_rondpoint.kts`](./tests/bindings/test_rondpoint.kts)
* Swift [`./tests/bindings/test_rondpoint.swift`](./tests/bindings/test_rondpoint.swift)
* Python [`./tests/bindings/test_rondpoint.py`](./tests/bindings/test_rondpoint.py)

If you want to try it out, you will need:

* The [Kotlin command-line tools](https://kotlinlang.org/docs/tutorials/command-line.html), particularly `kotlinc`.
* The [Java Native Access](https://github.com/java-native-access/jna#download) JAR downloaded and its path
added to your `$CLASSPATH` environment variable.
* Python 3
* The [Swift command-line tools](https://swift.org/download/), particularly `swift`, `swiftc` and
the `Foundation` package.

With that in place, try the following:

* Run `cargo build`. That compiles the component implementation into a native library named `uniffi_rondpoint`
in `../../target/debug/`.
* Run `cargo run -- generate`. That generates component bindings for each target language:
* `../../target/debug/rondpoint.kt` for Kotlin
* `../../target/debug/rondpoint.swift` for Swift
* `../../target/debug/rondpoint.py` for Python
* Run `cargo test`. This exercises the foreign language bindings via the scripts in `./tests/bindings/`.
* Run `cargo run -- exec tests/bindings/test_rondpoint.kts`. This will directly execute the Kotlin
test script. Try the same for the other languages.
* Run `cargo. run -- exec -l python` to get a Python shell in which you can import the generated
module for yourself and play around with it. Try `import rondpoint` and go from there!
41 changes: 0 additions & 41 deletions examples/sprites/README.md

This file was deleted.

38 changes: 0 additions & 38 deletions examples/todolist/README.md

This file was deleted.