mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
bin/clippy: Add option to skip cleaning cache
Add --use-cache option in bin/clippy to run cargo-clippy without deleting cache. It is useful when we use bin/clippy for multiple commits in pre-upload hook. BUG=chromium:1105466 TEST=bin/clippy w,w/o --use-cache Change-Id: I386c7e08ad48ea2446a91e99d4b6523673211d6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2297005 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
parent
ff1194a0b5
commit
29495300de
1 changed files with 16 additions and 3 deletions
19
bin/clippy
19
bin/clippy
|
@ -9,6 +9,17 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
USE_CACHE=false
|
||||
CLIPPY_ARGS=( "$@" )
|
||||
|
||||
# TODO: When we add more options, use a fancier parsing mechanism such as
|
||||
# getopts. Also use the Rust convention of -- separating the arguments for this
|
||||
# script itself from the ones for clippy.
|
||||
if (( "$#" > 0 )) && [[ "$1" == "--use-cache" ]]; then
|
||||
USE_CACHE=true
|
||||
CLIPPY_ARGS=( "${CLIPPY_ARGS[@]:1}" )
|
||||
fi
|
||||
|
||||
# Change into directory of script, which is crosvm/bin.
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
|
@ -69,7 +80,9 @@ SUPPRESS=(
|
|||
)
|
||||
|
||||
# Needed or else clippy won't re-run on code that has already compiled.
|
||||
cargo clean
|
||||
if [[ "${USE_CACHE}" == false ]]; then
|
||||
cargo clean
|
||||
fi
|
||||
|
||||
# Need to set pass --sysroot for cargo-clippy manually.
|
||||
# cf. https://github.com/rust-lang/rust-clippy/issues/3523
|
||||
|
@ -77,5 +90,5 @@ RUST_SYSROOT=$(rustc --print sysroot)
|
|||
RUSTFLAGS="${RUSTFLAGS:-}"
|
||||
export RUSTFLAGS="$RUSTFLAGS --sysroot=$RUST_SYSROOT"
|
||||
|
||||
cargo clippy --all-features --all-targets -- ${SUPPRESS[@]/#/-Aclippy::} "$@" \
|
||||
-D warnings
|
||||
cargo clippy --all-features --all-targets -- ${SUPPRESS[@]/#/-Aclippy::} \
|
||||
"${CLIPPY_ARGS[@]}" -D warnings
|
||||
|
|
Loading…
Reference in a new issue