1#!/bin/bash 2 3# Copyright 2019 The Chromium OS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# Run `rustfmt` on all Rust code contained in crosvm. This is different from 8# `cargo fmt --all` which formats multiple crates but a single workspace only. 9# Crosvm consists of multiple workspaces. 10# 11# Usage: 12# 13# $ bin/fmt 14# 15# To print a diff and exit 1 if code is not formatted, but without changing any 16# files, use: 17# 18# $ bin/fmt --check 19# 20 21set -euo pipefail 22 23# Change into directory of script, which is crosvm/bin. 24cd "$(dirname "${BASH_SOURCE[0]}")" 25 26# Jump up to root directory of crosvm repo. 27cd .. 28 29find . -name '*.rs' -print0 | grep -vz '^./target/' | xargs -0 rustfmt --edition=2018 "$@" -- 30