guppy/platform/
mod.rs

1// Copyright (c) The cargo-guppy Contributors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Support for dependencies that are only enabled on some platforms.
5//!
6//! Most of the time, dependencies are enabled across all platforms. For example, in this
7//! `Cargo.toml`:
8//!
9//! ```toml
10//! # once_cell 1.5 is enabled on all platforms.
11//! [dependencies]
12//! once_cell = "1.5"
13//! ```
14//!
15//! However, in some cases, dependencies may only be enabled on certain platforms.
16//!
17//! ```toml
18//! # This dependency is only enabled on Linux x86_64.
19//! [target.x86_64-unknown-linux-gnu.dependencies]
20//! inotify = "0.9.4"
21//!
22//! # This build dependency is enabled on Windows.
23//! [target.'cfg(windows)'.build-dependencies]
24//! winapi = "0.3.9"
25//! ```
26//!
27//! This module provides types that can represent platforms and evaluate expressions.
28//!
29//! # Representing platforms
30//!
31//! * [`Platform`] represents a single platform.
32//! * [`Triple`] is a [Rust target triple](https://doc.rust-lang.org/stable/rustc/platform-support.html).
33//! * [`PlatformSpec`] represents a single platform or a range of platforms, including any platform
34//!   (the union of all possible platforms) and all platforms (the intersection of all possible
35//!   platforms).
36//!
37//! # Evaluating platforms
38//!
39//! These structs are defined in the context of a [`PackageGraph`](crate::graph::PackageGraph), and
40//! are typically returned through [`PackageLink`](crate::graph::PackageLink) instances.
41//!
42//! * [`PlatformStatus`]: The status of a dependency or a feature which might be platform-dependent.
43//! * [`PlatformEval`]: A collection of platform specifications like `cfg(unix)`, to evaluate
44//!   against a platform.
45//! * [`EnabledTernary`]: A three-valued logic representing the status of a dependency or feature
46//!   on a given platform. Includes an additional status to represent situations like unknown
47//!   [target features](https://rust-lang.github.io/rfcs/2045-target-feature.html).
48//!
49//! If the `summaries` feature is enabled, this module also supports reading and writing serializable
50//! summaries of platforms. These can be used both as configuration, and to serialize the results of a
51//! particular `guppy` evaluation.
52//!
53//! For more, about platform-specific dependencies, see [Platform specific
54//! dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)
55//! in the Cargo reference.
56
57mod platform_eval;
58mod platform_spec;
59#[cfg(feature = "proptest1")]
60mod proptest_helpers;
61#[cfg(feature = "summaries")]
62mod summaries;
63
64pub use platform_eval::*;
65pub use platform_spec::*;
66#[cfg(feature = "summaries")]
67pub use summaries::*;
68// These are inlined -- generally, treat target_spec as a private dependency so expose these types
69// as part of guppy's API.
70pub use target_spec::{Platform, TargetFeatures, Triple};