Showing the changes to python (1 of 3 files). Show all
Unified · Split
| @@ -127,22 +127,42 @@ class CleanGenerated(distutils.command.clean.clean): · 126 unmodified lines | |||
| 127 | distutils.dir_util.remove_tree(output_path) | 127 | distutils.dir_util.remove_tree(output_path) |
| 128 | distutils.command.clean.clean.run(self) | 128 | distutils.command.clean.clean.run(self) |
| 129 | 129 | ||
| 130 | class GenerateCommand(distutils.cmd.Command): | 130 | from distutils.command.build_ext import build_ext as _build_ext |
| 131 | description = 'generate gen/gen-*.c files from ../src/aubio.h' | 131 | class build_ext(_build_ext): |
| 132 | user_options = [ | 132 | |
| 133 | user_options = _build_ext.user_options + [ | ||
| 133 | # The format is (long option, short option, description). | 134 | # The format is (long option, short option, description). |
| 134 | ('enable-double', None, 'use HAVE_AUBIO_DOUBLE=1 (default: 0)'), | 135 | ('enable-double', None, 'use HAVE_AUBIO_DOUBLE=1 (default: 0)'), |
| 135 | ] | 136 | ] |
| 136 | 137 | ||
| 137 | def initialize_options(self): | 138 | def initialize_options(self): |
| 139 | _build_ext.initialize_options(self) | ||
| 138 | self.enable_double = False | 140 | self.enable_double = False |
| 139 | 141 | ||
| 140 | def finalize_options(self): | 142 | def finalize_options(self): |
| 143 | _build_ext.finalize_options(self) | ||
| 141 | if self.enable_double: | 144 | if self.enable_double: |
| 142 | self.announce( | 145 | self.announce( |
| 143 | 'will generate code for aubio compiled with HAVE_AUBIO_DOUBLE=1', | 146 | 'will generate code for aubio compiled with HAVE_AUBIO_DOUBLE=1', |
| 144 | level=distutils.log.INFO) | 147 | level=distutils.log.INFO) |
| 145 | 148 | ||
| 146 | def run(self): | 149 | def build_extension(self, extension): |
| 147 | self.announce( 'Generating code', level=distutils.log.INFO) | 150 | if self.enable_double: |
| 148 | generated_object_files = generate_external(header, output_path, usedouble=self.enable_double) | 151 | extension.define_macros += [('HAVE_AUBIO_DOUBLE', 1)] |
| 152 | if os.path.isfile('src/aubio.h'): | ||
| 153 | # if aubio headers are found in this directory | ||
| 154 | add_local_aubio_header(extension) | ||
| 155 | # was waf used to build the shared lib? | ||
| 156 | if os.path.isdir(os.path.join('build','src')): | ||
| 157 | # link against build/src/libaubio, built with waf | ||
| 158 | add_local_aubio_lib(extension) | ||
| 159 | else: | ||
| 160 | # add libaubio sources and look for optional deps with pkg-config | ||
| 161 | add_local_aubio_sources(extension, usedouble=self.enable_double) | ||
| 162 | else: | ||
| 163 | # look for aubio headers and lib using pkg-config | ||
| 164 | add_system_aubio(extension) | ||
| 165 | # generate files python/gen/*.c, python/gen/aubio-generated.h | ||
| 166 | extension.sources += generate_external(header, output_path, overwrite = False, | ||
| 167 | usedouble=self.enable_double) | ||
| 168 | return _build_ext.build_extension(self, extension) | ||