2022-02-14 20:47:01 +00:00
|
|
|
#!/usr/bin/env python3
|
2022-09-13 17:55:17 +00:00
|
|
|
# Copyright 2022 The ChromiumOS Authors
|
2021-10-15 01:56:44 +00:00
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2022-03-22 20:04:31 +00:00
|
|
|
from impl.common import (
|
|
|
|
CROSVM_ROOT,
|
|
|
|
run_main,
|
|
|
|
cmd,
|
|
|
|
chdir,
|
|
|
|
)
|
2022-03-02 19:10:59 +00:00
|
|
|
|
2022-02-18 18:37:14 +00:00
|
|
|
|
2022-07-28 19:47:07 +00:00
|
|
|
def main(check: bool = False, nightly: bool = False):
|
2022-02-14 20:47:01 +00:00
|
|
|
chdir(CROSVM_ROOT)
|
2022-08-11 18:28:03 +00:00
|
|
|
cmd(
|
2023-02-21 21:40:59 +00:00
|
|
|
"./tools/presubmit format",
|
2022-08-11 18:28:03 +00:00
|
|
|
"--fix" if not check else None,
|
2023-02-21 21:40:59 +00:00
|
|
|
"--nightly-fmt" if nightly else None,
|
2022-02-18 18:37:14 +00:00
|
|
|
).fg()
|
2022-02-14 20:47:01 +00:00
|
|
|
|
|
|
|
|
2022-03-22 20:04:31 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
run_main(main)
|