@@ -4,9 +4,9 @@ set -euo pipefail
44
55# Check for required arguments
66if [[ $# -lt 2 ]]; then
7- echo " Usage: $0 <package> <target> [target_triple]" >&2
8- echo " Example: $0 hyperlight-host debug x86_64-unknown-linux-musl" >&2
9- exit 1
7+ echo " Usage: $0 <package> <target> [target_triple]" >&2
8+ echo " Example: $0 hyperlight-host debug x86_64-unknown-linux-musl" >&2
9+ exit 1
1010fi
1111
1212PACKAGE=" $1 "
@@ -18,20 +18,20 @@ CARGO="cargo"
1818# Cargo target argument to append to cargo calls (empty if not provided)
1919TRIPLE_ARG=" "
2020if [[ -n " ${TARGET_TRIPLE} " ]]; then
21- TRIPLE_ARG=" --target ${TARGET_TRIPLE} --target-dir ./target/host"
22- CARGO=" cross"
21+ TRIPLE_ARG=" --target ${TARGET_TRIPLE} --target-dir ./target/host"
22+ CARGO=" cross"
2323fi
2424
2525# Convert target for cargo profile
2626PROFILE=$( [ " $TARGET " = " debug" ] && echo " dev" || echo " $TARGET " )
2727
2828# Required features needed so the rust packages can compile
2929if [[ " $PACKAGE " == " hyperlight-host" ]]; then
30- REQUIRED_FEATURES=(" kvm" " mshv3 " )
30+ REQUIRED_FEATURES=(" kvm" " mshv " )
3131elif [[ " $PACKAGE " == " hyperlight-guest-bin" ]]; then
32- REQUIRED_FEATURES=(" printf" )
33- else
34- REQUIRED_FEATURES=()
32+ REQUIRED_FEATURES=(" printf" )
33+ else
34+ REQUIRED_FEATURES=()
3535fi
3636
3737# Get all features for the package (excluding default and required features)
@@ -40,42 +40,66 @@ features=$(cargo metadata --format-version 1 --no-deps | jq -r --arg pkg "$PACKA
4040
4141# Convert required features array to comma-separated string for cargo
4242if [[ ${# REQUIRED_FEATURES[@]} -gt 0 ]]; then
43- required_features_str=$( IFS=,; echo " ${REQUIRED_FEATURES[*]} " )
43+ required_features_str=$(
44+ IFS=,
45+ echo " ${REQUIRED_FEATURES[*]} "
46+ )
4447else
45- required_features_str=" "
48+ required_features_str=" "
4649fi
4750
4851# Test with minimal features
4952if [[ ${# REQUIRED_FEATURES[@]} -gt 0 ]]; then
50- echo " Testing $PACKAGE with required features only ($required_features_str )..."
51- (set -x; " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $required_features_str " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings)
53+ echo " Testing $PACKAGE with required features only ($required_features_str )..."
54+ (
55+ set -x
56+ " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $required_features_str " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings
57+ )
5258else
53- echo " Testing $PACKAGE with no features..."
54- (set -x; " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings)
59+ echo " Testing $PACKAGE with no features..."
60+ (
61+ set -x
62+ " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings
63+ )
5564fi
5665
5766echo " Testing $PACKAGE with default features..."
58- (set -x; " $CARGO " clippy -p " $PACKAGE " --all-targets --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings)
67+ (
68+ set -x
69+ " $CARGO " clippy -p " $PACKAGE " --all-targets --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings
70+ )
5971
6072# Test each additional feature individually
6173for feature in $features ; do
62- if [[ ${# REQUIRED_FEATURES[@]} -gt 0 ]]; then
63- echo " Testing $PACKAGE with feature: $required_features_str ,$feature "
64- (set -x; " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $required_features_str ,$feature " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings)
65- else
66- echo " Testing $PACKAGE with feature: $feature "
67- (set -x; " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $feature " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings)
68- fi
74+ if [[ ${# REQUIRED_FEATURES[@]} -gt 0 ]]; then
75+ echo " Testing $PACKAGE with feature: $required_features_str ,$feature "
76+ (
77+ set -x
78+ " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $required_features_str ,$feature " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings
79+ )
80+ else
81+ echo " Testing $PACKAGE with feature: $feature "
82+ (
83+ set -x
84+ " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $feature " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings
85+ )
86+ fi
6987done
7088
7189# Test all features together
7290if [[ -n " $features " ]]; then
73- all_features=$( echo $features | tr ' \n' ' ,' | sed ' s/,$//' )
74- if [[ ${# REQUIRED_FEATURES[@]} -gt 0 ]]; then
75- echo " Testing $PACKAGE with all features: $required_features_str ,$all_features "
76- (set -x; " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $required_features_str ,$all_features " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings)
77- else
78- echo " Testing $PACKAGE with all features: $all_features "
79- (set -x; " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $all_features " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings)
80- fi
81- fi
91+ all_features=$( echo $features | tr ' \n' ' ,' | sed ' s/,$//' )
92+ if [[ ${# REQUIRED_FEATURES[@]} -gt 0 ]]; then
93+ echo " Testing $PACKAGE with all features: $required_features_str ,$all_features "
94+ (
95+ set -x
96+ " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $required_features_str ,$all_features " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings
97+ )
98+ else
99+ echo " Testing $PACKAGE with all features: $all_features "
100+ (
101+ set -x
102+ " $CARGO " clippy -p " $PACKAGE " --all-targets --no-default-features --features " $all_features " --profile=" $PROFILE " ${TRIPLE_ARG} -- -D warnings
103+ )
104+ fi
105+ fi
0 commit comments