diff --git a/.github/workflows/github-cxx-qt-tests.yml b/.github/workflows/github-cxx-qt-tests.yml index 6a2d8dbb9..5f92b50ea 100644 --- a/.github/workflows/github-cxx-qt-tests.yml +++ b/.github/workflows/github-cxx-qt-tests.yml @@ -42,6 +42,7 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 + - run: rustup default 1.77.2 - run: rustup component add rustfmt - run: cargo fmt --all --check --verbose @@ -72,8 +73,9 @@ jobs: uses: actions/checkout@v4 - name: Setup toolchain run: | + rustup default 1.77.2 cargo install grcov - rustup component add llvm-tools + rustup component add llvm-tools rustfmt - name: build env: RUSTFLAGS: -Cinstrument-coverage @@ -106,7 +108,8 @@ jobs: uses: actions/checkout@v4 - name: Setup toolchain run: | - rustup component add clippy rustfmt + rustup default 1.77.2 + rustup component add rustfmt rustup target add wasm32-unknown-emscripten - name: "Rust tools cache" uses: actions/cache@v4 @@ -116,13 +119,14 @@ jobs: ~/.cargo/bin/sccache ~/.cargo/bin/mdbook ~/.cargo/bin/mdbook-linkcheck - key: ubuntu-24.04_sccache-0.7.6_mdbook-0.4.36_mdbook-linkcheck-0.7.7 + key: ubuntu-24.04_sccache-0.8.2_mdbook-0.4.36_mdbook-linkcheck-0.7.7 - name: "Build Rust tools" if: steps.rust-tools-cache.outputs.cache-hit != 'true' # Do not build with storage backends enabled, we only need local run: | - cargo install --no-default-features sccache - cargo install mdbook mdbook-linkcheck + cargo install --no-default-features --version 0.8.2 sccache + cargo install --version 0.4.36 mdbook + cargo install --version 0.7.7 mdbook-linkcheck # We want our compiler cache to always update to the newest state. # The best way for us to achieve this is to **always** update the cache after every landed commit. # That way it will closely follow our development. @@ -366,10 +370,14 @@ jobs: - name: "Clone Git repository" uses: actions/checkout@v4 # Ensure clippy and rustfmt is installed, they should come from github runner + # clippy version needs to be 1.78.0 for the MSRV lint # # Note we still need rustfmt for the cxx-qt-gen tests - name: "Install Rust toolchain" - run: rustup component add clippy rustfmt + run: | + rustup toolchain add 1.78.0 --component clippy + rustup default 1.77.2 + rustup component add rustfmt - name: "Rust tools cache" uses: actions/cache@v4 @@ -379,13 +387,14 @@ jobs: ${{ matrix.cargo_dir }}/bin/sccache${{ matrix.exe_suffix }} ${{ matrix.cargo_dir }}/bin/mdbook${{ matrix.exe_suffix }} ${{ matrix.cargo_dir }}/bin/mdbook-linkcheck${{ matrix.exe_suffix }} - key: ${{ matrix.os }}_sccache-0.7.6_mdbook-0.4.36_mdbook-linkcheck-0.7.7 + key: ${{ matrix.os }}_sccache-0.8.2_mdbook-0.4.36_mdbook-linkcheck-0.7.7 - name: "Build Rust tools" if: steps.rust-tools-cache.outputs.cache-hit != 'true' # Do not build with storage backends enabled, we only need local run: | - cargo install --no-default-features sccache - cargo install mdbook mdbook-linkcheck + cargo install --no-default-features --version 0.8.2 sccache + cargo install --version 0.4.36 mdbook + cargo install --version 0.7.7 mdbook-linkcheck # We want our compiler cache to always update to the newest state. # The best way for us to achieve this is to **always** update the cache after every landed commit. diff --git a/CMakeLists.txt b/CMakeLists.txt index 144b4fb43..f02c4d743 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,8 +151,9 @@ if(BUILD_TESTING) # Add CMake tests for `cargo test/clippy/fmt/doc`. add_test(NAME cargo_tests COMMAND cargo test --release --all-features --target-dir ${CARGO_TARGET_DIR}) add_test(NAME cargo_doc COMMAND cargo doc --release --all-features --target-dir ${CARGO_TARGET_DIR}) - add_test(NAME cargo_clippy COMMAND cargo clippy --release --all-features --target-dir ${CARGO_TARGET_DIR} -- -D warnings) - + # Minimum clippy version for the incompatible_msrv lint is 1.78.0 + add_test(NAME cargo_clippy COMMAND cargo +1.78.0 clippy --release --all-features --target-dir ${CARGO_TARGET_DIR} -- -D warnings) + set_tests_properties(cargo_tests cargo_clippy PROPERTIES ENVIRONMENT_MODIFICATION "${CARGO_ENV}" ) diff --git a/Cargo.toml b/Cargo.toml index 4989a8ce9..c6a11c463 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/KDAB/cxx-qt/" version = "0.7.0" +rust-version = "1.77.2" # Clippy needs to >= 1.78.0 for a lint, but the package can be 1.77.2 # Note a version needs to be specified on dependencies of packages # we publish, otherwise crates.io complains as it doesn't know the version. @@ -55,3 +56,6 @@ syn = { version = "2.0", features = ["extra-traits", "full"] } quote = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" + +[workspace.lints.clippy] +incompatible_msrv = "deny" \ No newline at end of file diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 000000000..9b5e33650 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +# SPDX-FileContributor: Ben Ford +# +# SPDX-License-Identifier: MIT OR Apache-2.0 + +# This is higher than the rust-version because the `incompatible_msrv` lint was introduced in clippy 1.78.0 +msrv = "1.78.0" diff --git a/crates/cxx-qt-build/Cargo.toml b/crates/cxx-qt-build/Cargo.toml index 448fe2938..618b37fea 100644 --- a/crates/cxx-qt-build/Cargo.toml +++ b/crates/cxx-qt-build/Cargo.toml @@ -11,6 +11,7 @@ edition.workspace = true license.workspace = true description = "Helpers for integrating `cxx-qt` crate into a Cargo build" repository.workspace = true +rust-version.workspace = true [dependencies] cc.workspace = true @@ -26,3 +27,6 @@ serde_json = "1.0" [features] link_qt_object_files = ["qt-build-utils/link_qt_object_files"] + +[lints] +workspace = true diff --git a/crates/cxx-qt-build/src/lib.rs b/crates/cxx-qt-build/src/lib.rs index 26c5912f2..eebb5f789 100644 --- a/crates/cxx-qt-build/src/lib.rs +++ b/crates/cxx-qt-build/src/lib.rs @@ -370,7 +370,7 @@ impl CxxQtBuilder { qt_modules.extend( modules // Each module is split by a comma - .split(",") + .split(',') // Each module could be Qt::Core or Qt6::Core etc // we only want the last part .map(|module| { diff --git a/crates/cxx-qt-gen/Cargo.toml b/crates/cxx-qt-gen/Cargo.toml index cfee6404b..1b33cce8e 100644 --- a/crates/cxx-qt-gen/Cargo.toml +++ b/crates/cxx-qt-gen/Cargo.toml @@ -17,6 +17,7 @@ license.workspace = true description = "Code generation for integrating `cxx-qt` into higher level tools" repository.workspace = true exclude = ["update_expected.sh"] +rust-version = "1.64.0" [dependencies] proc-macro2.workspace = true @@ -28,3 +29,6 @@ indoc = "2.0" [dev-dependencies] pretty_assertions = "1.2" + +[lints] +workspace = true diff --git a/crates/cxx-qt-lib-extras/Cargo.toml b/crates/cxx-qt-lib-extras/Cargo.toml index 1782d1c87..3319c80af 100644 --- a/crates/cxx-qt-lib-extras/Cargo.toml +++ b/crates/cxx-qt-lib-extras/Cargo.toml @@ -10,8 +10,8 @@ edition.workspace = true license.workspace = true description = "Extra Qt types for integrating `cxx-qt` crate with `cxx` that are not available in `cxx-qt-lib`" repository.workspace = true - links = "cxx-qt-lib-extras" +rust-version.workspace = true [dependencies] cxx.workspace = true @@ -24,3 +24,6 @@ cxx-qt-build.workspace = true [features] default = [] link_qt_object_files = ["cxx-qt-build/link_qt_object_files"] + +[lints] +workspace = true diff --git a/crates/cxx-qt-lib/Cargo.toml b/crates/cxx-qt-lib/Cargo.toml index 34546a676..e59bd23fb 100644 --- a/crates/cxx-qt-lib/Cargo.toml +++ b/crates/cxx-qt-lib/Cargo.toml @@ -18,6 +18,7 @@ exclude = [ "**/generate.sh" ] # can pass metadata from library to dependent. # See also: https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key links = "cxx-qt-lib" +rust-version.workspace = true [dependencies] cxx.workspace = true @@ -51,3 +52,6 @@ time = ["dep:time"] url = ["dep:url"] serde = ["dep:serde"] link_qt_object_files = ["cxx-qt-build/link_qt_object_files"] + +[lints] +workspace = true diff --git a/crates/cxx-qt-macro/Cargo.toml b/crates/cxx-qt-macro/Cargo.toml index bddb6a334..5437522cd 100644 --- a/crates/cxx-qt-macro/Cargo.toml +++ b/crates/cxx-qt-macro/Cargo.toml @@ -13,6 +13,7 @@ license.workspace = true description = "A set of macros for Qt/C++ interop in Rust" repository.workspace = true homepage = "https://kdab.github.io/cxx-qt/book/" +rust-version.workspace = true [lib] proc-macro = true @@ -25,3 +26,6 @@ syn.workspace = true [dev-dependencies] cxx.workspace = true cxx-qt.workspace = true + +[lints] +workspace = true diff --git a/crates/cxx-qt/Cargo.toml b/crates/cxx-qt/Cargo.toml index 3b06a6f71..009649c1c 100644 --- a/crates/cxx-qt/Cargo.toml +++ b/crates/cxx-qt/Cargo.toml @@ -16,6 +16,7 @@ homepage = "https://kdab.github.io/cxx-qt/book/" readme = "README.md" keywords = ["cxx", "ffi", "QML", "Qt"] categories = ["api-bindings", "gui"] +rust-version.workspace = true # When creating a library with cxx-qt-build, we need to set a fake "links" key # to make sure the build scripts are run in the correct order and the build scripts @@ -34,3 +35,6 @@ qt-build-utils.workspace = true [dev-dependencies] cxx.workspace = true + +[lints] +workspace = true diff --git a/crates/qt-build-utils/Cargo.toml b/crates/qt-build-utils/Cargo.toml index 93c615942..c27f981e3 100644 --- a/crates/qt-build-utils/Cargo.toml +++ b/crates/qt-build-utils/Cargo.toml @@ -11,6 +11,7 @@ authors = ["Be Wilson "] license.workspace = true description = "Build script helper for linking Qt libraries and using moc code generator. Intended to be used together with cc, cpp_build, or cxx_build" repository.workspace = true +rust-version.workspace = true [dependencies] cc.workspace = true @@ -29,3 +30,6 @@ thiserror = "1.0" # # When linking Qt dynamically, this makes no difference. link_qt_object_files = [] + +[lints] +workspace = true