From f371c0d0206dcac17450badc25073c7eedf9764a Mon Sep 17 00:00:00 2001 From: Sergey Kvachonok Date: Wed, 27 Nov 2024 16:36:01 +0300 Subject: [PATCH] docs: Add examples for `ConanInstall::build_profile()` Restructure the advanced usage sections in the crate docs and project README. --- README.md | 36 ++++++++++++++++++++++++++++++++++-- src/lib.rs | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 012888f..36f2af4 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ can also be found in the project repository. ## Advanced usage +### Automatic Conan profile inference from Cargo target + Using custom Conan profiles with names derived from the Cargo target information and a reduced output verbosity level: @@ -64,7 +66,6 @@ fn main() { ConanInstall::new() .profile(&conan_profile) - .detect_profile() // Auto-detect if the profile does not exist .build("missing") .verbosity(ConanVerbosity::Error) // Silence Conan warnings .run() @@ -73,7 +74,38 @@ fn main() { } ``` -## Getting C/C++ include paths from Conan dependencies +### Automatic Conan profile creation + +Creating a custom default Conan profile on the fly with zero configuration: + +```rust +use conan2::{ConanInstall, ConanVerbosity}; + +ConanInstall::new() + .profile("cargo") + .detect_profile() // Run `conan profile detect --exist-ok` for the above + .run() + .parse() + .emit(); +``` + +### Using separate host and build profiles + +Using different values for `--profile:host` and `--profile:build` +arguments of `conan install` command: + +```rust +use conan2::{ConanInstall, ConanVerbosity}; + +ConanInstall::new() + .host_profile("cargo-host") + .build_profile("cargo-build") + .run() + .parse() + .emit(); +``` + +### Getting C/C++ include paths from Conan dependencies To use the list of include paths, do the following after parsing the `conan install` output: diff --git a/src/lib.rs b/src/lib.rs index 0895bf3..0e234c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,6 +46,8 @@ //! //! ## Advanced usage //! +//! ### Automatic Conan profile inference from Cargo target +//! //! Using custom Conan profiles with names derived from the Cargo target information //! and a reduced output verbosity level: //! @@ -58,7 +60,6 @@ //! //! ConanInstall::new() //! .profile(&conan_profile) -//! .detect_profile() // Auto-detect if the profile does not exist //! .build("missing") //! .verbosity(ConanVerbosity::Error) // Silence Conan warnings //! .run() @@ -66,7 +67,38 @@ //! .emit(); //! ``` //! -//! ## Getting C/C++ include paths from Conan dependencies +//! ### Automatic Conan profile creation +//! +//! Creating a custom default Conan profile on the fly with zero configuration: +//! +//! ```no_run +//! use conan2::{ConanInstall, ConanVerbosity}; +//! +//! ConanInstall::new() +//! .profile("cargo") +//! .detect_profile() // Run `conan profile detect --exist-ok` for the above +//! .run() +//! .parse() +//! .emit(); +//! ``` +//! +//! ### Using separate host and build profiles +//! +//! Using different values for `--profile:host` and `--profile:build` +//! arguments of `conan install` command: +//! +//! ```no_run +//! use conan2::{ConanInstall, ConanVerbosity}; +//! +//! ConanInstall::new() +//! .host_profile("cargo-host") +//! .build_profile("cargo-build") +//! .run() +//! .parse() +//! .emit(); +//! ``` +//! +//! ### Getting C/C++ include paths from Conan dependencies //! //! To use the list of include paths, do the following after //! parsing the `conan install` output: