#!/usr/bin/env python3 # Copyright 2022 The ChromiumOS Authors # 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: # # $ tools/fmt # # To print a diff and exit 1 if code is not formatted, but without changing any # files, use: # # $ tools/fmt --check # from pathlib import Path import sys from impl.common import ( CROSVM_ROOT, run_main, cmd, chdir, ) def main(check: bool = False): chdir(CROSVM_ROOT) cmd( Path(sys.executable), "./tools/presubmit format", "--fix" if not check else None, ).fg() if __name__ == "__main__": run_main(main)