diff options
author | Robert Bradshaw <robertwb@gmail.com> | 2017-10-02 23:14:40 -0700 |
---|---|---|
committer | Robert Bradshaw <robertwb@gmail.com> | 2017-10-02 23:14:40 -0700 |
commit | 8514f0f8964bc3ee375566a24095dd515e8e1285 (patch) | |
tree | 448ccc0cbce52329f6f0509b86d3628c008f1227 /Cython/Compiler/ModuleNode.py | |
parent | 1c4f32b93570b41de3c8028711549a32e15b31f1 (diff) | |
parent | 4592586d74f5aa2274b15a85e130abfd684746f3 (diff) | |
download | cython-8514f0f8964bc3ee375566a24095dd515e8e1285.tar.gz |
Merge branch 'late_includes_auto'
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 3c04f0838..e26b87112 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -90,7 +90,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if x not in L1: L1.append(x) - extend_if_not_in(self.scope.include_files, scope.include_files) + extend_if_not_in(self.scope.include_files_early, scope.include_files_early) + extend_if_not_in(self.scope.include_files_late, scope.include_files_late) extend_if_not_in(self.scope.included_files, scope.included_files) extend_if_not_in(self.scope.python_include_files, scope.python_include_files) @@ -362,6 +363,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("") code.putln("/* Implementation of '%s' */" % env.qualified_name) + code = globalstate['late_includes'] + code.putln("/* Late includes */") + self.generate_includes(env, modules, code, early=False) + code = globalstate['all_the_rest'] self.generate_cached_builtins_decls(env, code) @@ -653,7 +658,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("#define %s" % Naming.h_guard_prefix + self.api_name(env)) code.putln("#define %s" % Naming.api_guard_prefix + self.api_name(env)) - self.generate_includes(env, cimported_modules, code) + code.putln("/* Early includes */") + self.generate_includes(env, cimported_modules, code, late=False) code.putln("") code.putln("#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)") code.putln("#define CYTHON_WITHOUT_ASSERTIONS") @@ -727,16 +733,23 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln(" #define DL_IMPORT(_T) _T") code.putln("#endif") - def generate_includes(self, env, cimported_modules, code): + def generate_includes(self, env, cimported_modules, code, early=True, late=True): includes = [] - for filename in env.include_files: + if early: + includes += env.include_files_early + if late: + includes += [include for include in env.include_files_late + if include not in env.include_files_early] + for filename in includes: byte_decoded_filenname = str(filename) + if byte_decoded_filenname[0] == '<' and byte_decoded_filenname[-1] == '>': code.putln('#include %s' % byte_decoded_filenname) else: code.putln('#include "%s"' % byte_decoded_filenname) - code.putln_openmp("#include <omp.h>") + if early: + code.putln_openmp("#include <omp.h>") def generate_filename_table(self, code): from os.path import isabs, basename |