Skip to content

Commit

Permalink
Update targets to Rust 1.63 (#51)
Browse files Browse the repository at this point in the history
* Make target-lexicon parsing optional

There are enough new weird architectures added in each version of Rust
that it is difficult to keep target-lexicon aware of all of them. So try
parsing triples, but don't fail if that doesn't work.

* Update targets to Rust 1.63

* Update to 1.64.0

* Bump MSRV to 1.58.0

* Move lint config to .cargo/config.toml

* Update CHANGELOG

* Fixup README

* Cleanup CI

* Oops

Co-authored-by: Jake Shadle <jake.shadle@embark-studios.com>
  • Loading branch information
sunshowers and Jake-Shadle authored Sep 27, 2022
1 parent 9febdd3 commit 266b620
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 222 deletions.
79 changes: 79 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[target.'cfg(all())']
rustflags = [
# BEGIN - Embark standard lints v6 for Rust 1.55+
# do not change or add/remove here, but one can add exceptions after this section
# for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
"-Dunsafe_code",
"-Wclippy::all",
"-Wclippy::await_holding_lock",
"-Wclippy::char_lit_as_u8",
"-Wclippy::checked_conversions",
"-Wclippy::dbg_macro",
"-Wclippy::debug_assert_with_mut_call",
"-Wclippy::doc_markdown",
"-Wclippy::empty_enum",
"-Wclippy::enum_glob_use",
"-Wclippy::exit",
"-Wclippy::expl_impl_clone_on_copy",
"-Wclippy::explicit_deref_methods",
"-Wclippy::explicit_into_iter_loop",
"-Wclippy::fallible_impl_from",
"-Wclippy::filter_map_next",
"-Wclippy::flat_map_option",
"-Wclippy::float_cmp_const",
"-Wclippy::fn_params_excessive_bools",
"-Wclippy::from_iter_instead_of_collect",
"-Wclippy::if_let_mutex",
"-Wclippy::implicit_clone",
"-Wclippy::imprecise_flops",
"-Wclippy::inefficient_to_string",
"-Wclippy::invalid_upcast_comparisons",
"-Wclippy::large_digit_groups",
"-Wclippy::large_stack_arrays",
"-Wclippy::large_types_passed_by_value",
"-Wclippy::let_unit_value",
"-Wclippy::linkedlist",
"-Wclippy::lossy_float_literal",
"-Wclippy::macro_use_imports",
"-Wclippy::manual_ok_or",
"-Wclippy::map_err_ignore",
"-Wclippy::map_flatten",
"-Wclippy::map_unwrap_or",
"-Wclippy::match_on_vec_items",
"-Wclippy::match_same_arms",
"-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",
"-Wclippy::needless_borrow",
"-Wclippy::needless_continue",
"-Wclippy::needless_for_each",
"-Wclippy::option_option",
"-Wclippy::path_buf_push_overwrite",
"-Wclippy::ptr_as_ptr",
"-Wclippy::rc_mutex",
"-Wclippy::ref_option_ref",
"-Wclippy::rest_pat_in_fully_bound_structs",
"-Wclippy::same_functions_in_if_condition",
"-Wclippy::semicolon_if_nothing_returned",
"-Wclippy::single_match_else",
"-Wclippy::string_add_assign",
"-Wclippy::string_add",
"-Wclippy::string_lit_as_bytes",
"-Wclippy::string_to_string",
"-Wclippy::todo",
"-Wclippy::trait_duplication_in_bounds",
"-Wclippy::unimplemented",
"-Wclippy::unnested_or_patterns",
"-Wclippy::unused_self",
"-Wclippy::useless_transmute",
"-Wclippy::verbose_file_reads",
"-Wclippy::zero_sized_map_values",
"-Wfuture_incompatible",
"-Wnonstandard_style",
"-Wrust_2018_idioms",
# END - Embark standard lints v6 for Rust 1.55+
]
31 changes: 12 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,33 @@ name: CI
jobs:
lint:
name: Lint
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
components: "clippy, rustfmt"

# make sure all code has been formatted with rustfmt
- run: rustup component add rustfmt
- name: check rustfmt
run: cargo fmt -- --check --color always

# run clippy to verify we have no warnings
- run: cargo fetch
- run: rustup component add clippy
- name: cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings

test:
name: Test
strategy:
matrix:
toolchain: [1.54, stable]
runs-on: ubuntu-20.04
toolchain: [1.58.0, stable]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
override: true
- run: cargo fetch
- name: cargo test build
run: cargo build --tests --release
Expand All @@ -55,20 +51,17 @@ jobs:

deny-check:
name: cargo-deny
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1

publish-check:
name: Publish Check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo fetch
- name: cargo publish check
run: cargo publish --dry-run
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Changed
- [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) updated the builtin target list to 1.64.0. Thanks [@sunshowers](https://github.com/sunshowers)!
- [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) bumped the MSRV to 1.58.0.

## [0.10.3] - 2022-05-19
### Added
- [PR#49](https://github.com/EmbarkStudios/cfg-expr/pull/49) added support for the `has_target_atomic = "<ptr | integer>"` and `panic = "<strategy>"` predicates. Thanks [@sunshowers](https://github.com/sunshowers)!
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ authors = [
"Embark <opensource@embark-studios.com>",
"Jake Shadle <jake.shadle@embark-studios.com>",
]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
rust-version = "1.58.0"
documentation = "https://docs.rs/cfg-expr"
homepage = "https://github.com/EmbarkStudios/cfg-expr"
keywords = ["cargo", "rustc", "cfg"]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
[![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.54.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2021/07/29/Rust-1.54.0.html)
[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.58.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html)
[![Minimum Stable Rust Version](https://img.shields.io/badge/Rust%20MSRV-1.58.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html)
[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.64.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 Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
msrv = "1.52"
msrv = "1.58.0"
avoid-breaking-exported-api = false
18 changes: 9 additions & 9 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{error::Error, fmt};

/// An error related to parsing of a cfg expression
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct ParseError {
/// The string that was parsed
pub original: String,
Expand All @@ -13,7 +13,7 @@ pub struct ParseError {
}

/// The particular reason for a `ParseError`
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum Reason {
/// not() takes exactly 1 predicate, unlike all() and any()
InvalidNot(usize),
Expand Down Expand Up @@ -54,18 +54,18 @@ impl fmt::Display for ParseError {
// Mismatched parens/quotes have a slightly different output
// than the other errors
match &self.reason {
r @ Reason::UnclosedParens | r @ Reason::UnclosedQuotes => {
f.write_fmt(format_args!("- {}", r))
r @ (Reason::UnclosedParens | Reason::UnclosedQuotes) => {
f.write_fmt(format_args!("- {r}"))
}
r @ Reason::UnopenedParens | r @ Reason::UnopenedQuotes => {
f.write_fmt(format_args!("^ {}", r))
r @ (Reason::UnopenedParens | Reason::UnopenedQuotes) => {
f.write_fmt(format_args!("^ {r}"))
}
other => {
for _ in self.span.start..self.span.end {
f.write_str("^")?;
}

f.write_fmt(format_args!(" {}", other))
f.write_fmt(format_args!(" {other}"))
}
}
}
Expand All @@ -91,7 +91,7 @@ impl fmt::Display for Reason {
f.write_str("expected one of ")?;

for (i, exp) in expected.iter().enumerate() {
f.write_fmt(format_args!("{}`{}`", if i > 0 { ", " } else { "" }, exp))?;
f.write_fmt(format_args!("{}`{exp}`", if i > 0 { ", " } else { "" }))?;
}
f.write_str(" here")
} else if !expected.is_empty() {
Expand All @@ -100,7 +100,7 @@ impl fmt::Display for Reason {
f.write_str("the term was not expected here")
}
}
InvalidNot(np) => f.write_fmt(format_args!("not() takes 1 predicate, found {}", np)),
InvalidNot(np) => f.write_fmt(format_args!("not() takes 1 predicate, found {np}")),
InvalidInteger => f.write_str("invalid integer"),
MultipleRootPredicates => f.write_str("multiple root predicates"),
InvalidHasAtomic => f.write_str("expected integer or \"ptr\""),
Expand Down
14 changes: 8 additions & 6 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum Func {
use crate::targets as targ;

/// All predicates that pertains to a target, except for `target_feature`
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum TargetPredicate {
/// [target_arch](https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch)
Arch(targ::Arch),
Expand Down Expand Up @@ -136,13 +136,15 @@ impl TargetMatcher for target_lexicon::Triple {
OperatingSystem::Redox => env == &targ::Env::relibc,
OperatingSystem::VxWorks => env == &targ::Env::gnu,
OperatingSystem::Freebsd => match self.architecture {
Architecture::Arm(ArmArchitecture::Armv6)
| Architecture::Arm(ArmArchitecture::Armv7) => env == &targ::Env::gnueabihf,
Architecture::Arm(ArmArchitecture::Armv6 | ArmArchitecture::Armv7) => {
env == &targ::Env::gnueabihf
}
_ => env.0.is_empty(),
},
OperatingSystem::Netbsd => match self.architecture {
Architecture::Arm(ArmArchitecture::Armv6)
| Architecture::Arm(ArmArchitecture::Armv7) => env == &targ::Env::eabihf,
Architecture::Arm(ArmArchitecture::Armv6 | ArmArchitecture::Armv7) => {
env == &targ::Env::eabihf
}
_ => env.0.is_empty(),
},
OperatingSystem::None_
Expand Down Expand Up @@ -372,7 +374,7 @@ pub(crate) struct InnerTarget {
}

/// A single predicate in a `cfg()` expression
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum Predicate<'a> {
/// A target predicate, with the `target_` prefix
Target(TargetPredicate),
Expand Down
Loading

0 comments on commit 266b620

Please sign in to comment.