Add control of --line-directives to Distutils build_ext
authorChuck Blake <cb@pdos.csail.mit.edu>
Thu, 10 Jun 2010 14:36:41 +0000 (11:36 -0300)
committerChuck Blake <cb@pdos.csail.mit.edu>
Thu, 10 Jun 2010 14:36:41 +0000 (11:36 -0300)
Cython/Distutils/build_ext.py
Cython/Distutils/extension.py

index fadeaae42a6ee27db78420e359f15ac709704955..1f11ca7f059d5658cb0a20dd675658c67deca375 100644 (file)
@@ -36,6 +36,8 @@ class build_ext(_build_ext.build_ext):
          "generate C++ source files"),
         ('pyrex-create-listing', None,
          "write errors to a listing file"),
+        ('pyrex-line-directives', None,
+         "emit source line directives"),
         ('pyrex-include-dirs=', None,
          "path to the Cython include files" + sep_by),
         ('pyrex-c-in-temp', None,
@@ -45,13 +47,14 @@ class build_ext(_build_ext.build_ext):
         ])
 
     boolean_options.extend([
-        'pyrex-cplus', 'pyrex-create-listing', 'pyrex-c-in-temp'
+        'pyrex-cplus', 'pyrex-create-listing', 'pyrex-line-directives', 'pyrex-c-in-temp'
     ])
 
     def initialize_options(self):
         _build_ext.build_ext.initialize_options(self)
         self.pyrex_cplus = 0
         self.pyrex_create_listing = 0
+        self.pyrex_line_directives = 0
         self.pyrex_include_dirs = None
         self.pyrex_c_in_temp = 0
         self.pyrex_gen_pxi = 0
@@ -114,6 +117,8 @@ class build_ext(_build_ext.build_ext):
         
         create_listing = self.pyrex_create_listing or \
             getattr(extension, 'pyrex_create_listing', 0)
+        line_directives = self.pyrex_line_directives or \
+            getattr(extension, 'pyrex_line_directives', 0)
         cplus = self.pyrex_cplus or getattr(extension, 'pyrex_cplus', 0) or \
                 (extension.language and extension.language.lower() == 'c++')
         pyrex_gen_pxi = self.pyrex_gen_pxi or getattr(extension, 'pyrex_gen_pxi', 0)
@@ -186,6 +191,7 @@ class build_ext(_build_ext.build_ext):
                     include_path = includes,
                     output_file = target,
                     cplus = cplus,
+                    emit_linenums = line_directives,
                     generate_pxi = pyrex_gen_pxi)
                 result = cython_compile(source, options=options,
                                         full_module_name=module_name)
index b9b73755f581484b7b3735eb246c0e6e46f89de2..e781c3e7052a395bf658cf2e629053f957a3ee77 100644 (file)
@@ -21,6 +21,8 @@ class Extension(_Extension.Extension):
         Unix form for portability)
     pyrex_create_listing_file : boolean
         write pyrex error messages to a listing (.lis) file.
+    pyrex_line_directivess : boolean
+        emit pyx line numbers for debugging/profiling
     pyrex_cplus : boolean
         use the C++ compiler for compiling and linking.
     pyrex_c_in_temp : boolean
@@ -47,6 +49,7 @@ class Extension(_Extension.Extension):
             language = None,
             pyrex_include_dirs = None,
             pyrex_create_listing = 0,
+            pyrex_line_directives = 0,
             pyrex_cplus = 0,
             pyrex_c_in_temp = 0,
             pyrex_gen_pxi = 0,
@@ -70,6 +73,7 @@ class Extension(_Extension.Extension):
 
         self.pyrex_include_dirs = pyrex_include_dirs or []
         self.pyrex_create_listing = pyrex_create_listing
+        self.pyrex_line_directives = pyrex_line_directives
         self.pyrex_cplus = pyrex_cplus
         self.pyrex_c_in_temp = pyrex_c_in_temp
         self.pyrex_gen_pxi = pyrex_gen_pxi