mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:00:13 +01:00
First, this makes the Bazel invocations not try to uses curses which prevents running them with `pre-commit run ... -v` showing the timings for each check. The curses display overwrote the output. Second, this fixes the main slowdown I was seeing. Because we passed _all_ files to the check-build-graph hook and there are large number of files, pre-commit would run the tool over and over on a subset of the files. This is especially wasteful as the build graph check already doesn't do anything with the files, it just checks `//...` on each invocation. So this just added a (large) constant factor of cost. Third, this tries to reduce the cost of `fix_cc_deps.py` in the case of large numbers of files. This still isn't _super_ fast -- but the rest of the cost is in running the `bazel query` and parsing the output. I tried switching it to jsonproto and it wasn't any faster. I think this would need to be in a non-Python language and use `proto` directly to significantly improve the cost here. Assisted-by: Antigravity with Gemini
24 lines
570 B
Python
Executable File
24 lines
570 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
"""Verify that the bazel build graph is in a valid state, for pre-commit."""
|
|
|
|
__copyright__ = """
|
|
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
Exceptions. See /LICENSE for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
"""
|
|
|
|
import subprocess
|
|
|
|
import scripts_utils
|
|
|
|
|
|
def main() -> None:
|
|
scripts_utils.chdir_repo_root()
|
|
bazel = scripts_utils.locate_bazel()
|
|
subprocess.check_call([bazel, "build", "--curses=no", "--nobuild", "//..."])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|