Lines 84-91
Link Here
|
84 |
filename = _build_ext.get_ext_filename(self,fullname) |
84 |
filename = _build_ext.get_ext_filename(self,fullname) |
85 |
ext = self.ext_map[fullname] |
85 |
ext = self.ext_map[fullname] |
86 |
if isinstance(ext,Library): |
86 |
if isinstance(ext,Library): |
|
|
87 |
if ext.force_shared and not use_stubs: |
88 |
_libtype = 'shared' |
89 |
else: |
90 |
_libtype = libtype |
87 |
fn, ext = os.path.splitext(filename) |
91 |
fn, ext = os.path.splitext(filename) |
88 |
return self.shlib_compiler.library_filename(fn,libtype) |
92 |
return self.shlib_compiler.library_filename(fn,_libtype) |
89 |
elif use_stubs and ext._links_to_dynamic: |
93 |
elif use_stubs and ext._links_to_dynamic: |
90 |
d,fn = os.path.split(filename) |
94 |
d,fn = os.path.split(filename) |
91 |
return os.path.join(d,'dl-'+fn) |
95 |
return os.path.join(d,'dl-'+fn) |
Lines 170-183
Link Here
|
170 |
def build_extension(self, ext): |
174 |
def build_extension(self, ext): |
171 |
_compiler = self.compiler |
175 |
_compiler = self.compiler |
172 |
try: |
176 |
try: |
|
|
177 |
force_shared = False |
173 |
if isinstance(ext,Library): |
178 |
if isinstance(ext,Library): |
174 |
self.compiler = self.shlib_compiler |
179 |
self.compiler = self.shlib_compiler |
|
|
180 |
force_shared = ext.force_shared and not use_stubs |
181 |
if force_shared: |
182 |
self.compiler.link_shared_object = \ |
183 |
sh_link_shared_object.__get__(self.compiler) |
175 |
_build_ext.build_extension(self,ext) |
184 |
_build_ext.build_extension(self,ext) |
176 |
if ext._needs_stub: |
185 |
if ext._needs_stub: |
177 |
self.write_stub( |
186 |
self.write_stub( |
178 |
self.get_finalized_command('build_py').build_lib, ext |
187 |
self.get_finalized_command('build_py').build_lib, ext |
179 |
) |
188 |
) |
180 |
finally: |
189 |
finally: |
|
|
190 |
if force_shared: |
191 |
self.compiler.link_shared_object = \ |
192 |
link_shared_object.__get__(self.compiler) |
181 |
self.compiler = _compiler |
193 |
self.compiler = _compiler |
182 |
|
194 |
|
183 |
def links_to_dynamic(self, ext): |
195 |
def links_to_dynamic(self, ext): |
Lines 244-287
Link Here
|
244 |
os.unlink(stub_file) |
256 |
os.unlink(stub_file) |
245 |
|
257 |
|
246 |
|
258 |
|
247 |
if use_stubs or os.name=='nt': |
259 |
def sh_link_shared_object(self, objects, output_libname, output_dir=None, |
248 |
# Build shared libraries |
260 |
libraries=None, library_dirs=None, runtime_library_dirs=None, |
249 |
# |
261 |
export_symbols=None, debug=0, extra_preargs=None, |
250 |
def link_shared_object(self, objects, output_libname, output_dir=None, |
262 |
extra_postargs=None, build_temp=None, target_lang=None |
251 |
libraries=None, library_dirs=None, runtime_library_dirs=None, |
263 |
): self.link(self.SHARED_LIBRARY, objects, output_libname, |
252 |
export_symbols=None, debug=0, extra_preargs=None, |
264 |
output_dir, libraries, library_dirs, runtime_library_dirs, |
253 |
extra_postargs=None, build_temp=None, target_lang=None |
265 |
export_symbols, debug, extra_preargs, extra_postargs, |
254 |
): self.link( |
266 |
build_temp, target_lang) |
255 |
self.SHARED_LIBRARY, objects, output_libname, |
|
|
256 |
output_dir, libraries, library_dirs, runtime_library_dirs, |
257 |
export_symbols, debug, extra_preargs, extra_postargs, |
258 |
build_temp, target_lang |
259 |
) |
260 |
else: |
261 |
# Build static libraries everywhere else |
262 |
libtype = 'static' |
263 |
|
267 |
|
264 |
def link_shared_object(self, objects, output_libname, output_dir=None, |
268 |
def st_link_shared_object(self, objects, output_libname, output_dir=None, |
265 |
libraries=None, library_dirs=None, runtime_library_dirs=None, |
269 |
libraries=None, library_dirs=None, runtime_library_dirs=None, |
266 |
export_symbols=None, debug=0, extra_preargs=None, |
270 |
export_symbols=None, debug=0, extra_preargs=None, |
267 |
extra_postargs=None, build_temp=None, target_lang=None |
271 |
extra_postargs=None, build_temp=None, target_lang=None |
268 |
): |
272 |
): |
269 |
# XXX we need to either disallow these attrs on Library instances, |
273 |
# XXX we need to either disallow these attrs on Library instances, |
270 |
# or warn/abort here if set, or something... |
274 |
# or warn/abort here if set, or something... |
271 |
#libraries=None, library_dirs=None, runtime_library_dirs=None, |
275 |
#libraries=None, library_dirs=None, runtime_library_dirs=None, |
272 |
#export_symbols=None, extra_preargs=None, extra_postargs=None, |
276 |
#export_symbols=None, extra_preargs=None, extra_postargs=None, |
273 |
#build_temp=None |
277 |
#build_temp=None |
274 |
|
278 |
|
275 |
assert output_dir is None # distutils build_ext doesn't pass this |
279 |
assert output_dir is None # distutils build_ext doesn't pass this |
276 |
output_dir,filename = os.path.split(output_libname) |
280 |
output_dir,filename = os.path.split(output_libname) |
277 |
basename, ext = os.path.splitext(filename) |
281 |
basename, ext = os.path.splitext(filename) |
278 |
if self.library_filename("x").startswith('lib'): |
282 |
if self.library_filename("x").startswith('lib'): |
279 |
# strip 'lib' prefix; this is kludgy if some platform uses |
283 |
# strip 'lib' prefix; this is kludgy if some platform uses |
280 |
# a different prefix |
284 |
# a different prefix |
281 |
basename = basename[3:] |
285 |
basename = basename[3:] |
282 |
|
286 |
|
283 |
self.create_static_lib( |
287 |
self.create_static_lib(objects, basename, output_dir, debug, target_lang) |
284 |
objects, basename, output_dir, debug, target_lang |
|
|
285 |
) |
286 |
|
288 |
|
287 |
|
289 |
|
|
|
290 |
if use_stubs or os.name=='nt': |
291 |
# Build shared libraries |
292 |
link_shared_object = sh_link_shared_object |
293 |
else: |
294 |
# Build static libraries everywhere else (unless force_shared) |
295 |
libtype = 'static' |
296 |
link_shared_object = st_link_shared_object |