• Home
  • Raw
  • Download

Lines Matching +full:require +full:- +full:main +full:- +full:filename

7 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
18 UNCRUSTIFY_ARGS = ["-c", CONFIG_FILE]
19 CHECK_GENERATED_FILES = "tests/scripts/check-generated-files.sh"
32 # Match FILENAME(s) in "check SCRIPT (FILENAME...)"
35 def list_generated_files() -> FrozenSet[str]:
43 # Parse check-generated-files.sh to get an up-to-date list of
47 # This introduces a limitation: check-generated-files.sh must have
50 content = open(CHECK_GENERATED_FILES, encoding="utf-8").read()
54 def get_src_files(since: Optional[str]) -> List[str]:
68 output = subprocess.check_output(["git", "ls-files"] + file_patterns,
73 cmd = ["git", "log", since + "..HEAD", "--name-only", "--pretty=", "--"] + src_files
77 cmd = ["git", "diff", "--name-only", "--"] + src_files
83 # Don't correct style for third-party files (and, for simplicity,
86 src_files = [filename for filename in src_files
87 if not (filename.startswith("3rdparty/") or
88 filename in generated_files)]
91 def get_uncrustify_version() -> str:
95 result = subprocess.run([UNCRUSTIFY_EXE, "--version"],
99 print_err("Could not get Uncrustify version:", str(result.stderr, "utf-8"))
102 return str(result.stdout, "utf-8")
104 def check_style_is_correct(src_file_list: List[str]) -> bool:
122 diff_cmd = ["diff", "-u", src_file, src_file + ".uncrustify"]
126 print(src_file + " changed - code style is incorrect.")
137 def fix_style_single_pass(src_file_list: List[str]) -> bool:
141 code_change_args = UNCRUSTIFY_ARGS + ["--no-backup"]
152 def fix_style(src_file_list: List[str]) -> int:
161 # Guard against future changes that cause the codebase to require
169 def main() -> int: function
171 Main with command line arguments.
181 parser.add_argument('-f', '--fix', action='store_true',
184 parser.add_argument('-s', '--since', metavar='COMMIT', const='development', nargs='?',
186 ' (e.g. --since=HEAD~3 or --since=development). If no'
188 # --subset is almost useless: it only matters if there are no files
190 # 'code_style.py --subset' does nothing). In particular,
191 # 'code_style.py --fix --subset ...' is intended as a stable ("porcelain")
193 parser.add_argument('--subset', action='store_true',
194 help='only check the specified files (default with non-option arguments)')
222 sys.exit(main())