diff --git a/examples/simple_counter/.cargo/config.toml b/examples/simple_counter/.cargo/config.toml index 4dd630322..f96e108b0 100644 --- a/examples/simple_counter/.cargo/config.toml +++ b/examples/simple_counter/.cargo/config.toml @@ -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" diff --git a/examples/simple_counter/Android/shared/build.gradle b/examples/simple_counter/Android/shared/build.gradle index 6bb902a49..071dfaeeb 100644 --- a/examples/simple_counter/Android/shared/build.gradle +++ b/examples/simple_counter/Android/shared/build.gradle @@ -102,8 +102,8 @@ tasks.register('bindGen', Exec) { tasks.register('typesGen', Exec) { workingDir "../../" if (System.getProperty('os.name').toLowerCase().contains('windows')) { - commandLine("cmd", "/c", "cargo test -p shared --features typegen") + commandLine("cmd", "/c", "cargo run --bin generate-types --features typegen") } else { - commandLine("sh", "-c", "cargo test -p shared --features typegen") + commandLine("sh", "-c", "cargo run --bin generate-types --features typegen") } } diff --git a/examples/simple_counter/Cargo.lock b/examples/simple_counter/Cargo.lock index 3e678b37b..b49cf653f 100644 --- a/examples/simple_counter/Cargo.lock +++ b/examples/simple_counter/Cargo.lock @@ -2830,7 +2830,6 @@ dependencies = [ name = "shared" version = "0.1.0" dependencies = [ - "anyhow", "crux_core", "lazy_static", "serde", diff --git a/examples/simple_counter/shared/Cargo.toml b/examples/simple_counter/shared/Cargo.toml index 5094207c5..25576ad26 100644 --- a/examples/simple_counter/shared/Cargo.toml +++ b/examples/simple_counter/shared/Cargo.toml @@ -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"] @@ -20,6 +24,3 @@ wasm-bindgen = "0.2.92" [target.uniffi-bindgen.dependencies] uniffi = { workspace = true, features = ["cli"] } - -[dev-dependencies] -anyhow.workspace = true diff --git a/examples/simple_counter/shared/tests/typegen.rs b/examples/simple_counter/shared/src/bin/generate-types.rs similarity index 74% rename from examples/simple_counter/shared/tests/typegen.rs rename to examples/simple_counter/shared/src/bin/generate-types.rs index 251451129..ff233eec2 100644 --- a/examples/simple_counter/shared/tests/typegen.rs +++ b/examples/simple_counter/shared/src/bin/generate-types.rs @@ -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::()?; - let output_root = PathBuf::from("./generated"); + let output_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("generated"); gen.swift("SharedTypes", output_root.join("swift"))?;