diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2014-01-18 16:34:34 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2014-01-18 16:34:34 +0100 |
commit | 1b741a56ae3d4071950408e3dc3fc8dda4cb5650 (patch) | |
tree | 45c0ef67f77542c39b8d88e741da44f97ebbb91e /Cython/Compiler/ModuleNode.py | |
parent | 593930b85e3ec93172d36f5bf6c8df7c16b113b9 (diff) | |
download | cython-1b741a56ae3d4071950408e3dc3fc8dda4cb5650.tar.gz |
when includes are used, additionally generate one annotation file per included file
--HG--
extra : amend_source : c2b02f8beedd17cdae81256283c30de6f5767e08
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index fe5bfc69d..05750a2d8 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -354,8 +354,29 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if options.gdb_debug: self._serialize_lineno_map(env, rootwriter) if Options.annotate or options.annotate: - self.annotate(rootwriter) - rootwriter.save_annotation(result.main_source_file, result.c_file) + self._generate_annotations(rootwriter, result) + + def _generate_annotations(self, rootwriter, result): + self.annotate(rootwriter) + rootwriter.save_annotation(result.main_source_file, result.c_file) + + # if we included files, additionally generate one annotation file for each + search_include_file = self.scope.context.search_include_directories + target_dir = os.path.dirname(result.c_file) + for included_file in self.scope.included_files: + source_file = search_include_file(included_file, "", self.pos, include=True) + if not source_file: + continue + target_file = os.path.join(target_dir, included_file) + target_file_dir = os.path.dirname(target_file) + if target_file_dir != target_dir and not os.path.exists(target_file_dir): + try: + os.makedirs(target_file_dir) + except OSError, e: + import errno + if e.errno != errno.EEXIST: + raise + rootwriter.save_annotation(source_file, target_file) def _serialize_lineno_map(self, env, ccodewriter): tb = env.context.gdb_debug_outputwriter |