Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Changed
- [PR#79](https://github.com/EmbarkStudios/cfg-expr/pull/79) updated the builtin target list to 1.87.0.

## [0.19.0] - 2025-04-03
### Changed
- [PR#78](https://github.com/EmbarkStudios/cfg-expr/pull/78) updated the builtin target list to 1.86.0.
Expand Down
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

# `⚙️ cfg-expr`

**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [1.86.0] are supported.**
**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [1.87.0] are supported.**

[![Build Status](https://github.com/EmbarkStudios/cfg-expr/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/cfg-expr/actions?workflow=CI)
[![Crates.io](https://img.shields.io/crates/v/cfg-expr.svg)](https://crates.io/crates/cfg-expr)
[![Docs](https://docs.rs/cfg-expr/badge.svg)](https://docs.rs/cfg-expr)
[![Minimum Stable Rust Version](https://img.shields.io/badge/Rust%20MSRV-1.70.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html)
[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.86.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html)
[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.87.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html)
[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
[![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev)
</div>
Expand All @@ -24,7 +24,7 @@

`cfg-expr` is a crate that can be used to parse and evaluate Rust `cfg()` expressions, both as declarable in Rust code itself, as well in cargo manifests' `[target.'cfg()'.dependencies]` sections.

It contains a list of all builtin targets known to rustc as of [1.86.0] that can be used to determine if a particular cfg expression is satisfiable.
It contains a list of all builtin targets known to rustc as of [1.87.0] that can be used to determine if a particular cfg expression is satisfiable.

```rust
use cfg_expr::{targets::get_builtin_target_by_triple, Expression, Predicate};
Expand All @@ -47,7 +47,6 @@ let specific = Expression::parse(

// cfg_expr includes a list of every builtin target in rustc
let x86_win = get_builtin_target_by_triple("i686-pc-windows-msvc").unwrap();
let x86_pentium_win = get_builtin_target_by_triple("i586-pc-windows-msvc").unwrap();
let uwp_win = get_builtin_target_by_triple("i686-uwp-windows-msvc").unwrap();
let mac = get_builtin_target_by_triple("x86_64-apple-darwin").unwrap();

Expand All @@ -63,15 +62,6 @@ assert!(specific.eval(|pred| {
}
}));

// This won't, it doesn't have the cool_thing feature!
assert!(!specific.eval(|pred| {
match pred {
Predicate::Target(tp) => tp.matches(x86_pentium_win),
Predicate::TargetFeature(feat) => avail_target_feats.contains(feat),
_ => false,
}
}));

// This will *not* satisfy the vendor predicate
assert!(!specific.eval(|pred| {
match pred {
Expand Down Expand Up @@ -110,4 +100,4 @@ at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

[1.86.0]: (https://forge.rust-lang.org/release/platform-support.html)
[1.87.0]: (https://forge.rust-lang.org/release/platform-support.html)
7 changes: 6 additions & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ impl TargetMatcher for target_lexicon::Triple {
target_lexicon::Vendor::Custom(target_lexicon::CustomVendor::Static("nuttx"));
const RTEMS: target_lexicon::Vendor =
target_lexicon::Vendor::Custom(target_lexicon::CustomVendor::Static("rtems"));
const WALI: target_lexicon::Vendor =
target_lexicon::Vendor::Custom(target_lexicon::CustomVendor::Static("wali"));

match tp {
Abi(_) => {
Expand Down Expand Up @@ -315,6 +317,9 @@ impl TargetMatcher for target_lexicon::Triple {
_ => false,
}
}
Linux if self.vendor == WALI => {
fam == &crate::targets::Family::wasm || fam == &crate::targets::Family::unix
}
Linux => {
// The 'kernel' environment is treated specially as not-unix
if self.environment != Environment::Kernel {
Expand Down Expand Up @@ -375,7 +380,7 @@ impl TargetMatcher for target_lexicon::Triple {
Vendor(ven) => match ven.0.parse::<target_lexicon::Vendor>() {
Ok(v) => {
if self.vendor == v
|| ((self.vendor == NUTTX || self.vendor == RTEMS)
|| ((self.vendor == NUTTX || self.vendor == RTEMS || self.vendor == WALI)
&& ven == &targ::Vendor::unknown)
{
true
Expand Down
60 changes: 30 additions & 30 deletions src/targets/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use super::*;

pub(crate) const RUSTC_VERSION: &str = "1.86.0";
pub(crate) const RUSTC_VERSION: &str = "1.87.0";

pub const ALL_BUILTINS: &[TargetInfo] = &[
TargetInfo {
Expand Down Expand Up @@ -1171,11 +1171,11 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
panic: Panic::abort,
},
TargetInfo {
triple: Triple::new_const("avr-unknown-gnu-atmega328"),
triple: Triple::new_const("avr-none"),
os: None,
abi: None,
arch: Arch::avr,
env: Some(Env::gnu),
env: None,
vendor: Some(Vendor::unknown),
families: Families::new_const(&[]),
pointer_width: 16,
Expand Down Expand Up @@ -1274,32 +1274,6 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("i586-pc-nto-qnx700"),
os: Some(Os::nto),
abi: None,
arch: Arch::x86,
env: Some(Env::nto70),
vendor: Some(Vendor::pc),
families: Families::unix,
pointer_width: 32,
endian: Endian::little,
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("i586-pc-windows-msvc"),
os: Some(Os::windows),
abi: None,
arch: Arch::x86,
env: Some(Env::msvc),
vendor: Some(Vendor::pc),
families: Families::windows,
pointer_width: 32,
endian: Endian::little,
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("i586-unknown-linux-gnu"),
os: Some(Os::linux),
Expand Down Expand Up @@ -1378,6 +1352,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("i686-pc-nto-qnx700"),
os: Some(Os::nto),
abi: None,
arch: Arch::x86,
env: Some(Env::nto70),
vendor: Some(Vendor::pc),
families: Families::unix,
pointer_width: 32,
endian: Endian::little,
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("i686-pc-windows-gnu"),
os: Some(Os::windows),
Expand Down Expand Up @@ -3068,6 +3055,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::abort,
},
TargetInfo {
triple: Triple::new_const("wasm32-wali-linux-musl"),
os: Some(Os::linux),
abi: None,
arch: Arch::wasm32,
env: Some(Env::musl),
vendor: Some(Vendor::unknown),
families: Families::unix_wasm,
pointer_width: 32,
endian: Endian::little,
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::abort,
},
TargetInfo {
triple: Triple::new_const("wasm32-wasip1"),
os: Some(Os::wasi),
Expand Down Expand Up @@ -3377,7 +3377,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
families: Families::unix,
pointer_width: 64,
endian: Endian::little,
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr,
panic: Panic::unwind,
},
TargetInfo {
Expand Down