Skip to content

Commit

Permalink
feat: Add ConanInstall::build_profile() method
Browse files Browse the repository at this point in the history
Allow setting Conan build profile along with the host profile.

Add an alias `ConanInstall::host_profile()` for `ConanInstall::profile()`.

Bump the crate version to 0.1.3 (preliminary).

Resolves #10
  • Loading branch information
ravenexp committed Nov 27, 2024
1 parent d4c9f06 commit f1e4cd6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "conan2"
version = "0.1.2"
version = "0.1.3"
description = "Pulls the C/C++ library linking flags from Conan dependencies"
authors = ["Sergey Kvachonok <[email protected]>"]
edition = "2021"
Expand Down
30 changes: 27 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ pub struct ConanInstall {
output_folder: Option<PathBuf>,
/// Conan recipe file path
recipe_path: Option<PathBuf>,
/// Conan profile name
/// Conan host profile name
profile: Option<String>,
/// Conan build profile name
build_profile: Option<String>,
/// Conan profile auto-detection flag
new_profile: bool,
/// Conan build policy
Expand Down Expand Up @@ -213,6 +215,21 @@ impl ConanInstall {
self
}

/// Sets the Conan host profile name to use for installing dependencies.
///
/// Matches `--profile:host` Conan executable option.
pub fn host_profile(&mut self, profile: &str) -> &mut ConanInstall {
self.profile(profile)
}

/// Sets the Conan build profile name to use for installing dependencies.
///
/// Matches `--profile:build` Conan executable option.
pub fn build_profile(&mut self, profile: &str) -> &mut ConanInstall {
self.build_profile = Some(profile.to_owned());
self
}

/// Auto-detects and creates the Conan profile to use for installing dependencies.
///
/// Schedules `conan profile detect --exist-ok` to run before running `conan install`.
Expand Down Expand Up @@ -256,6 +273,10 @@ impl ConanInstall {

if self.new_profile {
Self::run_profile_detect(&conan, self.profile.as_deref());

if self.build_profile != self.profile {
Self::run_profile_detect(&conan, self.build_profile.as_deref());
};
}

let mut command = Command::new(conan);
Expand All @@ -269,8 +290,11 @@ impl ConanInstall {
.arg(output_folder);

if let Some(profile) = self.profile.as_deref() {
command.arg("--profile");
command.arg(profile);
command.arg("--profile:host").arg(profile);
}

if let Some(build_profile) = self.build_profile.as_deref() {
command.arg("--profile:build").arg(build_profile);
}

if let Some(build) = self.build.as_deref() {
Expand Down

0 comments on commit f1e4cd6

Please sign in to comment.