diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-03-15 14:11:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-15 14:11:16 +0100 |
commit | ab5d31aecd008adf1b901e56fd31ab6cce5c8fbd (patch) | |
tree | b2cbdbf56d50ca57286d2aaf5c1652c1e1b6cf0f /src | |
parent | 00c3295c5d50ac1a65eb313ecbe8d3db49b97566 (diff) | |
parent | f29b65993e5726e870cc59ee6484912225af2620 (diff) |
Merge pull request #1537 from jhwgh1968/clang_env_args
Add BINDGEN_EXTRA_CLANG_ARGS env variable
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -31,6 +31,7 @@ extern crate peeking_take_while; extern crate quote; extern crate proc_macro2; extern crate regex; +extern crate shlex; extern crate which; #[cfg(feature = "logging")] @@ -1168,6 +1169,17 @@ impl Builder { /// Generate the Rust bindings using the options built up thus far. pub fn generate(mut self) -> Result<Bindings, ()> { + // Add any extra arguments from the environment to the clang command line. + if let Some(extra_clang_args) = std::env::var("BINDGEN_EXTRA_CLANG_ARGS").ok() { + // Try to parse it with shell quoting. If we fail, make it one single big argument. + if let Some(strings) = shlex::split(&extra_clang_args) { + self.options.clang_args.extend(strings); + } else { + self.options.clang_args.push(extra_clang_args); + }; + } + + // Transform input headers to arguments on the clang command line. self.options.input_header = self.input_headers.pop(); self.options.clang_args.extend( self.input_headers |