Skip to content

Commit

Permalink
impl From<cc::Build> for cpp_build::Config
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-h-chamberlain authored and ogoffart committed May 3, 2024
1 parent 9eda55b commit 58c8c46
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cpp_build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,22 @@ impl Default for Config {
}
}

/// Convert from a preconfigured [`cc::Build`] object to [`Config`].
/// Note that this will ensure C++ is enabled and add the proper include
/// directories to work with `cpp`.
impl From<cc::Build> for Config {
fn from(mut cc: cc::Build) -> Self {
cc.cpp(true).include(&*CARGO_MANIFEST_DIR);
Self { cc, std_flag_set: false }
}
}

impl Config {
/// Create a new `Config` object. This object will hold the configuration
/// options which control the build. If you don't need to make any changes,
/// `cpp_build::build` is a wrapper function around this interface.
pub fn new() -> Config {
let mut cc = cc::Build::new();
cc.cpp(true).include(&*CARGO_MANIFEST_DIR);
Config { cc, std_flag_set: false }
cc::Build::new().into()
}

/// Add a directory to the `-I` or include path for headers
Expand Down

0 comments on commit 58c8c46

Please sign in to comment.