#!/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 the crosvm workspace, including # all commmon/* crates as well. # # 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 -e cd "$(dirname $0)/.." echo "Fmt crosvm workspace" cargo fmt --all -- "$@" for crate in common/*; do if [ -e "${crate}/Cargo.toml" ]; then echo "Fmt ${crate}" (cd "${crate}" && cargo fmt) fi done