From 958d52f28b33f52399f4ee734000cb686bf75ef1 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 28 Nov 2024 06:55:14 +1100 Subject: -dynax/dynax.cpp: More I/O improvements: * Replaced hjingi hopper hack with a hopper device. * Improved DIP switch labels for mjembase and hooked up hopper. * Improved a few DIP switch labels for mjelctrn. -Fixed some more #include guards and added a CI task to check them in src/devices and src/mame. --- scripts/build/check_include_guards.py | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 scripts/build/check_include_guards.py (limited to 'scripts/build/check_include_guards.py') diff --git a/scripts/build/check_include_guards.py b/scripts/build/check_include_guards.py new file mode 100755 index 00000000000..f294cc6412f --- /dev/null +++ b/scripts/build/check_include_guards.py @@ -0,0 +1,47 @@ +#!/usr/bin/python3 +## +## icense:BSD-3-Clause +## copyright-holders:Vas Crabb + +import io +import os +import os.path +import re +import sys + + +def pathsplit(p): + result = [ ] + while p: + d, n = os.path.split(p) + if not n: + result.insert(0, d) + break + else: + result.insert(0, n) + p = d + return result + + +if __name__ == '__main__': + extpat = re.compile('.+\\.(h|hpp)$') + substpat = re.compile('[-.]') + guardpat = re.compile('^ *# *ifndef +([^\s]+)(\s+.*)?') + bad = False + for root in sys.argv[1:]: + for path, subdirs, files in os.walk(root): + prefix = 'MAME_' + '_'.join([n.upper() for n in pathsplit(os.path.relpath(path, root))]) + '_' + for f in files: + if extpat.match(f): + expected = prefix + substpat.sub('_', f.upper()) + fp = os.path.join(path, f) + with io.open(fp, 'r', encoding='utf-8') as fd: + for l in fd: + m = guardpat.match(l) + if m: + if m.group(1) != expected: + sys.stderr.write('%s: #include guard does not appear to match expected %s\n' % (fp, expected)) + bad = True + break + if bad: + sys.exit(1) -- cgit v1.2.3-70-g09d2