-
ralfulrich authored
rename framweork/sequence int framework/process remove all dynamic build files from main corsika directory, move into src re-added main/shower fixed wrong file locations Update corsika.hpp. Re-defining the version macros. Update corsika.hpp Update CONTRIBUTING.md Update MAINTAINERS.md Deleted FIXME.md Deleted AUTHORS Update COLLABORATION_AGREEMENT.md Update .clang-format Update .gitlab-ci.yml added packages: proposal, conex, cnpy, spdlog, lcov, corsika-data prevent in-source builds fotran language flags, sections build types fixed stack_example rename directories corsika8 interface target fixed few compilation, dependency issues in new system clang error simpler cmake files, using functions, re-introduce run_examples target clang format copyright notices fixed CI script, clang-format simplify ctest output better interfaces for urqmd and qgsjII, conex updated conex, data cmake integration build system cmake updates also updated corsika.hpp added earth radius moved static_pow from corsika::units::si::detail to corsika::units updated units::si namespaces throughout the project No python jobs removed a lot of stray using namespaces and corsika::units::si in entire codebase [refactory-2020] stack implementations: updated [refactory-2020] stack implementations: updated [refactory-2020] stack implementations [refactory-2020] stack implementations: !290 headers [refactory-2020] stack implementations: !290 headers
ralfulrich authoredrename framweork/sequence int framework/process remove all dynamic build files from main corsika directory, move into src re-added main/shower fixed wrong file locations Update corsika.hpp. Re-defining the version macros. Update corsika.hpp Update CONTRIBUTING.md Update MAINTAINERS.md Deleted FIXME.md Deleted AUTHORS Update COLLABORATION_AGREEMENT.md Update .clang-format Update .gitlab-ci.yml added packages: proposal, conex, cnpy, spdlog, lcov, corsika-data prevent in-source builds fotran language flags, sections build types fixed stack_example rename directories corsika8 interface target fixed few compilation, dependency issues in new system clang error simpler cmake files, using functions, re-introduce run_examples target clang format copyright notices fixed CI script, clang-format simplify ctest output better interfaces for urqmd and qgsjII, conex updated conex, data cmake integration build system cmake updates also updated corsika.hpp added earth radius moved static_pow from corsika::units::si::detail to corsika::units updated units::si namespaces throughout the project No python jobs removed a lot of stray using namespaces and corsika::units::si in entire codebase [refactory-2020] stack implementations: updated [refactory-2020] stack implementations: updated [refactory-2020] stack implementations [refactory-2020] stack implementations: !290 headers [refactory-2020] stack implementations: !290 headers
do-clang-format.py 2.60 KiB
#!/usr/bin/env python3
"""
Run clang-format with the style file in the CORSIKA repository.
By default it finds new files and files with modifications with respect to the current master and prints the filenames which need clang-formatting. Returns 1 if there are files which need modifications and 0 otherwise, so it can be used as a test.
"""
import argparse
import subprocess as subp
import os
import sys
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--apply', action="store_true",
help="Apply clang-format to files which need changes.")
parser.add_argument("--all", action="store_true",
help="Check all files below current path instead of new/modified.")
args = parser.parse_args()
excludeDirs = ["./modules", "./externals", "build", "install", "git"]
filelist = []
if args.all:
for dirpath, dirnames, filenames in os.walk("."):
excl = False
for excl_dir in excludeDirs:
if excl_dir in dirpath:
excl = True
break
if excl:
continue
for f in filenames:
if f.endswith(".hpp") or f.endswith(".cpp"):
filename = os.path.join(dirpath, f)
if not os.path.islink(filename):
filelist.append(filename)
if not filelist:
raise SystemExit("Error: You specified --all, but file list is empty. "
"Did you run from the build directory?")
else:
cmd = "git diff master --name-status"
for line in subp.check_output(cmd, shell=True).decode("utf8").strip().split("\n"):
if line.startswith("D"): continue
if line.startswith("R"):
filelist.append(line.split()[-1])
else:
filelist.append(line[1:].lstrip())
cmd = "git ls-files --exclude-standard --others"
filelist += subp.check_output(cmd, shell=True).decode("utf8").strip().split("\n")
filelist = [x for x in filelist
if "./externals" not in x and
"./modules" not in x and
(x.endswith(".hpp") or x.endswith(".cpp"))]
cmd = "clang-format"
if "CLANG_FORMAT" in os.environ:
cmd = os.environ["CLANG_FORMAT"]
cmd += " -style=file"
if args.apply:
for filename in filelist:
subp.check_call(cmd.split() + ["-i", filename])
else:
# only print files which need formatting
files_need_formatting = 0
for filename in filelist:
a = open(filename, "rb").read()
b = subp.check_output(cmd.split() + [filename])
if a != b:
files_need_formatting += 1
print(filename)
sys.exit(1 if files_need_formatting > 0 else 0)