File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -400,14 +400,22 @@ impl Default for Config {
400400 }
401401}
402402
403+ /// Convert from a preconfigured [`cc::Build`] object to [`Config`].
404+ /// Note that this will ensure C++ is enabled and add the proper include
405+ /// directories to work with `cpp`.
406+ impl From < cc:: Build > for Config {
407+ fn from ( mut cc : cc:: Build ) -> Self {
408+ cc. cpp ( true ) . include ( & * CARGO_MANIFEST_DIR ) ;
409+ Self { cc, std_flag_set : false }
410+ }
411+ }
412+
403413impl Config {
404414 /// Create a new `Config` object. This object will hold the configuration
405415 /// options which control the build. If you don't need to make any changes,
406416 /// `cpp_build::build` is a wrapper function around this interface.
407417 pub fn new ( ) -> Config {
408- let mut cc = cc:: Build :: new ( ) ;
409- cc. cpp ( true ) . include ( & * CARGO_MANIFEST_DIR ) ;
410- Config { cc, std_flag_set : false }
418+ cc:: Build :: new ( ) . into ( )
411419 }
412420
413421 /// Add a directory to the `-I` or include path for headers
You can’t perform that action at this time.
0 commit comments