From 355fd2780550bfd84f5a6c74821c9a91da6f1096 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 29 Nov 2024 16:34:32 +0100 Subject: [PATCH] Update to 1.83.0 (#76) --- CHANGELOG.md | 3 + README.md | 8 +- src/expr.rs | 18 ++-- src/expr/lexer.rs | 5 +- src/targets/builtins.rs | 193 ++++++++++++++++++++++++++++++++-------- 5 files changed, 178 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 725e4e2..0275ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [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. diff --git a/README.md b/README.md index 5a1cace..ed52598 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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}; @@ -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) diff --git a/src/expr.rs b/src/expr.rs index b900627..d4ee99e 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -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(_) => { @@ -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!( @@ -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 } @@ -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 { @@ -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; } @@ -372,7 +377,10 @@ impl TargetMatcher for target_lexicon::Triple { } Vendor(ven) => match ven.0.parse::() { 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") diff --git a/src/expr/lexer.rs b/src/expr/lexer.rs index ce594c7..60abc6b 100644 --- a/src/expr/lexer.rs +++ b/src/expr/lexer.rs @@ -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(), diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index 14f5703..79e3570 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.82.0"; +pub(crate) const RUSTC_VERSION: &str = "1.83.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -143,19 +143,6 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, - TargetInfo { - triple: Triple::new_const("aarch64-fuchsia"), - os: Some(Os::fuchsia), - abi: None, - arch: Arch::aarch64, - env: None, - vendor: Some(Vendor::unknown), - families: Families::unix, - pointer_width: 64, - endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, - panic: Panic::unwind, - }, TargetInfo { triple: Triple::new_const("aarch64-kmc-solid_asp3"), os: Some(Os::solid_asp3), @@ -188,7 +175,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ abi: None, arch: Arch::aarch64, env: None, - vendor: Some(Vendor::unknown), + vendor: Some(Vendor::nintendo), families: Families::new_const(&[]), pointer_width: 64, endian: Endian::little, @@ -364,6 +351,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("aarch64-unknown-nto-qnx700"), + os: Some(Os::nto), + abi: None, + arch: Arch::aarch64, + env: Some(Env::nto70), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("aarch64-unknown-nto-qnx710"), os: Some(Os::nto), @@ -611,6 +611,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("arm64e-apple-tvos"), + os: Some(Os::tvos), + abi: None, + arch: Arch::aarch64, + env: None, + vendor: Some(Vendor::apple), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("arm64ec-pc-windows-msvc"), os: Some(Os::windows), @@ -793,6 +806,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("armv7-rtems-eabihf"), + os: Some(Os::rtems), + abi: Some(Abi::eabihf), + arch: Arch::arm, + env: Some(Env::newlib), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("armv7-sony-vita-newlibeabihf"), os: Some(Os::vita), @@ -952,7 +978,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7a-kmc-solid_asp3-eabi"), os: Some(Os::solid_asp3), - abi: None, + abi: Some(Abi::eabi), arch: Arch::arm, env: None, vendor: Some(Vendor::kmc), @@ -965,7 +991,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7a-kmc-solid_asp3-eabihf"), os: Some(Os::solid_asp3), - abi: None, + abi: Some(Abi::eabihf), arch: Arch::arm, env: None, vendor: Some(Vendor::kmc), @@ -1071,7 +1097,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ os: None, abi: None, arch: Arch::avr, - env: None, + env: Some(Env::gnu), vendor: Some(Vendor::unknown), families: Families::new_const(&[]), pointer_width: 16, @@ -1495,6 +1521,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("loongarch64-unknown-linux-ohos"), + os: Some(Os::linux), + abi: None, + arch: Arch::loongarch64, + env: Some(Env::ohos), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("loongarch64-unknown-none"), os: None, @@ -2041,6 +2080,58 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("riscv32-wrs-vxworks"), + os: Some(Os::vxworks), + abi: None, + arch: Arch::riscv32, + env: Some(Env::gnu), + vendor: Some(Vendor::wrs), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::unwind, + }, + TargetInfo { + triple: Triple::new_const("riscv32e-unknown-none-elf"), + os: None, + abi: None, + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, + TargetInfo { + triple: Triple::new_const("riscv32em-unknown-none-elf"), + os: None, + abi: None, + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, + TargetInfo { + triple: Triple::new_const("riscv32emc-unknown-none-elf"), + os: None, + abi: None, + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("riscv32gc-unknown-linux-gnu"), os: Some(Os::linux), @@ -2262,6 +2353,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("riscv64-wrs-vxworks"), + os: Some(Os::vxworks), + abi: None, + arch: Arch::riscv64, + env: Some(Env::gnu), + vendor: Some(Vendor::wrs), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("riscv64gc-unknown-freebsd"), os: Some(Os::freebsd), @@ -2415,7 +2519,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::unix, pointer_width: 64, endian: Endian::big, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, TargetInfo { @@ -2428,7 +2532,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::unix, pointer_width: 64, endian: Endian::big, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, TargetInfo { @@ -2447,7 +2551,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("sparc-unknown-none-elf"), os: None, - abi: Some(Abi::elf), + abi: None, arch: Arch::sparc, env: None, vendor: Some(Vendor::unknown), @@ -2951,19 +3055,6 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, - TargetInfo { - triple: Triple::new_const("x86_64-fuchsia"), - os: Some(Os::fuchsia), - abi: None, - arch: Arch::x86_64, - env: None, - vendor: Some(Vendor::unknown), - families: Families::unix, - pointer_width: 64, - endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, - panic: Panic::unwind, - }, TargetInfo { triple: Triple::new_const("x86_64-linux-android"), os: Some(Os::android), @@ -3120,6 +3211,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("x86_64-unknown-hurd-gnu"), + os: Some(Os::hurd), + abi: None, + arch: Arch::x86_64, + env: Some(Env::gnu), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("x86_64-unknown-illumos"), os: Some(Os::illumos), @@ -3263,6 +3367,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("x86_64-unknown-trusty"), + os: Some(Os::trusty), + abi: None, + arch: Arch::x86_64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("x86_64-unknown-uefi"), os: Some(Os::uefi), @@ -3360,7 +3477,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ abi: None, arch: Arch::xtensa, env: None, - vendor: Some(Vendor::unknown), + vendor: Some(Vendor::espressif), families: Families::new_const(&[]), pointer_width: 32, endian: Endian::little, @@ -3386,7 +3503,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ abi: None, arch: Arch::xtensa, env: None, - vendor: Some(Vendor::unknown), + vendor: Some(Vendor::espressif), families: Families::new_const(&[]), pointer_width: 32, endian: Endian::little, @@ -3412,7 +3529,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ abi: None, arch: Arch::xtensa, env: None, - vendor: Some(Vendor::unknown), + vendor: Some(Vendor::espressif), families: Families::new_const(&[]), pointer_width: 32, endian: Endian::little, @@ -3427,7 +3544,6 @@ impl super::Abi { pub const abiv2hf: Abi = Abi::new_const("abiv2hf"); pub const eabi: Abi = Abi::new_const("eabi"); pub const eabihf: Abi = Abi::new_const("eabihf"); - pub const elf: Abi = Abi::new_const("elf"); pub const fortanix: Abi = Abi::new_const("fortanix"); pub const ilp32: Abi = Abi::new_const("ilp32"); pub const llvm: Abi = Abi::new_const("llvm"); @@ -3513,6 +3629,7 @@ impl super::Os { pub const openbsd: Os = Os::new_const("openbsd"); pub const psp: Os = Os::new_const("psp"); pub const redox: Os = Os::new_const("redox"); + pub const rtems: Os = Os::new_const("rtems"); pub const solaris: Os = Os::new_const("solaris"); pub const solid_asp3: Os = Os::new_const("solid_asp3"); pub const teeos: Os = Os::new_const("teeos");