Skip to content

Commit

Permalink
feat: add support for every other settings from wit-bindgen (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
sehnryr authored Apr 17, 2024
1 parent 40320a9 commit e1715b0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,21 @@ impl<'a> BindingsGenerator<'a> {
std_feature: settings.std_feature,
runtime_path: Some("wit_bindgen_rt".to_string()),
bitflags_path: Some("wit_bindgen_rt::bitflags".to_string()),
..Default::default()
raw_strings: settings.raw_strings,
skip: settings.skip.clone(),
stubs: settings.stubs,
export_prefix: settings.export_prefix.clone(),
with: settings
.with
.iter()
.map(|(key, value)| (key.clone(), value.clone()))
.collect(),
type_section_suffix: settings.type_section_suffix.clone(),
disable_run_ctors_once_workaround: settings.disable_run_ctors_once_workaround,
default_bindings_module: settings.default_bindings_module.clone(),
export_macro_name: settings.export_macro_name.clone(),
pub_export_macro: settings.pub_export_macro,
generate_unused_types: settings.generate_unused_types,
};

let mut files = Files::default();
Expand Down
43 changes: 43 additions & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@ pub struct Bindings {
/// If true, code generation should qualify any features that depend on
/// `std` with `cfg(feature = "std")`.
pub std_feature: bool,
/// If true, code generation should pass borrowed string arguments as
/// `&[u8]` instead of `&str`. Strings are still required to be valid
/// UTF-8, but this avoids the need for Rust code to do its own UTF-8
/// validation if it doesn't already have a `&str`
pub raw_strings: bool,
/// Names of functions to skip generating bindings for.
pub skip: Vec<String>,
/// If true, generate stub implementations for any exported functions,
/// interfaces, and/or resources.
pub stubs: bool,
/// Optionally prefix any export names with the specified value.
///
/// This is useful to avoid name conflicts when testing.
pub export_prefix: Option<String>,
/// Remapping of interface names to rust module names.
pub with: HashMap<String, String>,
/// Add the specified suffix to the name of the custome section containing
/// the component type.
pub type_section_suffix: Option<String>,
/// Disable a workaround used to prevent libc ctors/dtors from being invoked
/// too much.
pub disable_run_ctors_once_workaround: bool,
/// Changes the default module used in the generated `export!` macro to
/// something other than `self`.
pub default_bindings_module: Option<String>,
/// Alternative name to use for the `export!` macro if one is generated.
pub export_macro_name: Option<String>,
/// Ensures that the `export!` macro will be defined as `pub` so it is a
/// candidate for being exported outside of the crate.
pub pub_export_macro: bool,
/// Whether to generate unused structures, not generated by default (false)
pub generate_unused_types: bool,
}

impl Default for Bindings {
Expand All @@ -78,6 +110,17 @@ impl Default for Bindings {
ownership: Default::default(),
derives: Default::default(),
std_feature: false,
raw_strings: Default::default(),
skip: Default::default(),
stubs: Default::default(),
export_prefix: Default::default(),
with: Default::default(),
type_section_suffix: Default::default(),
disable_run_ctors_once_workaround: Default::default(),
default_bindings_module: Default::default(),
export_macro_name: Default::default(),
pub_export_macro: Default::default(),
generate_unused_types: Default::default(),
}
}
}
Expand Down

0 comments on commit e1715b0

Please sign in to comment.