OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 ''' | 3 ''' |
4 Copyright 2014 Google Inc. | 4 Copyright 2014 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 ''' | 8 ''' |
9 | 9 |
10 import os | 10 import os |
11 import optparse | 11 import optparse |
12 import posixpath | 12 import posixpath |
13 import re | 13 import re |
14 | 14 |
15 | 15 |
16 def is_ignored(full_path, ignore_list): | 16 def is_ignored(full_path, ignore_list): |
17 for ignore_path in ignore_list: | 17 for ignore_path in ignore_list: |
18 if re.match(full_path, ignore_path, re.I): | 18 if re.search(ignore_path, full_path, re.I): |
19 return True | 19 return True |
20 return False | 20 return False |
21 | 21 |
22 | 22 |
23 def find_header_files(include_dirs, ignore_list): | 23 def find_header_files(include_dirs, ignore_list): |
24 """Return a list of all '.h' files in top_dir. | 24 """Return a list of all '.h' files in top_dir. |
25 | 25 |
26 Args: | 26 Args: |
27 include_dirs: Paths to the directories within which to recursively search | 27 include_dirs: Paths to the directories within which to recursively search |
28 for files ending in '.h' | 28 for files ending in '.h' |
(...skipping 30 matching lines...) Expand all Loading... |
59 | 59 |
60 def main(): | 60 def main(): |
61 parser = optparse.OptionParser() | 61 parser = optparse.OptionParser() |
62 parser.add_option("--ignore", action="store", type="string", dest="ignore", | 62 parser.add_option("--ignore", action="store", type="string", dest="ignore", |
63 help="file to write the processed sources array to.") | 63 help="file to write the processed sources array to.") |
64 parser.set_usage("""generate_include_cpp out.cpp include_dir | 64 parser.set_usage("""generate_include_cpp out.cpp include_dir |
65 out.cpp: C++ code to be generated. | 65 out.cpp: C++ code to be generated. |
66 include_dirs: directories to traverse for include files""") | 66 include_dirs: directories to traverse for include files""") |
67 (options, args) = parser.parse_args() | 67 (options, args) = parser.parse_args() |
68 | 68 |
69 GenerateIncludeCPP(args[0], args[1:], options.ignore.split()) | 69 # The MSVS gyp generator uses windows path separators so we intercept those |
| 70 # strings and normalize them to our expected posix representation |
| 71 include_dirs = [] |
| 72 for include_dir in args[1:]: |
| 73 include_dirs.append(include_dir.replace("\\", "/")) |
| 74 ignore_list = options.ignore.replace("\\", "/") |
| 75 |
| 76 # We can strip off the relative portion of the path to ensure that when we |
| 77 # compare for regex matches we don't fail based on relative path depth |
| 78 ignore_list = ignore_list.replace("../", "") |
| 79 |
| 80 GenerateIncludeCPP(args[0], include_dirs, ignore_list.split()) |
70 | 81 |
71 | 82 |
72 if __name__ == "__main__": | 83 if __name__ == "__main__": |
73 main() | 84 main() |
OLD | NEW |