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

cli: Expose module_raw_lines to the CLI. #1936

Merged
merged 1 commit into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib.rs
Expand Up @@ -494,6 +494,14 @@ impl Builder {
output_vector.push(line.clone());
}

for (module, lines) in &self.options.module_lines {
for line in lines.iter() {
output_vector.push("--module-raw-line".into());
output_vector.push(module.clone());
output_vector.push(line.clone());
}
}

if self.options.use_core {
output_vector.push("--use-core".into());
}
Expand Down
14 changes: 14 additions & 0 deletions src/options.rs
Expand Up @@ -338,6 +338,13 @@ where
.takes_value(true)
.multiple(true)
.number_of_values(1),
Arg::with_name("module-raw-line")
.long("module-raw-line")
.help("Add a raw line of Rust code to a given module.")
.takes_value(true)
.multiple(true)
.number_of_values(2)
.value_names(&["module-name", "raw-line"]),
Arg::with_name("rust-target")
.long("rust-target")
.help(&rust_target_help)
Expand Down Expand Up @@ -769,6 +776,13 @@ where
}
}

if let Some(mut values) = matches.values_of("module-raw-line") {
while let Some(module) = values.next() {
let line = values.next().unwrap();
builder = builder.module_raw_line(module, line);
}
}

if matches.is_present("use-core") {
builder = builder.use_core();
}
Expand Down
1 change: 1 addition & 0 deletions tests/expectations/tests/namespace.rs
Expand Up @@ -16,6 +16,7 @@ pub mod root {
pub mod whatever {
#[allow(unused_imports)]
use self::super::super::root;
pub type whatever_other_thing_t = whatever_int_t;
pub type whatever_int_t = ::std::os::raw::c_int;
extern "C" {
#[link_name = "\u{1}_ZN8whatever11in_whateverEv"]
Expand Down
2 changes: 1 addition & 1 deletion tests/headers/namespace.hpp
@@ -1,4 +1,4 @@
// bindgen-flags: --enable-cxx-namespaces
// bindgen-flags: --enable-cxx-namespaces --module-raw-line root::whatever 'pub type whatever_other_thing_t = whatever_int_t;'

void top_level();

Expand Down