diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-04-27 09:06:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-27 09:06:19 -0400 |
| commit | abe94d6562ba70f8b8a6997a7b0fac381e0dcfdd (patch) | |
| tree | 5c1629145d54f12926ea4c3e687729d4e25c7ce9 /python/firstheader.py | |
| parent | 98dc08cddaaf01be7c5c577e4dd8443cbaabbe78 (diff) | |
| parent | 209135f188d02becf944658c02983dacc0c0fdd0 (diff) | |
Merge pull request #6298 from opensourcerouting/build-assorted-20200423
build: spring cleaning
Diffstat (limited to 'python/firstheader.py')
| -rw-r--r-- | python/firstheader.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/python/firstheader.py b/python/firstheader.py new file mode 100644 index 0000000000..19a85b63e5 --- /dev/null +++ b/python/firstheader.py @@ -0,0 +1,30 @@ +# +# check that the first header included in C files is either +# zebra.h or config.h +# + +import sys, os, re, subprocess + +include_re = re.compile('^#\s*include\s+["<]([^ ">]+)[">]', re.M) + +errors = 0 + +files = subprocess.check_output(['git', 'ls-files']).decode('ASCII') +for fn in files.splitlines(): + if not fn.endswith('.c'): + continue + if fn.startswith('tools/'): + continue + with open(fn, 'r') as fd: + data = fd.read() + m = include_re.search(data) + if m is None: + #sys.stderr.write('no #include in %s?\n' % (fn)) + continue + if m.group(1) in ['config.h', 'zebra.h', 'lib/zebra.h']: + continue + sys.stderr.write('%s: %s\n' % (fn, m.group(0))) + errors += 1 + +if errors: + sys.exit(1) |
