Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new target "ninja clippy" for Rust projects #13914

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Commits on Nov 20, 2024

  1. scripts: make clangtidy obey b_colorout

    Buffering the output of clang-tidy will kill colored output, because the
    tools being run are not going to see isatty() return true anymore.
    To avoid that, pass b_colorout down to the clangtidy script.
    
    As a bonus, this fixes -Db_colorout=never which was producing colored
    output from clang-tidy.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    fa895c8 View commit details
    Browse the repository at this point in the history
  2. scripts: rename run_tool to run_clang_tool

    Differentiate from the "run_tool_on_targets" function that will be introduced
    in the next commit.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    ff54f18 View commit details
    Browse the repository at this point in the history
  3. mtest: move determine_worker_count to utils, generalize

    It is useful to apply a limit to the number of processes even outside "meson test",
    and specifically for clang tools.  In preparation for this, generalize
    determine_worker_count() to accept a variable MESON_NUM_PROCESSES instead of
    MESON_TESTTHREADS, and use it throughout instead of multiprocessing.cpu_count().
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    eb53b00 View commit details
    Browse the repository at this point in the history
  4. scripts: convert run_tool to asyncio

    This improves the handling of keyboard interrupt, and also makes it easy to
    buffer the output and not mix errors from different subprocesses.  This
    is useful for clang-tidy and will be used by clippy as well.  In addition,
    the new code supports MESON_NUM_PROCESSES.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    a996db8 View commit details
    Browse the repository at this point in the history
  5. utils: optimize PerMachine

    There is no need to create and look up a dictionary when MachineChoice is
    an enum, and there is no need to create a PerMachine object on every
    __setitem__ of another PerMachine object.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    94528c7 View commit details
    Browse the repository at this point in the history
  6. introspect: add machine to target_sources

    Even though the "targets" introspection info already includes the
    command line arguments used to invoke the compiler, this is not
    enough to correlated with the "compilers" introspection info and
    get extra information from there.
    
    Together with the existing "language" key, adding a "machine" key
    is enough to identify completely an entry in the compilers info.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    76d044e View commit details
    Browse the repository at this point in the history
  7. scripts: add "clippy" internal tool

    Similar to the "ninja scan-build" target for C, add a clippy internal
    tool that runs clippy-driver on all crates in the project.
    
    The approach used is more efficient than with "ninja scan-build", and
    does not require rerunning Meson in a separate build directory; it
    uses the introspection data to find the compiler arguments for the
    target and invokes clippy-driver with a slightly modified command
    line.
    
    This could actually be applied to scan-build as well, reusing the
    run_tool_on_targets() function.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    3497ac7 View commit details
    Browse the repository at this point in the history
  8. ninjabackend: add support for "ninja clippy"

    Add a target that builds all crates that could be extern to others,
    and then reruns clippy.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    74e572b View commit details
    Browse the repository at this point in the history
  9. rust: raise a warning if clippy is used instead of rustc

    clippy-driver is not meant to be a general-purpose compiler front-end.
    Since Meson can now provide natively the ability to invoke clippy,
    raise a warning if someone uses it that way.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    bonzini committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    e02ea84 View commit details
    Browse the repository at this point in the history