mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Moves common script logic into utils.py (not a great name, but couldn't come up with better). This is in particular to make the buildifier.py script really trivial, allowing that pre-commit to be easily added. However, scripts have also been diverging on how we find bazel, so I'm trying to unify that. The advantage of reimplementing buildifier's pre-commit is that (a) we can now run buildifier server-side, and (b) we can stop advising installing it manually. Then the only Linux-specific package manager is Cargo, which is only used for watchman, which is optional -- so stop highlighting Linux-specific package managers in the tool instructions.
27 lines
616 B
Python
Executable File
27 lines
616 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
"""Runs buildifier on passed-in BUILD files, mainly 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 sys
|
|
|
|
import scripts_utils # type: ignore
|
|
|
|
|
|
def main() -> None:
|
|
files = sys.argv[1:]
|
|
if not files:
|
|
return
|
|
buildifier = scripts_utils.get_release(scripts_utils.Release.BUILDIFIER)
|
|
subprocess.check_call([buildifier] + files)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|