Skip to content

Commit

Permalink
Add wasm feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jhugman committed Dec 4, 2024
1 parent 859a02f commit eb821d1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions crates/ubrn_bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = []
wasm = []

[dependencies]
anyhow = { workspace = true }
Expand Down
20 changes: 16 additions & 4 deletions crates/ubrn_bindgen/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ pub struct BindingsArgs {
pub(crate) source: SourceArgs,
#[command(flatten)]
pub(crate) output: OutputArgs,
#[cfg(feature = "wasm")]
#[command(flatten)]
pub(crate) switches: SwitchArgs,
switches: SwitchArgs,
}

impl BindingsArgs {
pub fn new(switches: SwitchArgs, source: SourceArgs, output: OutputArgs) -> Self {
pub fn new(_switches: SwitchArgs, source: SourceArgs, output: OutputArgs) -> Self {
Self {
switches,
#[cfg(feature = "wasm")]
switches: _switches,
source,
output,
}
Expand All @@ -42,6 +44,16 @@ impl BindingsArgs {
pub fn cpp_dir(&self) -> &Utf8Path {
&self.output.cpp_dir
}

#[cfg(not(feature = "wasm"))]
pub fn switches(&self) -> SwitchArgs {
Default::default()
}

#[cfg(feature = "wasm")]
pub fn switches(&self) -> SwitchArgs {
self.switches.clone()
}
}

#[derive(Args, Clone, Debug)]
Expand Down Expand Up @@ -125,7 +137,7 @@ impl BindingsArgs {
let generator = ReactNativeBindingGenerator::new(
ts_dir.clone(),
abi_dir.clone(),
self.switches.clone(),
self.switches(),
);
let dummy_dir = Utf8PathBuf::from_str(".")?;

Expand Down
4 changes: 4 additions & 0 deletions crates/ubrn_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ name = "uniffi-bindgen-react-native"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = []
wasm = []

[dependencies]
anyhow = { workspace = true }
askama = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/ubrn_cli/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub(crate) struct GenerateAllArgs {
#[clap(long)]
config: Utf8PathBuf,

#[cfg(feature = "wasm")]
#[command(flatten)]
switches: SwitchArgs,

Expand Down
2 changes: 1 addition & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ anyhow = { workspace = true }
camino = { workspace = true }
clap = { workspace = true }
pathdiff = { workspace = true }
ubrn_bindgen = { path = "../crates/ubrn_bindgen" }
ubrn_bindgen = { path = "../crates/ubrn_bindgen", features = ["wasm"] }
ubrn_common = { path = "../crates/ubrn_common" }

0 comments on commit eb821d1

Please sign in to comment.