Flutter Engine
The Flutter Engine
Functions
list_dart_files_as_depfile Namespace Reference

Functions

def main (argv)
 

Function Documentation

◆ main()

def list_dart_files_as_depfile.main (   argv)

Definition at line 20 of file list_dart_files_as_depfile.py.

20def main(argv):
21 depfile = argv[1]
22 directory = argv[2]
23 if not os.path.isabs(directory):
24 directory = os.path.realpath(directory)
25
26 pattern = None
27 if len(argv) > 3:
28 pattern = re.compile(argv[3])
29
30 # Output a GN/Ninja depfile, whose format is a Makefile with one target.
31 out = open(depfile, 'w')
32 out.write(os.path.relpath(depfile))
33 out.write(":")
34
35 for root, directories, files in os.walk(directory):
36 # We only care about actual source files, not generated code or tests.
37 for skip_dir in ['.git', 'gen', 'test']:
38 if skip_dir in directories:
39 directories.remove(skip_dir)
40
41 # If we are looking at the root directory, filter the immediate
42 # subdirectories by the given pattern.
43 if pattern and root == directory:
44 directories[:] = filter(pattern.match, directories)
45
46 for filename in files:
47 if filename.endswith(
48 '.dart') and not filename.endswith('_test.dart'):
49 fullname = os.path.join(directory, root, filename)
50 fullname = fullname.replace(os.sep, '/')
51 out.write(" \"")
52 out.write(fullname)
53 out.write("\"")
54
55 out.write("\n")
56 out.close()
57
58