crosvm/bin/fmt
Daniel Verkamp 1769b63686 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>
2019-10-21 19:26:04 +00:00

30 lines
747 B
Bash
Executable file

#!/bin/bash
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# 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.
#
# Usage:
#
# $ bin/fmt
#
# To print a diff and exit 1 if code is not formatted, but without changing any
# files, use:
#
# $ bin/fmt --check
#
set -euo pipefail
# Change into directory of script, which is crosvm/bin.
cd "$(dirname "${BASH_SOURCE[0]}")"
# Jump up to root directory of crosvm repo.
cd ..
find . -name '*.rs' -print0 | xargs -0 rustfmt "$@" --