IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 44d85880 authored by ralfulrich's avatar ralfulrich
Browse files

update clang/copyright scripts

parent 932ed4ca
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import argparse
import subprocess as subp
import os
import sys
import re
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--apply', action="store_true",
......@@ -17,20 +18,20 @@ parser.add_argument("--all", action="store_true",
args = parser.parse_args()
excludeDirs = ["./modules", "./externals", "build", "install", "git"]
excludeDirs = [r"^(\./)?modules/", r"^(\./)?externals/", r"^(\./)?build", r"^(\./)?install", r"(\./)?\.git"]
filelist = []
if args.all:
for dirpath, dirnames, filenames in os.walk("."):
excl = False
for excl_dir in excludeDirs:
if excl_dir in dirpath:
if re.findall(excl_dir, dirpath):
excl = True
break
if excl:
continue
for f in filenames:
if f.endswith(".hpp") or f.endswith(".cpp"):
if (f.endswith(".hpp") or f.endswith(".cpp") or f.endswith(".inl")):
filename = os.path.join(dirpath, f)
if not os.path.islink(filename):
filelist.append(filename)
......@@ -47,18 +48,31 @@ 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"))]
filelist2 = subp.check_output(cmd, shell=True).decode("utf8").strip().split("\n")
filelist += filelist2
# some cleanup
filelist_clean = []
for f in filelist:
if not (f.endswith(".hpp") or f.endswith(".cpp") or f.endswith(".inl")):
continue
if os.path.islink(f):
continue
excl = False
for excl_dir in excludeDirs:
if re.findall(excl_dir, f):
excl = True
break
if excl:
continue
filelist_clean.append(f)
filelist = filelist_clean
cmd = "clang-format"
if "CLANG_FORMAT" in os.environ:
cmd = os.environ["CLANG_FORMAT"]
cmd += " -style=file"
if args.apply:
for filename in filelist:
for filename in filelist:
subp.check_call(cmd.split() + ["-i", filename])
else:
......
......@@ -24,7 +24,7 @@ Debug = 0
excludeDirs = ["./modules", "./externals", "build", "install", "git"]
excludeFiles = ['PhysicalConstants.h','CorsikaFenvOSX.cc', 'sgn.h', 'quartic.h']
extensions = [".cpp", ".hpp"]
extensions = [".cpp", ".inl", ".hpp"]
"""
justCheck: T: only checking, F: also changing files
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment