diff options
author | Martin Raum <martin@raum-brothers.eu> | 2014-08-14 21:06:09 +0200 |
---|---|---|
committer | Martin Raum <martin@raum-brothers.eu> | 2014-08-14 21:06:09 +0200 |
commit | e3b1cc75f129e55feb9210d40d86104bafef3797 (patch) | |
tree | b58f41c2a541caae56d2c8c5e75233f714e51f8c /Cython/Compiler/ModuleNode.py | |
parent | 705e2d2ec1bff344949a80476fb1c7272991aa71 (diff) | |
download | cython-e3b1cc75f129e55feb9210d40d86104bafef3797.tar.gz |
Table of file names with relative paths.
The previous commit reveals too much information about the system. With
this change only modules of the processed package are expanded. The
expanded path reaches no deeper than the package's root.
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index cf55d3d8f..bb476010e 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -683,11 +683,22 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln_openmp("#include <omp.h>") def generate_filename_table(self, code): + import os.path as path + + full_module_path = path.join(*self.full_module_name.split('.')) + module_abspath = path.splitext(path.abspath( + self.compilation_source.source_desc.get_filenametable_entry() ))[0] + module_relpath = module_abspath[:-len(full_module_path)] + code.putln("") code.putln("static const char *%s[] = {" % Naming.filetable_cname) if code.globalstate.filename_list: for source_desc in code.globalstate.filename_list: - filename = os.path.abspath(source_desc.get_filenametable_entry()) + file_abspath = path.abspath(source_desc.get_filenametable_entry()) + if file_abspath.startswith(module_relpath): + filename = file_abspath[len(module_relpath):] + else: + filename = path.basename(file_abspath) escaped_filename = filename.replace("\\", "\\\\").replace('"', r'\"') code.putln('"%s",' % escaped_filename) else: |