diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2018-02-14 11:07:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 11:07:28 -0800 |
commit | 8c5f862f828b1f85eb29a4159c0f9237ac473fbf (patch) | |
tree | 00a36fc52ad3712baa9af1bb874fc99b43bf8272 | |
parent | a09a8ff66eef3f53340201a79cc09cefacf6163e (diff) | |
parent | 5e49ce9060cda0f20da69af8b5ec81506455a8fc (diff) |
Merge pull request #1255 from sanmai-NL/patch-1
Check for more common C++ header file extensions
-rw-r--r-- | src/lib.rs | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -1111,6 +1111,12 @@ impl Builder { /// issues. The resulting file will be named something like `__bindgen.i` or /// `__bindgen.ii` pub fn dump_preprocessed_input(&self) -> io::Result<()> { + fn check_is_cpp(name_file: &str) -> bool { + name_file.ends_with(".hpp") || name_file.ends_with(".hxx") + || name_file.ends_with(".hh") + || name_file.ends_with(".h++") + } + let clang = clang_sys::support::Clang::find(None, &[]).ok_or_else(|| { io::Error::new(io::ErrorKind::Other, "Cannot find clang executable") })?; @@ -1120,11 +1126,13 @@ impl Builder { let mut wrapper_contents = String::new(); // Whether we are working with C or C++ inputs. - let mut is_cpp = false; + let mut is_cpp = self.options.clang_args.windows(2).any(|w| { + w[0] == "-x=c++" || w[1] == "-x=c++" || w == &["-x", "c++"] + }); // For each input header, add `#include "$header"`. for header in &self.input_headers { - is_cpp |= header.ends_with(".hpp"); + is_cpp |= check_is_cpp(header); wrapper_contents.push_str("#include \""); wrapper_contents.push_str(header); @@ -1134,7 +1142,7 @@ impl Builder { // For each input header content, add a prefix line of `#line 0 "$name"` // followed by the contents. for &(ref name, ref contents) in &self.input_header_contents { - is_cpp |= name.ends_with(".hpp"); + is_cpp |= check_is_cpp(name); wrapper_contents.push_str("#line 0 \""); wrapper_contents.push_str(name); @@ -1142,10 +1150,6 @@ impl Builder { wrapper_contents.push_str(contents); } - is_cpp |= self.options.clang_args.windows(2).any(|w| { - w[0] == "-x=c++" || w[1] == "-x=c++" || w == &["-x", "c++"] - }); - let wrapper_path = PathBuf::from(if is_cpp { "__bindgen.cpp" } else { |