OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 # | 3 # |
4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
9 | 9 |
10 import os | 10 import os |
11 import re | 11 import re |
| 12 import string |
12 | 13 |
13 | 14 |
14 # TARGET_RE matches a GN target, and extracts the target name and the contents. | 15 # TARGET_RE matches a GN target, and extracts the target name and the contents. |
15 TARGET_RE = re.compile(r'(?P<indent>\s*)\w+\("(?P<target_name>\w+)"\) {' | 16 TARGET_RE = re.compile(r'(?P<indent>\s*)\w+\("(?P<target_name>\w+)"\) {' |
16 r'(?P<target_contents>.*?)' | 17 r'(?P<target_contents>.*?)' |
17 r'(?P=indent)}', | 18 r'(?P=indent)}', |
18 re.MULTILINE | re.DOTALL) | 19 re.MULTILINE | re.DOTALL) |
19 | 20 |
20 # SOURCES_RE matches a block of sources inside a GN target. | 21 # SOURCES_RE matches a block of sources inside a GN target. |
21 SOURCES_RE = re.compile( | 22 SOURCES_RE = re.compile( |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 The set contains absolute paths. | 106 The set contains absolute paths. |
106 """ | 107 """ |
107 headers_in_sources = set([]) | 108 headers_in_sources = set([]) |
108 for target_match in TARGET_RE.finditer(file_content): | 109 for target_match in TARGET_RE.finditer(file_content): |
109 target_contents = target_match.group('target_contents') | 110 target_contents = target_match.group('target_contents') |
110 for sources_match in SOURCES_RE.finditer(target_contents): | 111 for sources_match in SOURCES_RE.finditer(target_contents): |
111 sources = sources_match.group('sources') | 112 sources = sources_match.group('sources') |
112 for source_file_match in SOURCE_FILE_RE.finditer(sources): | 113 for source_file_match in SOURCE_FILE_RE.finditer(sources): |
113 source_file = source_file_match.group('source_file') | 114 source_file = source_file_match.group('source_file') |
114 if source_file.endswith('.h'): | 115 if source_file.endswith('.h'): |
115 headers_in_sources.add(os.path.join(target_abs_path, source_file)) | 116 source_file_tokens = string.split(source_file, '/') |
| 117 # pylint: disable=star-args |
| 118 headers_in_sources.add(os.path.join(target_abs_path, |
| 119 *source_file_tokens)) |
116 return headers_in_sources | 120 return headers_in_sources |
OLD | NEW |