2021-10-15 01:56:44 +00:00
|
|
|
#!/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.
|
|
|
|
|
2021-11-11 23:14:38 +00:00
|
|
|
# Run `rustfmt` on all Rust code contained in the crosvm workspace, including
|
|
|
|
# all commmon/* crates as well.
|
2021-10-15 01:56:44 +00:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# $ bin/fmt
|
|
|
|
#
|
|
|
|
# To print a diff and exit 1 if code is not formatted, but without changing any
|
|
|
|
# files, use:
|
|
|
|
#
|
|
|
|
# $ bin/fmt --check
|
|
|
|
#
|
|
|
|
|
2021-11-11 23:14:38 +00:00
|
|
|
set -e
|
|
|
|
cd "$(dirname $0)/.."
|
2021-10-15 01:56:44 +00:00
|
|
|
|
2021-11-11 23:14:38 +00:00
|
|
|
echo "Fmt crosvm workspace"
|
|
|
|
cargo fmt --all -- "$@"
|
2021-10-15 01:56:44 +00:00
|
|
|
|
2021-11-11 23:14:38 +00:00
|
|
|
for crate in common/*; do
|
2021-11-18 23:15:15 +00:00
|
|
|
if [ -e "${crate}/Cargo.toml" ]; then
|
2021-11-11 23:14:38 +00:00
|
|
|
echo "Fmt ${crate}"
|
|
|
|
(cd "${crate}" && cargo fmt)
|
|
|
|
fi
|
|
|
|
done
|