Skip to content

Commit

Permalink
Update to 1.72.0 targets (#64)
Browse files Browse the repository at this point in the history
* Update to 1.72.0 targets

* Update CHANGELOG
  • Loading branch information
Jake-Shadle authored Sep 8, 2023
1 parent 52af7e1 commit 2ba956f
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
name: Test
strategy:
matrix:
toolchain: [1.58.0, stable]
toolchain: [1.70.0, stable]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand Down
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#64](https://github.com/EmbarkStudios/cfg-expr/pull/64) updated the builtin target list to 1.72.0. It also changed the MSRV to 1.70.0.

## [0.15.4] - 2023-07-28
### Changed
- [PR#62](https://github.com/EmbarkStudios/cfg-expr/pull/62) updated the builtin target list to 1.71.0.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
rust-version = "1.58.0"
rust-version = "1.70.0"
documentation = "https://docs.rs/cfg-expr"
homepage = "https://github.com/EmbarkStudios/cfg-expr"
keywords = ["cargo", "rustc", "cfg"]
Expand All @@ -24,7 +24,7 @@ targets = ["target-lexicon"]

[dependencies]
smallvec = "1.8"
target-lexicon = { version = "0.12.5", optional = true }
target-lexicon = { version = "0.12.11", optional = true }

[dev-dependencies]
similar-asserts = "1.1"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# `⚙️ cfg-expr`

**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [Rust 1.69.0](https://forge.rust-lang.org/release/platform-support.html) are supported.**
**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [Rust 1.72.0](https://forge.rust-lang.org/release/platform-support.html) 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)
Expand All @@ -22,7 +22,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.66.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.72.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
20 changes: 18 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ impl TargetMatcher for target_lexicon::Triple {
} else if arch == &targ::Arch::bpf {
self.architecture == Architecture::Bpfeb
|| self.architecture == Architecture::Bpfel
} else if arch == &targ::Arch::x86_64 {
self.architecture == Architecture::X86_64
|| self.architecture == Architecture::X86_64h
} else {
match arch.0.parse::<Architecture>() {
Ok(a) => match (self.architecture, a) {
Expand Down Expand Up @@ -224,6 +227,11 @@ impl TargetMatcher for target_lexicon::Triple {
| Environment::Uclibceabi
| Environment::Uclibceabihf
)
} else if env == &targ::Env::newlib {
matches!(
self.operating_system,
OperatingSystem::Horizon | OperatingSystem::Espidf
)
} else {
self.environment == e
}
Expand All @@ -235,7 +243,7 @@ impl TargetMatcher for target_lexicon::Triple {
}
}
Family(fam) => {
use target_lexicon::OperatingSystem::{
use OperatingSystem::{
Aix, AmdHsa, Bitrig, Cloudabi, Cuda, Darwin, Dragonfly, Emscripten, Espidf,
Freebsd, Fuchsia, Haiku, Hermit, Horizon, Illumos, Ios, L4re, Linux, MacOSX,
Nebulet, Netbsd, None_, Openbsd, Redox, Solaris, Tvos, Uefi, Unknown, VxWorks,
Expand Down Expand Up @@ -324,7 +332,15 @@ impl TargetMatcher for target_lexicon::Triple {
false
}
Vendor(ven) => match ven.0.parse::<target_lexicon::Vendor>() {
Ok(v) => self.vendor == v,
Ok(v) => {
if self.vendor == v {
true
} else if let target_lexicon::Vendor::Custom(custom) = &self.vendor {
custom.as_str() == "esp" && v == target_lexicon::Vendor::Espressif
} else {
false
}
}
Err(_) => false,
},
PointerWidth(pw) => {
Expand Down
2 changes: 1 addition & 1 deletion src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo>
/// versions.
///
/// ```
/// assert_eq!("1.71.0", cfg_expr::targets::rustc_version());
/// assert_eq!("1.72.0", cfg_expr::targets::rustc_version());
/// ```
pub fn rustc_version() -> &'static str {
builtins::RUSTC_VERSION
Expand Down
77 changes: 71 additions & 6 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.71.0";
pub(crate) const RUSTC_VERSION: &str = "1.72.0";

pub const ALL_BUILTINS: &[TargetInfo] = &[
TargetInfo {
Expand Down Expand Up @@ -403,6 +403,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("aarch64_be-unknown-netbsd"),
os: Some(Os::netbsd),
abi: None,
arch: Arch::aarch64,
env: None,
vendor: Some(Vendor::unknown),
families: Families::unix,
pointer_width: 64,
endian: Endian::big,
has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("arm-linux-androideabi"),
os: Some(Os::android),
Expand Down Expand Up @@ -674,7 +687,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
pointer_width: 32,
endian: Endian::little,
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::abort,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("armv7-unknown-freebsd"),
Expand Down Expand Up @@ -1235,6 +1248,32 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("loongarch64-unknown-none"),
os: None,
abi: None,
arch: Arch::loongarch64,
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("loongarch64-unknown-none-softfloat"),
os: None,
abi: None,
arch: Arch::loongarch64,
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("m68k-unknown-linux-gnu"),
os: Some(Os::linux),
Expand Down Expand Up @@ -1781,6 +1820,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
has_atomics: HasAtomics::new_const(&[]),
panic: Panic::abort,
},
TargetInfo {
triple: Triple::new_const("riscv32imac-esp-espidf"),
os: Some(Os::espidf),
abi: None,
arch: Arch::riscv32,
env: Some(Env::newlib),
vendor: Some(Vendor::espressif),
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("riscv32imac-unknown-none-elf"),
os: None,
Expand Down Expand Up @@ -1885,6 +1937,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[
has_atomics: HasAtomics::atomic_8_16_32_64_ptr,
panic: Panic::unwind,
},
TargetInfo {
triple: Triple::new_const("riscv64gc-unknown-netbsd"),
os: Some(Os::netbsd),
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::unwind,
},
TargetInfo {
triple: Triple::new_const("riscv64gc-unknown-none-elf"),
os: None,
Expand Down Expand Up @@ -2272,7 +2337,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 All @@ -2285,7 +2350,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 All @@ -2298,7 +2363,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 All @@ -2311,7 +2376,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

0 comments on commit 2ba956f

Please sign in to comment.