diff options
author | ZyX <kp-pav@yandex.ru> | 2017-04-08 01:54:58 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-04-08 01:54:58 +0300 |
commit | 043d8ff9f2389f8deab7934aa0ab4ce88a747f01 (patch) | |
tree | 4d6fa32d7c1ddaa99c15f80c1a4ba95d5f3ca2da /scripts | |
parent | 5992cdf3c27ee9c73cea22e288c6ea6d54867394 (diff) | |
parent | 13352c00f1909d9296c5f276a3735f5e6f231b39 (diff) | |
download | rneovim-043d8ff9f2389f8deab7934aa0ab4ce88a747f01.tar.gz rneovim-043d8ff9f2389f8deab7934aa0ab4ce88a747f01.tar.bz2 rneovim-043d8ff9f2389f8deab7934aa0ab4ce88a747f01.zip |
Merge branch 'master' into luaviml'/lua
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check-includes.py | 66 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 2 |
2 files changed, 67 insertions, 1 deletions
diff --git a/scripts/check-includes.py b/scripts/check-includes.py new file mode 100755 index 0000000000..21308a21aa --- /dev/null +++ b/scripts/check-includes.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +import sys +import re +import os + +from subprocess import Popen, PIPE +from argparse import ArgumentParser + + +GENERATED_INCLUDE_RE = re.compile( + r'^\s*#\s*include\s*"([/a-z_0-9.]+\.generated\.h)"(\s+//.*)?$') + + +def main(argv): + argparser = ArgumentParser() + argparser.add_argument('--generated-includes-dir', action='append', + help='Directory where generated includes are located.') + argparser.add_argument('--file', type=open, help='File to check.') + argparser.add_argument('iwyu_args', nargs='*', + help='IWYU arguments, must go after --.') + args = argparser.parse_args(argv) + + with args.file: + include_dirs = [] + + iwyu = Popen(['include-what-you-use', '-xc'] + args.iwyu_args + ['/dev/stdin'], + stdin=PIPE, stdout=PIPE, stderr=PIPE) + + for line in args.file: + match = GENERATED_INCLUDE_RE.match(line) + if match: + for d in args.generated_includes_dir: + try: + f = open(os.path.join(d, match.group(1))) + except IOError: + continue + else: + with f: + for generated_line in f: + iwyu.stdin.write(generated_line) + break + else: + raise IOError('Failed to find {0}'.format(match.group(1))) + else: + iwyu.stdin.write(line) + + iwyu.stdin.close() + + out = iwyu.stdout.read() + err = iwyu.stderr.read() + + ret = iwyu.wait() + + if ret != 2: + print('IWYU failed with exit code {0}:'.format(ret)) + print('{0} stdout {0}'.format('=' * ((80 - len(' stdout ')) // 2))) + print(out) + print('{0} stderr {0}'.format('=' * ((80 - len(' stderr ')) // 2))) + print(err) + return 1 + return 0 + + +if __name__ == '__main__': + raise SystemExit(main(sys.argv[1:])) diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index d02eef6b44..c8ae36cc3b 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -321,7 +321,7 @@ list_vim_patches() { if [[ -n "${vim_tag}" ]]; then local patch_number="${vim_tag:5}" # Remove prefix like "v7.4." # Tagged Vim patch, check version.c: - is_missing="$(sed -n '/static int included_patches/,/}/p' "${NVIM_SOURCE_DIR}/src/nvim/version.c" | + is_missing="$(sed -n '/static const int included_patches/,/}/p' "${NVIM_SOURCE_DIR}/src/nvim/version.c" | grep -x -e "[[:space:]]*//[[:space:]]${patch_number} NA.*" -e "[[:space:]]*${patch_number}," >/dev/null && echo "false" || echo "true")" vim_commit="${vim_tag#v}" if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then |