.PHONY: help build build-release build-pgo test clean install benchmark lint format check-deps coverage security advanced-build sccache-setup upx-install
help:
@echo "vx - Universal Development Tool Manager"
@echo ""
@echo "Available targets:"
@echo " build - Build debug version"
@echo " build-release - Build release version"
@echo " build-pgo - Build with Profile-Guided Optimization"
@echo " test - Run all tests"
@echo " coverage - Generate code coverage report"
@echo " security - Run security audit"
@echo " clean - Clean build artifacts"
@echo " install - Install to system"
@echo " benchmark - Run performance benchmarks"
@echo " lint - Run linting checks"
@echo " lint-fix - Fix clippy warnings automatically"
@echo " lint-strict - Run strict linting with pedantic rules"
@echo " format - Format code"
@echo " check-deps - Check for dependency updates"
@echo ""
@echo "PGO targets:"
@echo " pgo-clean - Clean PGO data and rebuild"
@echo " pgo-verbose - Build PGO with verbose output"
@echo " test-pgo - Test PGO optimization effectiveness"
@echo ""
@echo "GoReleaser targets:"
@echo " goreleaser-test - Test GoReleaser configuration"
@echo " goreleaser-snapshot - Create snapshot build"
@echo " goreleaser-release - Create PGO-optimized release"
@echo ""
@echo "Advanced optimization targets:"
@echo " advanced-build - Build with all optimizations"
@echo " sccache-setup - Install and configure sccache"
@echo " upx-install - Install UPX compression tool"
@echo " build-matrix - Build for multiple targets"
@echo " build-optimized - Build with UPX and stripping"
build:
@echo "๐จ Building debug version..."
cargo build
build-release:
@echo "๐ Building release version..."
CARGO_INCREMENTAL=1 cargo build --release
build-fast:
@echo "โก Building with fast profile..."
cargo build --profile dev-fast
build-parallel:
@echo "โก Building with maximum parallelization..."
CARGO_INCREMENTAL=1 RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo build --release
build-pgo:
@echo "๐ฏ Building with Profile-Guided Optimization..."
ifeq ($(OS),Windows_NT)
@powershell -ExecutionPolicy Bypass -File scripts/build-pgo.ps1
else
@chmod +x scripts/build-pgo.sh
@./scripts/build-pgo.sh
endif
pgo-clean:
@echo "๐งน Cleaning and rebuilding with PGO..."
ifeq ($(OS),Windows_NT)
@powershell -ExecutionPolicy Bypass -File scripts/build-pgo.ps1 -Clean
else
@chmod +x scripts/build-pgo.sh
@./scripts/build-pgo.sh --clean
endif
pgo-verbose:
@echo "๐ฏ Building PGO with verbose output..."
ifeq ($(OS),Windows_NT)
@powershell -ExecutionPolicy Bypass -File scripts/build-pgo.ps1 -Verbose
else
@chmod +x scripts/build-pgo.sh
@./scripts/build-pgo.sh --verbose
endif
test:
@echo "๐งช Running tests..."
cargo test
test-verbose:
@echo "๐งช Running tests with verbose output..."
cargo test -- --nocapture
coverage:
@echo "๐ Generating code coverage report..."
@echo "Installing cargo-llvm-cov if not present..."
@cargo install cargo-llvm-cov --quiet || true
@echo "Generating coverage..."
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
@echo "Coverage report generated: lcov.info"
coverage-html:
@echo "๐ Generating HTML coverage report..."
@echo "Installing cargo-llvm-cov if not present..."
@cargo install cargo-llvm-cov --quiet || true
@echo "Generating HTML coverage..."
cargo llvm-cov --all-features --workspace --html
@echo "HTML coverage report generated in target/llvm-cov/html/"
security:
@echo "๐ Running security audit..."
@echo "Installing cargo-audit if not present..."
@cargo install cargo-audit --quiet || true
@echo "Running audit..."
cargo audit
clean:
@echo "๐งน Cleaning build artifacts..."
cargo clean
rm -rf pgo-data
install:
@echo "๐ฆ Installing vx..."
cargo install --path .
lint:
@echo "๐ Running linting checks..."
cargo clippy --all-targets --all-features -- -D warnings
lint-fix:
@echo "๐ง Fixing clippy warnings..."
@chmod +x scripts/fix-clippy.sh
@./scripts/fix-clippy.sh --fix
lint-strict:
@echo "๐ Running strict linting checks..."
@chmod +x scripts/fix-clippy.sh
@./scripts/fix-clippy.sh --pedantic --nursery --all-features
format:
@echo "โจ Formatting code..."
cargo fmt
format-check:
@echo "๐ Checking code formatting..."
cargo fmt -- --check
check-deps:
@echo "๐ Checking for dependency updates..."
cargo outdated
update-deps:
@echo "โฌ๏ธ Updating dependencies..."
cargo update
benchmark:
@echo "โฑ๏ธ Running performance benchmarks..."
@echo "Testing startup time..."
@time cargo run --release -- version >/dev/null
@echo "Testing command parsing..."
@time cargo run --release -- --help >/dev/null
benchmark-pgo:
@echo "โฑ๏ธ Benchmarking PGO-optimized binary..."
ifeq ($(OS),Windows_NT)
@powershell -Command "Measure-Command { ./target/release/vx.exe version } | Select-Object TotalMilliseconds"
else
@time ./target/release/vx version >/dev/null
endif
dev-setup:
@echo "๐ ๏ธ Setting up development environment..."
rustup component add clippy rustfmt
cargo install cargo-outdated
release-check:
@echo "๐ Pre-release checks..."
cargo fmt -- --check
cargo clippy -- -D warnings
cargo test
cargo build --release
docs:
@echo "๐ Building documentation..."
cargo doc --open
size-analysis:
@echo "๐ Analyzing binary size..."
cargo build --release
ls -lh target/release/vx*
ifeq ($(OS),Windows_NT)
@echo "Windows binary size analysis:"
@dir target\release\vx.exe
else
@echo "Binary size analysis:"
@file target/release/vx
@size target/release/vx
endif
quick: format lint test build
ci: format-check lint security test coverage build-release
goreleaser-test:
@echo "๐งช Testing GoReleaser configuration..."
goreleaser check
goreleaser build --snapshot --clean
goreleaser-release:
@echo "๐ Creating release with GoReleaser (PGO-optimized)..."
goreleaser release --clean
goreleaser-snapshot:
@echo "๐ธ Creating snapshot build with GoReleaser..."
goreleaser build --snapshot --clean
test-pgo:
@echo "๐งช Testing PGO optimization effectiveness..."
@chmod +x scripts/test-pgo.sh
@./scripts/test-pgo.sh
perf-compare:
@echo "๐ Performance comparison: Debug vs Release vs PGO"
@echo "Debug build:"
@time cargo run -- version >/dev/null 2>&1
@echo "Release build:"
@time cargo run --release -- version >/dev/null 2>&1
@echo "Building PGO version..."
@$(MAKE) build-pgo >/dev/null 2>&1
@echo "PGO build:"
@time ./target/release/vx version >/dev/null 2>&1
advanced-build:
@echo "๐ Building with all optimizations..."
@chmod +x scripts/advanced-build.sh
@./scripts/advanced-build.sh --pgo --benchmark --size-analysis
sccache-setup:
@echo "โก Setting up sccache..."
@if ! command -v sccache >/dev/null 2>&1; then \
echo "Installing sccache..."; \
cargo install sccache --locked; \
else \
echo "sccache already installed"; \
fi
@echo "sccache version: $$(sccache --version)"
@echo "sccache stats:"
@sccache --show-stats
upx-install:
@echo "๐๏ธ Installing UPX compression tool..."
ifeq ($(OS),Windows_NT)
@choco install upx
else ifeq ($(shell uname),Darwin)
@brew install upx
else
@sudo apt-get update && sudo apt-get install -y upx-ucl
endif
@echo "UPX version: $$(upx --version | head -1)"
build-matrix:
@echo "๐ Building for multiple targets..."
@for target in x86_64-unknown-linux-gnu x86_64-unknown-linux-musl aarch64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin x86_64-pc-windows-msvc; do \
echo "Building for $$target..."; \
./scripts/advanced-build.sh --target $$target || echo "Failed to build $$target"; \
done
build-optimized:
@echo "๐ฏ Building optimized release..."
@$(MAKE) sccache-setup
@$(MAKE) upx-install
@./scripts/advanced-build.sh --pgo --strip --upx --benchmark
build-linux-arm64:
@echo "๐ง Building for Linux ARM64..."
@./scripts/advanced-build.sh --target aarch64-unknown-linux-gnu
build-macos-arm64:
@echo "๐ Building for macOS ARM64..."
@./scripts/advanced-build.sh --target aarch64-apple-darwin --pgo
build-windows:
@echo "๐ช Building for Windows..."
@./scripts/advanced-build.sh --target x86_64-pc-windows-msvc --pgo