Skip to content

Commit

Permalink
cli: Expose module_raw_lines to the CLI.
Browse files Browse the repository at this point in the history
This makes command_line_args properly return them, instead of dropping
them on the floor.
  • Loading branch information
emilio committed Dec 2, 2020
1 parent 19142ac commit 460ae84
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
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

0 comments on commit 460ae84

Please sign in to comment.