5"""Tool for listing Dart source files.
7If the first argument is 'relative', the script produces paths relative to the
8current working directory. If the first argument is 'absolute', the script
9produces absolute paths.
12 python3 tools/list_dart_files_as_depfile.py <depfile> <directory> <pattern>
23 if not os.path.isabs(directory):
24 directory = os.path.realpath(directory)
28 pattern = re.compile(argv[3])
31 out = open(depfile,
'w')
32 out.write(os.path.relpath(depfile))
35 for root, directories, files
in os.walk(directory):
37 for skip_dir
in [
'.git',
'gen',
'test']:
38 if skip_dir
in directories:
39 directories.remove(skip_dir)
43 if pattern
and root == directory:
44 directories[:] = filter(pattern.match, directories)
46 for filename
in files:
48 '.dart')
and not filename.endswith(
'_test.dart'):
49 fullname = os.path.join(directory, root, filename)
50 fullname = fullname.replace(os.sep,
'/')
59if __name__ ==
'__main__':
60 sys.exit(
main(sys.argv))