diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 774265c..7dd6147 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,11 @@ defaults: env: CC: clang CC_LD: lld + CI_CARGO_ARGS: >- + --all-features + --all-targets + --verbose + --workspace CI_MESON_ARGS: >- --buildtype debugoptimized --warnlevel 2 @@ -68,7 +73,7 @@ jobs: uses: actions/checkout@v4 - name: "Run Analyzer" - run: cargo check --all-targets --features libc --verbose --workspace + run: cargo check ${CI_CARGO_ARGS} # # A complete but basic build of the project, running on common x86-64 ubuntu @@ -89,7 +94,7 @@ jobs: uses: actions/checkout@v4 - name: "Build and Test" - run: cargo test --all-targets --features libc --verbose --workspace + run: cargo test ${CI_CARGO_ARGS} # # A simple no-op job that serves as guard. All extended jobs depend on this @@ -124,7 +129,7 @@ jobs: uses: actions/checkout@v4 - name: "Build and Test" - run: cargo test --all-targets --features libc --verbose --workspace + run: cargo test ${CI_CARGO_ARGS} # # A matrix of project builds with different settings. All builds run the @@ -146,8 +151,8 @@ jobs: # Explicitly set all options here to document them. cargoargs: >- + --all-features --all-targets - --features libc --profile=release image: "ghcr.io/readaheadeu/rae-ci-archlinux:latest" toolchain: stable @@ -157,15 +162,32 @@ jobs: name: "Ubuntu-x86_64-nightly-release" cargoargs: >- + --all-features --all-targets - --features libc --profile=release image: "ghcr.io/readaheadeu/rae-ci-ubuntu:latest" toolchain: nightly + # Test a nightly build with polonius, verifying the code that works + # around deficiencies of non-polonius builds. + - id: "polonius" + name: "Ubuntu-x86_64-nightly-polonius" + + cargoargs: >- + --all-features + --all-targets + --profile=release + image: "ghcr.io/readaheadeu/rae-ci-ubuntu:latest" + rustflags: >- + --cfg polonius + -Z polonius=next + toolchain: nightly + container: image: ${{ matrix.image }} options: "--user root" + env: + RUSTFLAGS: ${{ matrix.rustflags }} runs-on: "ubuntu-latest" steps: @@ -201,14 +223,7 @@ jobs: uses: actions/checkout@v4 - name: "Build and Test" - run: | - cargo \ - test \ - --all-targets \ - --features libc \ - --target i686-unknown-linux-gnu \ - --verbose \ - --workspace + run: cargo test ${CI_CARGO_ARGS} --target i686-unknown-linux-gnu # # A development build using the meson build system. @@ -234,3 +249,27 @@ jobs: - name: "Run Tests" run: meson test -C "./build" + + # + # A development build using the MSRV. To avoid updating our own container + # images with that version all the time, use the official images for it. + # This means, we cannot rely on any other utilities to be present, so just + # run a straight cargo build. + # + ext_msrv: + name: "Ext: msrv @ rust:" + needs: ext_guard + + container: + image: "rust:1.91-alpine" + defaults: + run: + shell: "sh" + runs-on: "ubuntu-latest" + + steps: + - name: "Fetch Sources" + uses: actions/checkout@v4 + + - name: "Build and Test" + run: cargo test ${CI_CARGO_ARGS} diff --git a/Cargo.toml b/Cargo.toml index a2fc591..344c95e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,10 +22,16 @@ homepage = "https://www.bus1.eu" license = "MIT OR Apache-2.0 OR LGPL-2.1-or-later" readme = "README.md" repository = "https://github.com/bus1/sys" -rust-version = "1.84" +rust-version = "1.91" [workspace.dependencies] libc = { default-features = false, version = "0.2.175" } osi = { path = "./lib/osi", version = "1.0.0" } sys = { path = "./lib/sys", version = "1.0.0" } tmp = { path = "./lib/tmp", version = "1.0.0" } + +[workspace.lints.rust.unexpected_cfgs] +level = "warn" +check-cfg = [ + "cfg(polonius)" +] diff --git a/README.md b/README.md index 24858fc..523e19d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ system specific interfaces. The requirements for this project are: - * `rustc >= 1.83` + * `rustc >= 1.91` ### Repository: diff --git a/lib/osi/Cargo.toml b/lib/osi/Cargo.toml index b309f22..fa7d550 100644 --- a/lib/osi/Cargo.toml +++ b/lib/osi/Cargo.toml @@ -21,3 +21,6 @@ rust-version.workspace = true [features] std = [] + +[lints] +workspace = true diff --git a/lib/sys/Cargo.toml b/lib/sys/Cargo.toml index 401d0d1..96d54c5 100644 --- a/lib/sys/Cargo.toml +++ b/lib/sys/Cargo.toml @@ -20,8 +20,12 @@ repository.workspace = true rust-version.workspace = true [features] +libc = ["dep:libc"] std = [] [dependencies] libc = { optional = true, workspace = true } osi = { workspace = true } + +[lints] +workspace = true diff --git a/lib/tmp/Cargo.toml b/lib/tmp/Cargo.toml index 0ac46f6..9991809 100644 --- a/lib/tmp/Cargo.toml +++ b/lib/tmp/Cargo.toml @@ -19,9 +19,9 @@ readme.workspace = true repository.workspace = true rust-version.workspace = true -[features] -polonius = [] - [dependencies] osi = { workspace = true } sys = { workspace = true } + +[lints] +workspace = true diff --git a/lib/tmp/src/fmt/json/token.rs b/lib/tmp/src/fmt/json/token.rs index d98d892..ea2e0c7 100644 --- a/lib/tmp/src/fmt/json/token.rs +++ b/lib/tmp/src/fmt/json/token.rs @@ -828,7 +828,7 @@ impl<'read> Dec<'read> { // correctness of Polonius. let fixed = { osi::cfg::cond! { - (feature = "polonius") { v }, + (polonius) { v }, { // SAFETY: Workaround for NLL, unneeded with Polonius. unsafe { core::mem::transmute(v) } diff --git a/meson.build b/meson.build index 83ad27f..bdfc644 100644 --- a/meson.build +++ b/meson.build @@ -15,7 +15,7 @@ project( add_languages('rust', native: false) rust_edition = '2021' -rust_msv = '1.74' +rust_msv = '1.91' mod_rust = import('rust') rust = meson.get_compiler('rust') @@ -92,11 +92,21 @@ endif use_std = get_option('std') +# +# Global configuration +# + +rlib_rust_args = [ + '--check-cfg=cfg(feature, values("libc", "std"))', + '--check-cfg=cfg(polonius)', + '--check-cfg=cfg(test)', +] + # # Target: libosi # -libosi_rlib_rust_args = [] +libosi_rlib_rust_args = rlib_rust_args if use_std libosi_rlib_rust_args += ['--cfg=feature="std"'] @@ -120,7 +130,7 @@ meson.override_dependency('libosi-' + libosi_major, libosi_dep, static: true) # libsys_rlib_deps = [libosi_dep] -libsys_rlib_rust_args = [] +libsys_rlib_rust_args = rlib_rust_args if use_libc libsys_rlib_deps += [dep_libc] @@ -150,20 +160,18 @@ meson.override_dependency('libsys-' + libsys_major, libsys_dep, static: true) # Target: libtmp # +libtmp_rlib_deps = [libosi_dep, libsys_dep] +libtmp_rlib_rust_args = rlib_rust_args + libtmp_rlib = static_library( 'tmp', ['lib/tmp/src/lib.rs'], - dependencies: [ - libosi_dep, - libsys_dep, - ], + dependencies: libtmp_rlib_deps, + rust_args: libtmp_rlib_rust_args, ) libtmp_dep = declare_dependency( - dependencies: [ - libosi_dep, - libsys_dep, - ], + dependencies: libtmp_rlib_deps, link_with: libtmp_rlib, version: libtmp_version, )