crosvm/tools/clippy
Dennis Kempin 45b5c13047 Make common crates part of the crosvm workspace
This greatly simplifies and speeds up compilation
and clippy times.

This ChromeOS-side building these crates has been
updated to copy the source out of the source tree
so that they will compile as a separate workspace.

BUG=b:256020427
TEST=presubmit

Change-Id: I2e0f1f6724924d6bdd70ea28d7777df7966cf724
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988324
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-10-31 21:33:33 +00:00

48 lines
1.3 KiB
Python
Executable file

#!/usr/bin/env python3
# Copyright 2019 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# To check for violations:
# $ ./tools/clippy
#
# To fix violations where possible:
# $ ./tools/clippy --fix
from impl.common import CROSVM_ROOT, cwd, run_main, cmd, chdir
from impl.test_runner import get_workspace_excludes
from impl.test_target import Triple
clippy = cmd("cargo clippy").with_color_flag()
triple = Triple.host_default()
excluded_crates: list[str] = list(get_workspace_excludes(triple))
def is_crate_excluded(crate: str) -> bool:
return crate in excluded_crates
def main(fix: bool = False, json: bool = False, locked: bool = False):
chdir(CROSVM_ROOT)
# Note: Clippy checks are configured in .cargo/config.toml
common_args = [
"--fix" if fix else None,
"--message-format=json" if json else None,
"--locked" if locked else None,
"--all-targets",
"--",
"-Dwarnings",
]
print("Clippy crosvm workspace")
clippy(
"--workspace",
f"--features={triple.feature_flag}",
*[f"--exclude={crate}" for crate in excluded_crates],
*common_args,
).with_envs(triple.get_cargo_env()).fg()
if __name__ == "__main__":
run_main(main)