diff --git a/.cargo/config.toml b/.cargo/config.toml index 3d31fa7..dca7598 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -44,7 +44,6 @@ rustflags = [ "-Wclippy::match_wild_err_arm", "-Wclippy::match_wildcard_for_single_variants", "-Wclippy::mem_forget", - "-Wclippy::mismatched_target_os", "-Wclippy::missing_enforced_import_renames", "-Wclippy::mut_mut", "-Wclippy::mutex_integer", @@ -72,6 +71,7 @@ rustflags = [ "-Wclippy::useless_transmute", "-Wclippy::verbose_file_reads", "-Wclippy::zero_sized_map_values", + "-Wunexpected_cfgs", "-Wfuture_incompatible", "-Wnonstandard_style", "-Wrust_2018_idioms", diff --git a/CHANGELOG.md b/CHANGELOG.md index cc0c4a8..d63bbf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#74](https://github.com/EmbarkStudios/cfg-expr/pull/74) updated the builtin target list to 1.81.0. + ## [0.16.0] - 2024-07-29 ### Changed -- [PR#70](https://github.com/EmbarkStudios/cfg-expr/pull/70) updated the builtin target list to 1.78.0. Thanks [@sunshowers](https://github.com/sunshowers)! +- [PR#70](https://github.com/EmbarkStudios/cfg-expr/pull/70) updated the builtin target list to 1.80.0. Thanks [@sunshowers](https://github.com/sunshowers)! ## [0.15.8] - 2024-04-10 ### Changed diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d3b5b7c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,231 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bstr" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "cfg-expr" +version = "0.16.0" +dependencies = [ + "similar-asserts", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "windows-sys", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" + +[[package]] +name = "serde" +version = "1.0.209" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.209" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "similar" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" +dependencies = [ + "bstr", + "unicode-segmentation", +] + +[[package]] +name = "similar-asserts" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe85670573cd6f0fa97940f26e7e6601213c3b0555246c24234131f88c5709e" +dependencies = [ + "console", + "similar", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "2.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index 4197ebf..7a1095d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ targets = ["target-lexicon"] [dependencies] smallvec = "1.8" -target-lexicon = { version = "0.12.15", optional = true } +target-lexicon = { version = "=0.12.16", optional = true } [dev-dependencies] similar-asserts = "1.1" diff --git a/README.md b/README.md index 1c5541f..ddc8882 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.80.0] are supported.** +**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [1.81.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.80.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) +[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.81.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.80.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.81.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.80.0]: (https://forge.rust-lang.org/release/platform-support.html) +[1.81.0]: (https://forge.rust-lang.org/release/platform-support.html) diff --git a/src/expr.rs b/src/expr.rs index 30d0c9f..f6caa09 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -187,8 +187,9 @@ impl TargetMatcher for target_lexicon::Triple { Environment::LinuxKernel => env == &targ::Env::gnu, _ => env.0.is_empty(), }, - OperatingSystem::WasiP1 => env.0.is_empty(), + OperatingSystem::WasiP1 => env == &targ::Env::p1, OperatingSystem::WasiP2 => env == &targ::Env::p2, + OperatingSystem::Wasi => env.0.is_empty() || env == &targ::Env::p1, _ => { if env.0.is_empty() { matches!( @@ -367,7 +368,9 @@ impl TargetMatcher for target_lexicon::Triple { if self.vendor == v { true } else if let target_lexicon::Vendor::Custom(custom) = &self.vendor { - custom.as_str() == "esp" && v == target_lexicon::Vendor::Espressif + matches!(custom.as_str(), "esp" | "esp32" | "esp32s2" | "esp32s3") + && (v == target_lexicon::Vendor::Espressif + || v == target_lexicon::Vendor::Unknown) } else { false } diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index 543b5f6..5babbe4 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.80.0"; +pub(crate) const RUSTC_VERSION: &str = "1.81.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -1365,6 +1365,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("i686-unknown-redox"), + os: Some(Os::redox), + abi: None, + arch: Arch::x86, + env: Some(Env::relibc), + vendor: Some(Vendor::unknown), + 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-unknown-uefi"), os: Some(Os::uefi), @@ -2605,7 +2618,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ os: Some(Os::wasi), abi: None, arch: Arch::wasm32, - env: None, + env: Some(Env::p1), vendor: Some(Vendor::unknown), families: Families::wasm, pointer_width: 32, @@ -2618,7 +2631,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ os: Some(Os::wasi), abi: None, arch: Arch::wasm32, - env: None, + env: Some(Env::p1), vendor: Some(Vendor::unknown), families: Families::wasm, pointer_width: 32, @@ -2631,7 +2644,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ os: Some(Os::wasi), abi: None, arch: Arch::wasm32, - env: None, + env: Some(Env::p1), vendor: Some(Vendor::unknown), families: Families::wasm, pointer_width: 32, @@ -3133,6 +3146,84 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("xtensa-esp32-espidf"), + os: Some(Os::espidf), + abi: None, + arch: Arch::xtensa, + env: Some(Env::newlib), + vendor: Some(Vendor::espressif), + 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("xtensa-esp32-none-elf"), + os: None, + abi: None, + arch: Arch::xtensa, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, + TargetInfo { + triple: Triple::new_const("xtensa-esp32s2-espidf"), + os: Some(Os::espidf), + abi: None, + arch: Arch::xtensa, + env: Some(Env::newlib), + vendor: Some(Vendor::espressif), + 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("xtensa-esp32s2-none-elf"), + os: None, + abi: None, + arch: Arch::xtensa, + 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("xtensa-esp32s3-espidf"), + os: Some(Os::espidf), + abi: None, + arch: Arch::xtensa, + env: Some(Env::newlib), + vendor: Some(Vendor::espressif), + 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("xtensa-esp32s3-none-elf"), + os: None, + abi: None, + arch: Arch::xtensa, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, ]; impl super::Abi { @@ -3181,6 +3272,7 @@ impl super::Arch { pub const wasm64: Arch = Arch::new_const("wasm64"); pub const x86: Arch = Arch::new_const("x86"); pub const x86_64: Arch = Arch::new_const("x86_64"); + pub const xtensa: Arch = Arch::new_const("xtensa"); } impl super::Vendor { @@ -3267,6 +3359,7 @@ impl super::Env { pub const nto70: Env = Env::new_const("nto70"); pub const nto71: Env = Env::new_const("nto71"); pub const ohos: Env = Env::new_const("ohos"); + pub const p1: Env = Env::new_const("p1"); pub const p2: Env = Env::new_const("p2"); pub const psx: Env = Env::new_const("psx"); pub const relibc: Env = Env::new_const("relibc"); diff --git a/update/src/main.rs b/update/src/main.rs index ced5990..166b84c 100644 --- a/update/src/main.rs +++ b/update/src/main.rs @@ -169,7 +169,8 @@ fn assemble(version: &str, rustc: String) -> Result { // unstable "relocation_model" | "target_has_atomic_equal_alignment" - | "target_has_atomic_load_store" => { + | "target_has_atomic_load_store" + | "fmt_debug" => { //relocation_model = Some(val), } _ => panic!("unknown key: {line}"),