Skip to content

Commit bebb783

Browse files
bors[bot]Bromeon
andauthored
Merge #890
890: Add cargo-machete and remove unnecessary dependencies 🔪 r=Bromeon a=Bromeon [**cargo-machete**](https://github.com/bnjbvr/cargo-machete) is a tool designed to detect unnecessary dependencies in Rust crates. Having a similar goal as cargo-udep, it chooses some different trade-offs, which are explained in the [blog post](https://blog.benj.me/2022/04/27/cargo-machete/). In godot-rust, machete detected _**6 cases**_ of unnecessary dependencies (of which 2 are between internal crates). I automated checks via CI action, which runs in less than a second -- most time is spent on `cargo install`, which is cached when possible. I needed to highlight one false positive (`libc`), which is fortunately a well-supported feature of machete. With the amount of proc-macros and code generation we deal with, I was surprised it wasn't more. This addition should help us detect dependencies which are no longer needed, and slightly reduce initial compile time. It won't have a big effect on incremental compilation. We may need to monitor in the coming weeks if the removed dependencies cause issues in one way or another -- that would however also highlight a lack of coverage in our CI pipeline. bors try Co-authored-by: Jan Haller <[email protected]>
2 parents a34e43f + 84c99b1 commit bebb783

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

.github/workflows/full-ci.yml

+18-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ env:
3333
# Local variables
3434
# Note: using variables is limited at the moment, see https://github.com/actions/runner/issues/480
3535
GDRUST_FEATURES: "gdnative/async,gdnative/serde,gdnative_bindings_generator/debug"
36-
CARGO_DENY_VERSION: "0.11.0"
37-
CARGO_DINGHY_VERSION: "0.4.68"
36+
CARGO_DENY_VERSION: "0.11.4"
37+
CARGO_DINGHY_VERSION: "0.4.71"
38+
CARGO_MACHETE_VERSION: "0.3"
3839

3940
on:
4041
push:
@@ -80,21 +81,33 @@ jobs:
8081
- name: "Check clippy"
8182
run: cargo clippy --workspace --features ${GDRUST_FEATURES} -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
8283

83-
cargo-deny:
84+
cargo-deny-machete:
8485
runs-on: ubuntu-latest
8586
needs: rustfmt
8687
steps:
8788
- uses: actions/checkout@v2
89+
90+
# Deny
8891
# Note: manually downloading is ~30s faster than https://github.com/EmbarkStudios/cargo-deny-action
8992
- name: "Install cargo-deny"
9093
run: |
9194
wget --no-verbose https://github.com/EmbarkStudios/cargo-deny/releases/download/$CARGO_DENY_VERSION/cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl.tar.gz -O cargo-deny.tar.gz
9295
tar -zxvf cargo-deny.tar.gz
9396
mkdir -p $HOME/.cargo/bin
9497
mv cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl/cargo-deny $HOME/.cargo/bin
95-
- name: "Check cargo-deny"
98+
- name: "Deny non-conforming dependencies"
9699
run: cargo deny check --config tools/deny.toml
97100

101+
# Machete
102+
- name: "Install cargo-machete"
103+
uses: baptiste0928/cargo-install@v1
104+
with:
105+
crate: cargo-machete
106+
version: ${{ env.CARGO_MACHETE_VERSION }}
107+
- name: "Use machete to cut down dependencies"
108+
run: cargo machete
109+
110+
98111
test:
99112
name: test-${{ matrix.os.name }}${{ matrix.rust.postfix }}
100113
needs: rustfmt
@@ -285,7 +298,7 @@ jobs:
285298
needs:
286299
#- rustfmt
287300
- clippy
288-
- cargo-deny
301+
- cargo-deny-machete
289302
- test
290303
- integration-test-godot
291304
- build-release

bindings-generator/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ custom-godot = ["which"]
1717

1818
[dependencies]
1919
heck = "0.4"
20-
memchr = "2"
2120
miniserde = "0.1.16"
2221
proc-macro2 = "1"
2322
quote = "1"

gdnative-async/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ gdnative-core = { path = "../gdnative-core", version = "=0.10.0" }
1919
gdnative-bindings = { path = "../gdnative-bindings", version = "=0.10.0" }
2020
atomic-waker = "1"
2121
crossbeam-channel = "0.5"
22-
crossbeam-utils = "0.8"
2322
futures-task = "0.3"
2423
once_cell = "1"
2524
parking_lot = "0.12"

gdnative-bindings/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ one-class-one-file = []
1717
custom-godot = ["gdnative_bindings_generator/custom-godot"]
1818

1919
[dependencies]
20-
gdnative-sys = { path = "../gdnative-sys", version = "=0.10.0" }
2120
gdnative-core = { path = "../gdnative-core", version = "=0.10.0" }
22-
bitflags = "1"
2321
libc = "0.2"
2422

2523
[build-dependencies]

gdnative-sys/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ proc-macro2 = "1"
2121
quote = "1"
2222
miniserde = "0.1.16"
2323
semver = "1"
24+
25+
# False positives found by cargo-machete
26+
[package.metadata.cargo-machete]
27+
ignored = ["libc"]

test/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ custom-godot = ["gdnative/custom-godot"]
1717

1818
[dependencies]
1919
gdnative = { path = "../gdnative", features = ["gd-test", "serde", "async"] }
20-
gdnative-derive = { path = "../gdnative-derive" }
2120
approx = "0.5"
2221
ron = "0.7"
2322
serde = "1"
@@ -26,4 +25,3 @@ bincode = "1"
2625
serde_yaml = "0.8.23"
2726
rmp-serde = "1"
2827
futures = "0.3"
29-
once_cell = "1"

0 commit comments

Comments
 (0)