Skip to content

Commit 180aec9

Browse files
richerfutwistedfall
authored andcommitted
chore: update code style
1 parent 5c56ddc commit 180aec9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

binding-generator/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dunce = "1"
1818
once_cell = "1" # replace with std::sync::OnceLock when MSRV is 1.70
1919
percent-encoding = { version = "2", default-features = false }
2020
regex = "1"
21+
shlex = { version = "1.3", default-features = false }
2122

2223
[features]
2324
clang-runtime = ["clang/runtime", "clang-sys/runtime"]

binding-generator/src/generator.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::path::{Path, PathBuf};
88
use clang::diagnostic::{Diagnostic, Severity};
99
use clang::{Clang, Entity, EntityKind, Index};
1010
use dunce::canonicalize;
11+
use shlex::Shlex;
1112

1213
use crate::type_ref::{CppNameStyle, FishStyle, TypeRef, TypeRefKind};
1314
use crate::typedef::NewTypedefResult;
@@ -435,10 +436,10 @@ impl Generator {
435436
// need to have c++14 here because VS headers contain features that require it
436437
args.push("-std=c++14".into());
437438
// 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-
});
439+
if let Some(clang_arg_str) = env::var_os("OPENCV_CLANG_ARGS") {
440+
let clang_arg = clang_arg_str.to_str().expect("Try to get OPENCV_CLANG_ARGS failed.");
441+
Shlex::new(clang_arg).into_iter().for_each(|i| args.push(i.into()))
442+
}
442443
args
443444
}
444445

0 commit comments

Comments
 (0)