diff --git a/CHANGELOG.md b/CHANGELOG.md index 4971232..d8ddd03 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 <!-- next-header --> ## [Unreleased] - ReleaseDate +### Changed +- [PR#75](https://github.com/EmbarkStudios/cfg-expr/pull/75) updated the builtin target list to 1.82.0. + ## [0.17.0] - 2024-09-05 ### Changed - [PR#74](https://github.com/EmbarkStudios/cfg-expr/pull/74) updated the builtin target list to 1.81.0. diff --git a/README.md b/README.md index ddc8882..5a1cace 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.81.0] are supported.** +**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [1.82.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.81.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) +[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.82.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> @@ -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.81.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.82.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.81.0]: (https://forge.rust-lang.org/release/platform-support.html) +[1.82.0]: (https://forge.rust-lang.org/release/platform-support.html) diff --git a/src/expr.rs b/src/expr.rs index f6caa09..b900627 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -105,6 +105,9 @@ impl TargetMatcher for target_lexicon::Triple { Abi, Arch, Endian, Env, Family, HasAtomic, Os, Panic, PointerWidth, Vendor, }; + const NUTTX: target_lexicon::Vendor = + target_lexicon::Vendor::Custom(target_lexicon::CustomVendor::Static("nuttx")); + match tp { Abi(_) => { // `target_abi` is unstable. Assume false for this. @@ -267,6 +270,7 @@ impl TargetMatcher for target_lexicon::Triple { MacOSX, Nebulet, Netbsd, None_, Openbsd, Redox, Solaris, Tvos, Uefi, Unknown, Visionos, VxWorks, Wasi, WasiP1, WasiP2, Watchos, Windows, }; + match self.operating_system { AmdHsa | Bitrig | Cloudabi | Cuda | Hermit | Nebulet | None_ | Uefi => false, Aix @@ -300,6 +304,7 @@ impl TargetMatcher for target_lexicon::Triple { _ => false, } } + Unknown if self.vendor == NUTTX => fam == &crate::targets::Family::unix, Unknown => { // asmjs, wasm32 and wasm64 are part of the wasm family. match self.architecture { @@ -334,9 +339,11 @@ impl TargetMatcher for target_lexicon::Triple { self.operating_system, OperatingSystem::WasiP1 | OperatingSystem::WasiP2 ) + || os == &targ::Os::nuttx && self.vendor == NUTTX { return true; } + match os.0.parse::<OperatingSystem>() { Ok(o) => match self.environment { Environment::HermitKernel => os == &targ::Os::hermit, @@ -365,7 +372,7 @@ impl TargetMatcher for target_lexicon::Triple { } Vendor(ven) => match ven.0.parse::<target_lexicon::Vendor>() { Ok(v) => { - if self.vendor == v { + if self.vendor == v || self.vendor == NUTTX && 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/targets/builtins.rs b/src/targets/builtins.rs index 5babbe4..14f5703 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.81.0"; +pub(crate) const RUSTC_VERSION: &str = "1.82.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -416,6 +416,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-trusty"), + os: Some(Os::trusty), + abi: None, + arch: Arch::aarch64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("aarch64-unknown-uefi"), os: Some(Os::uefi), @@ -910,6 +923,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("armv7-unknown-trusty"), + os: Some(Os::trusty), + abi: Some(Abi::eabi), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("armv7-wrs-vxworks-eabihf"), os: Some(Os::vxworks), @@ -1833,6 +1859,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("powerpc-unknown-linux-muslspe"), + os: Some(Os::linux), + abi: Some(Abi::spe), + arch: Arch::powerpc, + env: Some(Env::musl), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::big, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("powerpc-unknown-netbsd"), os: Some(Os::netbsd), @@ -2106,6 +2145,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv32imac-unknown-nuttx-elf"), + os: Some(Os::nuttx), + abi: None, + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + 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("riscv32imac-unknown-xous-elf"), os: Some(Os::xous), @@ -2145,6 +2197,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv32imafc-unknown-nuttx-elf"), + os: Some(Os::nuttx), + abi: None, + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("riscv32imc-esp-espidf"), os: Some(Os::espidf), @@ -2171,6 +2236,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::new_const(&[]), panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv32imc-unknown-nuttx-elf"), + os: Some(Os::nuttx), + abi: None, + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + 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("riscv64-linux-android"), os: Some(Os::android), @@ -2275,6 +2353,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv64gc-unknown-nuttx-elf"), + os: Some(Os::nuttx), + abi: None, + arch: Arch::riscv64, + 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::abort, + }, TargetInfo { triple: Triple::new_const("riscv64gc-unknown-openbsd"), os: Some(Os::openbsd), @@ -2301,6 +2392,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv64imac-unknown-nuttx-elf"), + os: Some(Os::nuttx), + abi: None, + arch: Arch::riscv64, + 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::abort, + }, TargetInfo { triple: Triple::new_const("s390x-unknown-linux-gnu"), os: Some(Os::linux), @@ -2444,6 +2548,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::new_const(&[]), panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("thumbv6m-nuttx-eabi"), + os: Some(Os::nuttx), + abi: Some(Abi::eabi), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("thumbv7a-pc-windows-msvc"), os: Some(Os::windows), @@ -2496,6 +2613,32 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("thumbv7em-nuttx-eabi"), + os: Some(Os::nuttx), + abi: Some(Abi::eabi), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, + TargetInfo { + triple: Triple::new_const("thumbv7em-nuttx-eabihf"), + os: Some(Os::nuttx), + abi: Some(Abi::eabihf), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("thumbv7m-none-eabi"), os: None, @@ -2509,6 +2652,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("thumbv7m-nuttx-eabi"), + os: Some(Os::nuttx), + abi: Some(Abi::eabi), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("thumbv7neon-linux-androideabi"), os: Some(Os::android), @@ -2561,6 +2717,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("thumbv8m.base-nuttx-eabi"), + os: Some(Os::nuttx), + abi: Some(Abi::eabi), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("thumbv8m.main-none-eabi"), os: None, @@ -2587,6 +2756,32 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("thumbv8m.main-nuttx-eabi"), + os: Some(Os::nuttx), + abi: Some(Abi::eabi), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, + TargetInfo { + triple: Triple::new_const("thumbv8m.main-nuttx-eabihf"), + os: Some(Os::nuttx), + abi: Some(Abi::eabihf), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("wasm32-unknown-emscripten"), os: Some(Os::emscripten), @@ -3314,12 +3509,14 @@ impl super::Os { pub const macos: Os = Os::new_const("macos"); pub const netbsd: Os = Os::new_const("netbsd"); pub const nto: Os = Os::new_const("nto"); + pub const nuttx: Os = Os::new_const("nuttx"); 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 solaris: Os = Os::new_const("solaris"); pub const solid_asp3: Os = Os::new_const("solid_asp3"); pub const teeos: Os = Os::new_const("teeos"); + pub const trusty: Os = Os::new_const("trusty"); pub const tvos: Os = Os::new_const("tvos"); pub const uefi: Os = Os::new_const("uefi"); pub const unknown: Os = Os::new_const("unknown");