Skip to content

Commit 9999441

Browse files
committed
Slim down published binary
1 parent 6b2ee5d commit 9999441

File tree

2 files changed

+53
-27
lines changed

2 files changed

+53
-27
lines changed

Cargo.toml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,27 @@ name = "git-x"
2323
path = "src/main.rs"
2424

2525
[dependencies]
26-
clap = { version = "4.5", features = ["derive"] }
27-
console = "0.16"
28-
chrono = "0.4"
29-
dialoguer = { version = "0.11", features = ["fuzzy-select"] }
30-
fuzzy-matcher = "0.3"
31-
atty = "0.2"
32-
indicatif = "0.18"
33-
tokio = { version = "1.40", features = ["rt-multi-thread", "process", "macros"] }
34-
futures = "0.3"
35-
rayon = "1.8"
26+
clap = { version = "4.5", features = ["derive", "std", "help", "usage", "error-context"], default-features = false }
27+
console = { version = "0.16", default-features = false }
28+
chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }
29+
dialoguer = { version = "0.11", features = ["fuzzy-select"], default-features = false }
30+
fuzzy-matcher = { version = "0.3", default-features = false }
31+
atty = { version = "0.2", default-features = false }
32+
indicatif = { version = "0.18", default-features = false }
33+
tokio = { version = "1.40", features = ["rt-multi-thread", "process", "macros"], default-features = false }
34+
futures = { version = "0.3", default-features = false, features = ["std"] }
35+
rayon = { version = "1.8", default-features = false }
3636

3737
[dev-dependencies]
3838
assert_cmd = "2.0"
3939
tempfile = "3.20"
4040
predicates = "3.1"
4141
serial_test = "3.0"
42+
43+
# Performance-optimized release profile
44+
[profile.release]
45+
opt-level = 3
46+
lto = "thin"
47+
codegen-units = 16
48+
panic = "abort"
49+
strip = true

Makefile

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
BINARY_NAME = git-x
44
CARGO = cargo
55

6-
.PHONY: all build ci run test coverage install uninstall fmt fmt-check lint lint-check clean publish help
6+
.PHONY: all build ci run test coverage install uninstall fmt fmt-check lint lint-check clean publish help publish-optimized analyze-size
77

88
## Build and run the project (default)
99
all: run
@@ -55,27 +55,45 @@ uninstall:
5555
clean:
5656
$(CARGO) clean
5757

58-
## Publish to crates.io
58+
## Analyze binary size and dependencies
59+
analyze-size: build
60+
@echo "=== Performance-Optimized Binary Analysis ==="
61+
@ls -lh target/release/$(BINARY_NAME)
62+
@echo ""
63+
@echo "=== Crate Size Breakdown ==="
64+
$(CARGO) bloat --release --crates
65+
@echo ""
66+
@echo "=== Top Functions ==="
67+
$(CARGO) bloat --release -n 10
68+
69+
## Publish optimized binary to crates.io
70+
publish-optimized: build test
71+
$(CARGO) publish
72+
73+
## Publish to crates.io (standard)
5974
publish:
6075
$(CARGO) publish
6176

6277
## Show this help message
6378
help:
6479
@echo ""
6580
@echo "git-x Makefile — available targets:"
66-
@echo " make Build and run (default)"
67-
@echo " make build Build release binary"
68-
@echo " make run Run binary with ARGS=\"xinfo\""
69-
@echo " make test Run tests"
70-
@echo " make coverage Generate test coverage report"
71-
@echo " make fmt Format code"
72-
@echo " make fmt-check Check formatting"
73-
@echo " make lint Lint with Clippy"
74-
@echo " make lint-check Check for linting issues"
75-
@echo " make install Install to ~/.cargo/bin as 'git-x'"
76-
@echo " make uninstall Uninstall binary"
77-
@echo " make clean Remove build artifacts"
78-
@echo " make publish Publish to crates.io"
79-
@echo " make help Show this help message"
80-
@echo " make ci Run CI checks (formatting, linting, tests)"
81+
@echo " make Build and run (default)"
82+
@echo " make build Build release binary"
83+
@echo " make run Run binary with ARGS=\"info\""
84+
@echo " make test Run tests"
85+
@echo " make coverage Generate test coverage report"
86+
@echo " make fmt Format code"
87+
@echo " make fmt-check Check formatting"
88+
@echo " make lint Lint with Clippy"
89+
@echo " make lint-check Check for linting issues"
90+
@echo " make install Install to ~/.cargo/bin as 'git-x'"
91+
@echo " make uninstall Uninstall binary"
92+
@echo " make clean Remove build artifacts"
93+
@echo " make ci Run CI checks (formatting, linting, tests)"
94+
@echo ""
95+
@echo "Optimization Targets:"
96+
@echo " make analyze-size Analyze binary size and dependencies"
97+
@echo " make publish-optimized Publish optimized binary to crates.io"
98+
@echo " make publish Publish to crates.io (standard)"
8199
@echo ""

0 commit comments

Comments
 (0)