diff options
author | Googler <noreply@google.com> | 2017-04-03 20:31:42 +0000 |
---|---|---|
committer | Marcel Hlopko <hlopko@google.com> | 2017-04-04 10:07:05 +0200 |
commit | fc031e22d0aa3b79f793d097d91832994c1eb5e9 (patch) | |
tree | 7b79f6d062ce8ce84d1f6b5795800becb577426a | |
parent | 3f00727b700e5591218934d7a8df164cd572be65 (diff) |
Scan both .h and .m files for imports and includes
The dependency mappings are generated by scanning the .m files. I found a case where a header file was only imported in the .h file.
RELNOTES: None.
PiperOrigin-RevId: 152050144
-rwxr-xr-x | tools/j2objc/j2objc_wrapper.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/tools/j2objc/j2objc_wrapper.py b/tools/j2objc/j2objc_wrapper.py index 1c97b296ec..cdc1c503b3 100755 --- a/tools/j2objc/j2objc_wrapper.py +++ b/tools/j2objc/j2objc_wrapper.py @@ -142,17 +142,20 @@ def _ReadDepMapping(input_file_queue, output_dep_mapping_queue, return try: - deps = [] - entry = os.path.relpath(os.path.splitext(input_file)[0], output_root) - with file_open(input_file, 'r') as f: - for line in f: - include = _INCLUDE_RE.match(line) - if include: - include_path = include.group(2) - dep = os.path.splitext(include_path)[0] - if dep != entry: - deps.append(dep) - output_dep_mapping_queue.put((entry, deps)) + deps = set() + input_file_name = os.path.splitext(input_file)[0] + entry = os.path.relpath(input_file_name, output_root) + for file_ext in ['.m', '.h']: + with file_open(input_file_name + file_ext, 'r') as f: + for line in f: + include = _INCLUDE_RE.match(line) + if include: + include_path = include.group(2) + dep = os.path.splitext(include_path)[0] + if dep != entry: + deps.add(dep) + + output_dep_mapping_queue.put((entry, sorted(deps))) except Exception as e: # pylint: disable=broad-except error_message_queue.put(str(e)) finally: |