Skip to content

Commit

Permalink
Optimize shared types generate
Browse files Browse the repository at this point in the history
  • Loading branch information
Binlogo committed Jul 24, 2024
1 parent 2caee21 commit 1586dfd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/simple_counter/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[alias]
uniffi-gen-swift = "run --bin uniffi-bindgen generate --library target/release/libshared.dylib --language swift --out-dir shared/generated/swift/SharedFFI"
uniffi-gen-java = "run --bin uniffi-bindgen generate --library target/release/libshared.dylib --language kotlin --out-dir shared/generated/java"
generate-types = "run --bin generate-types --features typegen"
1 change: 0 additions & 1 deletion examples/simple_counter/Cargo.lock

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

7 changes: 4 additions & 3 deletions examples/simple_counter/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ rust-version = "1.66"
crate-type = ["lib", "staticlib", "cdylib"]
name = "shared"

[[bin]]
name = "generate-types"
required-features = ["typegen"]

[features]
typegen = ["crux_core/typegen"]

Expand All @@ -20,6 +24,3 @@ wasm-bindgen = "0.2.92"

[target.uniffi-bindgen.dependencies]
uniffi = { workspace = true, features = ["cli"] }

[dev-dependencies]
anyhow.workspace = true
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use crux_core::typegen::TypeGen;
use shared::Counter;
use std::path::PathBuf;
use uniffi::deps::anyhow;

#[cfg(feature = "typegen")]
#[test]
fn typegen() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=../shared");

fn main() -> anyhow::Result<()> {
let mut gen = TypeGen::new();

gen.register_app::<Counter>()?;

let output_root = PathBuf::from("./generated");
let output_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("generated");

gen.swift("SharedTypes", output_root.join("swift"))?;

Expand Down

0 comments on commit 1586dfd

Please sign in to comment.