summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-10-16 16:07:17 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-21 19:26:04 +0000
commit1769b63686e054917576ec02e66c3991b78578ce (patch)
tree5de1900c745ecf17353172d9b460b4e2c7c638a5
parent3be01bd505dbb3cfd6306d69b8c50a5ac76d3912 (diff)
downloadcrosvm-1769b63686e054917576ec02e66c3991b78578ce.tar
crosvm-1769b63686e054917576ec02e66c3991b78578ce.tar.gz
crosvm-1769b63686e054917576ec02e66c3991b78578ce.tar.bz2
crosvm-1769b63686e054917576ec02e66c3991b78578ce.tar.lz
crosvm-1769b63686e054917576ec02e66c3991b78578ce.tar.xz
crosvm-1769b63686e054917576ec02e66c3991b78578ce.tar.zst
crosvm-1769b63686e054917576ec02e66c3991b78578ce.zip
bin/fmt: remove use of `cargo fmt`
This simplifies our formatting script so that it does not need any of
the Cargo metadata to run; the new version just finds all Rust files
(*.rs) and runs `rustfmt` on them individually.

BUG=None
TEST=bin/fmt
TEST=bin/fmt --check

Change-Id: I45aaee497d4f1dfcc03b3e2c5c2f27feb974dc80
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1865371
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
-rwxr-xr-xbin/fmt19
1 files changed, 2 insertions, 17 deletions
diff --git a/bin/fmt b/bin/fmt
index 39eac2c..69d1140 100755
--- a/bin/fmt
+++ b/bin/fmt
@@ -4,7 +4,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-# Run `cargo fmt` on all Rust code contained in crosvm. This is different from
+# Run `rustfmt` on all Rust code contained in crosvm. This is different from
 # `cargo fmt --all` which formats multiple crates but a single workspace only.
 # Crosvm consists of multiple workspaces.
 #
@@ -26,19 +26,4 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
 # Jump up to root directory of crosvm repo.
 cd ..
 
-# Keep track of whether any cargo fmt invocation exited with error.
-EXIT=0
-
-FIND_CARGO_TOMLS="$(find "$PWD" -name Cargo.toml)"
-
-while read path_to_cargo_toml; do
-    cd "$(dirname "$path_to_cargo_toml")"
-
-    if grep --quiet '\[workspace\]' Cargo.toml; then
-        if ! cargo fmt --all -- "$@"; then
-            EXIT=1
-        fi
-    fi
-done <<< "$FIND_CARGO_TOMLS"
-
-exit $EXIT
+find . -name '*.rs' -print0 | xargs -0 rustfmt "$@" --