Skip to content

Conversation

elrnv
Copy link
Contributor

@elrnv elrnv commented Mar 10, 2021

Added a build_with member function to Config to allow for feeding in custom cc::Build configurations (both C and C++). This makes it particularly convenient, for instance to integrate cmake builds with the cxx-build crate, which produces cc::Build configs.

For instance, we may build C++ code with cxx with cmake using:

let build = cxx_build::bridge("src/lib.rs");
cmake::Config::new(".")
    .no_build_target(true)
    .build_with(build.clone(), build.clone());

This is useful when integrating cxx with existing projects that already use CMake.
I tested this particular workflow in the hdkrs crate, which builds a cxx layer between the Houdini C++ API (which uses CMake) and Rust.

@alexcrichton
Copy link
Member

Could these perhaps be dedicated configuration methods rather than a separate build method? Otherwise seems reasonable to me!

Removed build_with in favour of configuration options in Config which
can be set using init_c_cfg and init_cxx_cfg.
@elrnv
Copy link
Contributor Author

elrnv commented Mar 12, 2021

Good point! I updated the PR with two additional configuration options in Config that let the user set an explicit cc::Build starting point for C and C++ (separately).

@alexcrichton
Copy link
Member

Looks good to me, thanks!

@alexcrichton alexcrichton merged commit 838ffb2 into rust-lang:master Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants