Skip to content

Commit

Permalink
Update to 1.83.0 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle authored Nov 29, 2024
1 parent f504d6a commit 355fd27
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 49 deletions.
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#76](https://github.com/EmbarkStudios/cfg-expr/pull/76) updated the builtin target list to 1.83.0.

## [0.17.1] - 2024-11-15
### Changed
- [PR#75](https://github.com/EmbarkStudios/cfg-expr/pull/75) updated the builtin target list to 1.82.0.
Expand Down
8 changes: 4 additions & 4 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.82.0] are supported.**
**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [1.83.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.82.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html)
[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.83.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.82.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.83.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 Down Expand Up @@ -110,4 +110,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.82.0]: (https://forge.rust-lang.org/release/platform-support.html)
[1.83.0]: (https://forge.rust-lang.org/release/platform-support.html)
18 changes: 13 additions & 5 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ impl TargetMatcher for target_lexicon::Triple {

const NUTTX: target_lexicon::Vendor =
target_lexicon::Vendor::Custom(target_lexicon::CustomVendor::Static("nuttx"));
const RTEMS: target_lexicon::Vendor =
target_lexicon::Vendor::Custom(target_lexicon::CustomVendor::Static("rtems"));

match tp {
Abi(_) => {
Expand Down Expand Up @@ -231,7 +233,7 @@ impl TargetMatcher for target_lexicon::Triple {
Environment::Kernel => {
self.operating_system == OperatingSystem::Linux
}
_ => false,
_ => self.architecture == Architecture::Avr,
}
} else if env == &targ::Env::musl {
matches!(
Expand All @@ -252,7 +254,7 @@ impl TargetMatcher for target_lexicon::Triple {
matches!(
self.operating_system,
OperatingSystem::Horizon | OperatingSystem::Espidf
)
) || self.vendor == RTEMS
} else {
self.environment == e
}
Expand Down Expand Up @@ -304,7 +306,9 @@ impl TargetMatcher for target_lexicon::Triple {
_ => false,
}
}
Unknown if self.vendor == NUTTX => fam == &crate::targets::Family::unix,
Unknown if self.vendor == NUTTX || self.vendor == RTEMS => {
fam == &crate::targets::Family::unix
}
Unknown => {
// asmjs, wasm32 and wasm64 are part of the wasm family.
match self.architecture {
Expand Down Expand Up @@ -339,7 +343,8 @@ impl TargetMatcher for target_lexicon::Triple {
self.operating_system,
OperatingSystem::WasiP1 | OperatingSystem::WasiP2
)
|| os == &targ::Os::nuttx && self.vendor == NUTTX
|| (os == &targ::Os::nuttx && self.vendor == NUTTX)
|| (os == &targ::Os::rtems && self.vendor == RTEMS)
{
return true;
}
Expand Down Expand Up @@ -372,7 +377,10 @@ impl TargetMatcher for target_lexicon::Triple {
}
Vendor(ven) => match ven.0.parse::<target_lexicon::Vendor>() {
Ok(v) => {
if self.vendor == v || self.vendor == NUTTX && ven == &targ::Vendor::unknown {
if self.vendor == v
|| ((self.vendor == NUTTX || self.vendor == RTEMS)
&& ven == &targ::Vendor::unknown)
{
true
} else if let target_lexicon::Vendor::Custom(custom) = &self.vendor {
matches!(custom.as_str(), "esp" | "esp32" | "esp32s2" | "esp32s3")
Expand Down
5 changes: 3 additions & 2 deletions src/expr/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ pub enum Token<'a> {
Comma,
}

impl<'a> std::fmt::Display for Token<'a> {
impl std::fmt::Display for Token<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Debug::fmt(self, f)
}
}

impl<'a> Token<'a> {
impl Token<'_> {
#[inline]
fn len(&self) -> usize {
match self {
Token::Key(s) => s.len(),
Expand Down
Loading

0 comments on commit 355fd27

Please sign in to comment.