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

To replace *.udl with use of Uniffi proc macro initially #261

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[alias]
xcode = ["bin", "cargo-xcode"]
make = ["bin", "cargo-make"]
3 changes: 0 additions & 3 deletions examples/hello_world/shared/build.rs

This file was deleted.

9 changes: 5 additions & 4 deletions examples/hello_world/shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
uniffi::setup_scaffolding!();

pub mod app; // not exposed so you can remove this in your project

use lazy_static::lazy_static;
Expand All @@ -7,24 +9,23 @@ pub use crux_core::{bridge::Bridge, Core, Request};

pub use app::*;

// TODO hide this plumbing

uniffi::include_scaffolding!("shared");

lazy_static! {
static ref CORE: Bridge<Effect, Hello> = Bridge::new(Core::new());
}

#[uniffi::export]
#[wasm_bindgen]
pub fn process_event(data: &[u8]) -> Vec<u8> {
CORE.process_event(data)
}

#[uniffi::export]
#[wasm_bindgen]
pub fn handle_response(id: u32, data: &[u8]) -> Vec<u8> {
CORE.handle_response(id, data)
}

#[uniffi::export]
#[wasm_bindgen]
pub fn view() -> Vec<u8> {
CORE.view()
Expand Down
5 changes: 0 additions & 5 deletions examples/hello_world/shared/src/shared.udl

This file was deleted.

21 changes: 8 additions & 13 deletions examples/simple_counter/Android/shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
}

sourceSets {
main.java.srcDirs += "${projectDir}/../../shared_types/generated/java"
main.java.srcDirs += "${projectDir}/../../shared/generated/java"
}
}

Expand Down Expand Up @@ -83,27 +83,22 @@ afterEvaluate {
}

tasks.register('bindGen', Exec) {
def outDir = "${projectDir}/../../shared_types/generated/java"
workingDir "../../"
def outDir = "${projectDir}/../../shared/generated/java"
workingDir "../../shared"
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine("cmd", "/c",
"cargo build -p shared && " + "target\\debug\\uniffi-bindgen generate shared\\src\\shared.udl " + "--language kotlin " + "--out-dir " + outDir.replace('/', '\\'))
"cargo make uniffi-gen-java")
} else {
commandLine("sh", "-c",
"""\
cargo build -p shared && \
target/debug/uniffi-bindgen generate shared/src/shared.udl \
--language kotlin \
--out-dir $outDir
""")
"cargo make uniffi-gen-java")
}
}

tasks.register('typesGen', Exec) {
workingDir "../../"
workingDir "../../shared"
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine("cmd", "/c", "cargo build -p shared_types")
commandLine("cmd", "/c", "cargo make generate-types")
} else {
commandLine("sh", "-c", "cargo build -p shared_types")
commandLine("sh", "-c", "cargo make generate-types")
}
}
64 changes: 17 additions & 47 deletions examples/simple_counter/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion examples/simple_counter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["shared", "shared_types", "web-dioxus", "web-leptos", "web-yew"]
members = ["shared", "web-dioxus", "web-leptos", "web-yew"]
resolver = "1"

[workspace.package]
Expand All @@ -14,6 +14,8 @@ rust-version = "1.66"
anyhow = "1.0.86"
crux_core = "0.8"
serde = "1.0.203"
uniffi = { git = "https://github.com/mozilla/uniffi-rs.git", branch = "main" }

[workspace.metadata.bin]
cargo-xcode = { version = "=1.7.0" }
cargo-make = { version = "=0.37.14" }
Loading
Loading