|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # xfail-license |
3 | 3 |
|
4 | | -import sys, fileinput, subprocess, re |
| 4 | +import sys, fileinput, subprocess, re, argparse, os |
5 | 5 | from licenseck import * |
6 | 6 |
|
7 | 7 | err=0 |
@@ -32,9 +32,31 @@ def do_license_check(name, contents): |
32 | 32 | if not check_license(name, contents): |
33 | 33 | report_error_name_no(name, 1, "incorrect license") |
34 | 34 |
|
35 | | - |
36 | | -file_names = [s for s in sys.argv[1:] if (not s.endswith("_gen.rs")) |
37 | | - and (not ".#" in s)] |
| 35 | +parser = argparse.ArgumentParser(description='Tidy source files.') |
| 36 | +parser.add_argument('--srcdir') |
| 37 | +args = parser.parse_args() |
| 38 | + |
| 39 | +file_names = [] |
| 40 | +for (dirpath, dirnames, filenames) in os.walk(os.path.join(args.srcdir, 'src')): |
| 41 | + for name in filenames: |
| 42 | + if name.endswith("_gen.rs") or ".#" in name: |
| 43 | + continue |
| 44 | + def in_dir(d): |
| 45 | + return dirpath.startswith(os.path.join(args.srcdir, d)) |
| 46 | + def add(): |
| 47 | + file_names.append(os.path.join(dirpath, name)) |
| 48 | + ext = os.path.splitext(name)[1] |
| 49 | + if ext in ['.rs', '.rc'] and not in_dir('src/test'): |
| 50 | + add() |
| 51 | + elif ext in ['.py'] and in_dir('src/etc'): |
| 52 | + add() |
| 53 | + elif ext in ['.c', '.cpp', '.h']: |
| 54 | + if in_dir('src/rt/jemalloc') or in_dir('src/rt/linenoise') \ |
| 55 | + or in_dir('src/rt/vg') or in_dir('src/rt/msvc'): |
| 56 | + continue |
| 57 | + if in_dir('src/rt') or in_dir('src/rustllvm'): |
| 58 | + if name != 'miniz.cpp': |
| 59 | + add() |
38 | 60 |
|
39 | 61 | current_name = "" |
40 | 62 | current_contents = "" |
|
0 commit comments