Skip to content

Commit 5c56ddc

Browse files
richerfutwistedfall
authored andcommitted
feat: allow custom arguments for clang
1 parent b6d6304 commit 5c56ddc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ The following variables affect the building the of the `opencv` crate, but belon
128128
`*.dll`s next to your binary. Be sure to specify paths in UNIX style (/C/Program Files/Dir) because colon
129129
in `PATH` might be interpreted as the entry separator. Summary [here](https://stackoverflow.com/a/6546427).
130130

131+
* `OPENCV_CLANG_ARGS`
132+
Allow custom arguments for generating and parsing code with clang, see the [documentation for clang arguments](https://docs.rs/clang/latest/clang/struct.Parser.html#method.arguments).
133+
131134
* clang crate environment variables
132135
See crate's [README](https://github.com/KyleMayes/clang-sys/blob/master/README.md#environment-variables)
133136

binding-generator/src/generator.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::borrow::Cow;
2+
use std::env;
23
use std::fs::File;
34
use std::io::BufReader;
45
use std::ops::ControlFlow;
@@ -433,6 +434,11 @@ impl Generator {
433434
args.push("-includeocvrs_common.hpp".into());
434435
// need to have c++14 here because VS headers contain features that require it
435436
args.push("-std=c++14".into());
437+
// allow us to use some custom clang args
438+
let clang_args = env::var_os("OPENCV_CLANG_ARGS").unwrap_or_default();
439+
clang_args.to_string_lossy().split_whitespace().map(String::from).for_each(|i| {
440+
args.push(i.into());
441+
});
436442
args
437443
}
438444

0 commit comments

Comments
 (0)