Rust-bindgen: Is it possible to specifying include directories (to search)?

Created on 4 May 2017  路  1Comment  路  Source: rust-lang/rust-bindgen

This is hopefully a simple question/enhancement request. I'm new to Rust bindgen and clang -- apologies if this has been asked before.

I am trying to generate bindings for an open source project where some header files are generated as part of their build. So they have some header files in src tree and some in build, but they don't specify the full path in the source headers.

For example:
src/h1.h

#include "h2.h"
...

build/generated-source/h2.h

...

Bindgen fails to find h2.h when parsing h1.h. Is there any way to have bindgen work with this kind of structure directly, or do I need to copy the required header files to a common location?

Thanks

Most helpful comment

You can pass whatever args you would give to clang to find the include to bindgen as well (after a --), eg:

$ bindgen <bindgen-things> -- -Ibuild/generated-source

or, if you're using a Builder:

bindgen::Builder::default()
    // ...
    .clang_arg("-Ibuild/generated-source")
    // ...

If this doesn't resolve your problems, please reopen :)

>All comments

You can pass whatever args you would give to clang to find the include to bindgen as well (after a --), eg:

$ bindgen <bindgen-things> -- -Ibuild/generated-source

or, if you're using a Builder:

bindgen::Builder::default()
    // ...
    .clang_arg("-Ibuild/generated-source")
    // ...

If this doesn't resolve your problems, please reopen :)

Was this page helpful?
0 / 5 - 0 ratings