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 | 12 |
13 | 13 |
14 # TARGET_RE matches a GN target, and extracts the target name and the contents. | 14 # 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+)"\) {' | 15 TARGET_RE = re.compile(r'(?P<indent>\s*)\w+\("(?P<target_name>\w+)"\) {' |
16 r'(?P<target_contents>.*?)' | 16 r'(?P<target_contents>.*?)' |
17 r'(?P=indent)}', | 17 r'(?P=indent)}', |
18 re.MULTILINE | re.DOTALL) | 18 re.MULTILINE | re.DOTALL) |
19 | 19 |
20 # SOURCES_RE matches a block of sources inside a GN target. | 20 # SOURCES_RE matches a block of sources inside a GN target. |
21 SOURCES_RE = re.compile(r'sources \+?= \[(?P<sources>.*?)\]', | 21 SOURCES_RE = re.compile( |
22 re.MULTILINE | re.DOTALL) | 22 r'(sources|common_objc_headers) \+?= \[(?P<sources>.*?)\]', |
| 23 re.MULTILINE | re.DOTALL) |
23 | 24 |
24 SOURCE_FILE_RE = re.compile(r'.*\"(?P<source_file>.*)\"') | 25 SOURCE_FILE_RE = re.compile(r'.*\"(?P<source_file>.*)\"') |
25 | 26 |
26 | 27 |
27 class NoBuildGnFoundError(Exception): | 28 class NoBuildGnFoundError(Exception): |
28 pass | 29 pass |
29 | 30 |
30 | 31 |
31 class WrongFileTypeError(Exception): | 32 class WrongFileTypeError(Exception): |
32 pass | 33 pass |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 headers_in_sources = set([]) | 107 headers_in_sources = set([]) |
107 for target_match in TARGET_RE.finditer(file_content): | 108 for target_match in TARGET_RE.finditer(file_content): |
108 target_contents = target_match.group('target_contents') | 109 target_contents = target_match.group('target_contents') |
109 for sources_match in SOURCES_RE.finditer(target_contents): | 110 for sources_match in SOURCES_RE.finditer(target_contents): |
110 sources = sources_match.group('sources') | 111 sources = sources_match.group('sources') |
111 for source_file_match in SOURCE_FILE_RE.finditer(sources): | 112 for source_file_match in SOURCE_FILE_RE.finditer(sources): |
112 source_file = source_file_match.group('source_file') | 113 source_file = source_file_match.group('source_file') |
113 if source_file.endswith('.h'): | 114 if source_file.endswith('.h'): |
114 headers_in_sources.add(os.path.join(target_abs_path, source_file)) | 115 headers_in_sources.add(os.path.join(target_abs_path, source_file)) |
115 return headers_in_sources | 116 return headers_in_sources |
OLD | NEW |