diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
commit | 39dac57259cff8b61db0b22cb2ad0a8adb02692e (patch) | |
tree | 52a026cc8c22793eb17fd0f5e22adce1ae08a1dd /build/ppCheck.py | |
parent | a1cce3b2b00bbd9f4983013ddd8934a7bccb9e99 (diff) | |
parent | c2d9ab62f3d097c9e0e00184cab1f546554f5eaa (diff) | |
download | UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.gz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.lz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.xz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.zip |
Merge branch 'redwood' into 28.9-platform
Diffstat (limited to 'build/ppCheck.py')
-rw-r--r-- | build/ppCheck.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/build/ppCheck.py b/build/ppCheck.py new file mode 100644 index 000000000..1e27ca171 --- /dev/null +++ b/build/ppCheck.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +from __future__ import print_function +import os, sys + +if not len(sys.argv) is 2 or not os.path.exists(sys.argv[1]): + print("\nYou did not supply a valid path to check.") + exit(1) +else: + print("\nChecking for un-preprocessed files...", end = ' ') + DIST_PATH = sys.argv[1] + +PP_FILE_TYPES = ( + '.css', + '.dtd', + '.html', + '.js', + '.jsm', + '.xhtml', + '.xml', + '.xul', + '.manifest', + '.properties', + '.rdf' +) + +PP_SPECIAL_TYPES = ('.css') + +PP_DIRECTIVES = [ + 'define', + 'if', + 'ifdef', + 'ifndef', + 'elif', + 'elifdef', + 'endif', + 'error', + 'expand', + 'filter', + 'include', + 'literal', + 'undef', + 'unfilter' +] + +PP_FILES = [] +PP_BAD_FILES = [] + +for root, directories, filenames in os.walk(DIST_PATH): + for filename in filenames: + if filename.endswith(PP_FILE_TYPES): + PP_FILES += [ os.path.join(root, filename).replace(os.sep, '/') ] + +for file in PP_FILES: + with open(file) as fp: + marker = '%' if file.endswith(PP_SPECIAL_TYPES) else '#' + directives = tuple(marker + directive for directive in PP_DIRECTIVES) + for line in fp: + if line.startswith(directives): + PP_BAD_FILES += [ file.replace(DIST_PATH + '/', '') ] + fp.close() + +PP_BAD_FILES = list(dict.fromkeys(PP_BAD_FILES)) + +print('Done!') + +if len(PP_BAD_FILES) > 0: + print("\nWARNING: The following {0} file(s) in {1} may require preprocessing:\n".format(len(PP_BAD_FILES), DIST_PATH)) + for file in PP_BAD_FILES: + print(file) + +exit(0)
\ No newline at end of file |