2022-02-14 20:47:01 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-10-15 01:56:44 +00:00
|
|
|
# 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-12 17:35:42 +00:00
|
|
|
# To check for violations:
|
|
|
|
# $ ./tools/clippy
|
|
|
|
#
|
|
|
|
# To fix violations where possible:
|
|
|
|
# $ ./tools/clippy --fix
|
|
|
|
|
2022-02-14 20:47:01 +00:00
|
|
|
from impl.common import CROSVM_ROOT, cwd, run_main, cmd, chdir
|
|
|
|
|
|
|
|
clippy = cmd("cargo clippy")
|
|
|
|
|
|
|
|
|
|
|
|
def main(fix: bool = False):
|
|
|
|
chdir(CROSVM_ROOT)
|
|
|
|
|
|
|
|
# Note: Clippy checks are configured in .cargo/config.toml
|
|
|
|
clippy_args = [
|
|
|
|
"--fix" if fix else None,
|
|
|
|
"--all-targets",
|
|
|
|
"--",
|
|
|
|
"-Dwarnings",
|
|
|
|
]
|
|
|
|
print("Clippy crosvm workspace")
|
|
|
|
clippy("--workspace", "--features=all-linux", *clippy_args).fg()
|
|
|
|
|
|
|
|
for crate in CROSVM_ROOT.glob("common/*/Cargo.toml"):
|
|
|
|
print("Clippy", crate.parent.relative_to(CROSVM_ROOT))
|
|
|
|
with cwd(crate.parent):
|
|
|
|
clippy("--all-features", *clippy_args).fg()
|
|
|
|
|
|
|
|
|
|
|
|
run_main(main)
|