1+ #! /usr/bin/env bash
2+ # filepath: /home/marosset/src/github.com/marosset/hyperlight/hack/clippy-package-features.sh
3+
4+ set -euo pipefail
5+
6+ # Check for required arguments
7+ if [[ $# -lt 2 ]]; then
8+ echo " Usage: $0 <package> <target>" >&2
9+ echo " Example: $0 hyperlight-host debug" >&2
10+ exit 1
11+ fi
12+
13+ PACKAGE=" $1 "
14+ TARGET=" $2 "
15+
16+ # Convert target for cargo profile
17+ PROFILE=$( [ " $TARGET " = " debug" ] && echo " dev" || echo " $TARGET " )
18+
19+ # Required features for compilation (only for hyperlight-host)
20+ if [[ " $PACKAGE " == " hyperlight-host" ]]; then
21+ REQUIRED_FEATURES=" kvm,mshv3"
22+ # Get all features for the package (excluding default and required features)
23+ features=$( cargo metadata --format-version 1 --no-deps | jq -r " .packages[] | select(.name == \" $PACKAGE \" ) | .features | keys[]" | grep -v -E " ^(default|kvm|mshv3)$" || true)
24+ else
25+ REQUIRED_FEATURES=" "
26+ # Get all features for the package (excluding default)
27+ features=$( cargo metadata --format-version 1 --no-deps | jq -r " .packages[] | select(.name == \" $PACKAGE \" ) | .features | keys[]" | grep -v " ^default$" || true)
28+ fi
29+
30+ # Test with minimal features
31+ if [[ -n " $REQUIRED_FEATURES " ]]; then
32+ echo " Testing $PACKAGE with required features only ($REQUIRED_FEATURES )..."
33+ cargo clippy -p " $PACKAGE " --all-targets --no-default-features --features " $REQUIRED_FEATURES " --profile=" $PROFILE " -- -D warnings
34+ else
35+ echo " Testing $PACKAGE with no features..."
36+ cargo clippy -p " $PACKAGE " --all-targets --no-default-features --profile=" $PROFILE " -- -D warnings
37+ fi
38+
39+ echo " Testing $PACKAGE with default features..."
40+ cargo clippy -p " $PACKAGE " --all-targets --profile=" $PROFILE " -- -D warnings
41+
42+ # Test each additional feature individually
43+ for feature in $features ; do
44+ if [[ -n " $REQUIRED_FEATURES " ]]; then
45+ echo " Testing $PACKAGE with feature: $REQUIRED_FEATURES ,$feature "
46+ cargo clippy -p " $PACKAGE " --all-targets --no-default-features --features " $REQUIRED_FEATURES ,$feature " --profile=" $PROFILE " -- -D warnings || echo " Feature $feature failed for $PACKAGE "
47+ else
48+ echo " Testing $PACKAGE with feature: $feature "
49+ cargo clippy -p " $PACKAGE " --all-targets --no-default-features --features " $feature " --profile=" $PROFILE " -- -D warnings || echo " Feature $feature failed for $PACKAGE "
50+ fi
51+ done
52+
53+ # Test all features together
54+ if [[ -n " $features " ]]; then
55+ all_features=$( echo $features | tr ' \n' ' ,' | sed ' s/,$//' )
56+ if [[ -n " $REQUIRED_FEATURES " ]]; then
57+ echo " Testing $PACKAGE with all features: $REQUIRED_FEATURES ,$all_features "
58+ cargo clippy -p " $PACKAGE " --all-targets --no-default-features --features " $REQUIRED_FEATURES ,$all_features " --profile=" $PROFILE " -- -D warnings || echo " All features failed for $PACKAGE "
59+ else
60+ echo " Testing $PACKAGE with all features: $all_features "
61+ cargo clippy -p " $PACKAGE " --all-targets --no-default-features --features " $all_features " --profile=" $PROFILE " -- -D warnings || echo " All features failed for $PACKAGE "
62+ fi
63+ fi
0 commit comments