Skip to content

Commit

Permalink
docs: Add examples for ConanInstall::build_profile()
Browse files Browse the repository at this point in the history
Restructure the advanced usage sections in the crate docs
and project README.
  • Loading branch information
ravenexp committed Nov 27, 2024
1 parent 7882980 commit f371c0d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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()
Expand All @@ -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:
Expand Down
36 changes: 34 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//!
Expand All @@ -58,15 +60,45 @@
//!
//! ConanInstall::new()
//! .profile(&conan_profile)
//! .detect_profile() // Auto-detect if the profile does not exist
//! .build("missing")
//! .verbosity(ConanVerbosity::Error) // Silence Conan warnings
//! .run()
//! .parse()
//! .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:
Expand Down

0 comments on commit f371c0d

Please sign in to comment.