mirror of https://github.com/python/cpython
Catch up with latest changes in CCompiler:
- add 'extra_preargs' and 'extra_postargs' parameters (and use them!) - added 'compiler_type' class attribute - respect reordered arguments to 'gen_lib_options()'
This commit is contained in:
parent
802d6b7b4c
commit
0e3530ba28
|
@ -53,6 +53,8 @@ class UnixCCompiler (CCompiler):
|
||||||
# are specified via {add,set}_include_dirs(), and there's no way to
|
# are specified via {add,set}_include_dirs(), and there's no way to
|
||||||
# distinguish them. This might be a bug.
|
# distinguish them. This might be a bug.
|
||||||
|
|
||||||
|
compiler_type = 'unix'
|
||||||
|
|
||||||
_obj_ext = '.o'
|
_obj_ext = '.o'
|
||||||
_exe_ext = ''
|
_exe_ext = ''
|
||||||
_shared_lib_ext = SO
|
_shared_lib_ext = SO
|
||||||
|
@ -89,7 +91,9 @@ class UnixCCompiler (CCompiler):
|
||||||
sources,
|
sources,
|
||||||
output_dir=None,
|
output_dir=None,
|
||||||
macros=None,
|
macros=None,
|
||||||
includes=None):
|
includes=None,
|
||||||
|
extra_preargs=None,
|
||||||
|
extra_postargs=None):
|
||||||
|
|
||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
output_dir = self.output_dir
|
output_dir = self.output_dir
|
||||||
|
@ -130,6 +134,10 @@ class UnixCCompiler (CCompiler):
|
||||||
cc_args = ['-c'] + pp_opts + \
|
cc_args = ['-c'] + pp_opts + \
|
||||||
self.ccflags + self.ccflags_shared + \
|
self.ccflags + self.ccflags_shared + \
|
||||||
sources
|
sources
|
||||||
|
if extra_preargs:
|
||||||
|
cc_args[:0] = extra_preargs
|
||||||
|
if extra_postargs:
|
||||||
|
cc_args.extend (extra_postargs)
|
||||||
self.spawn ([self.cc] + cc_args)
|
self.spawn ([self.cc] + cc_args)
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,7 +172,8 @@ class UnixCCompiler (CCompiler):
|
||||||
output_dir=None,
|
output_dir=None,
|
||||||
libraries=None,
|
libraries=None,
|
||||||
library_dirs=None,
|
library_dirs=None,
|
||||||
build_info=None):
|
extra_preargs=None,
|
||||||
|
extra_postargs=None):
|
||||||
# XXX should we sanity check the library name? (eg. no
|
# XXX should we sanity check the library name? (eg. no
|
||||||
# slashes)
|
# slashes)
|
||||||
self.link_shared_object (
|
self.link_shared_object (
|
||||||
|
@ -173,7 +182,8 @@ class UnixCCompiler (CCompiler):
|
||||||
output_dir,
|
output_dir,
|
||||||
libraries,
|
libraries,
|
||||||
library_dirs,
|
library_dirs,
|
||||||
build_info)
|
extra_preargs,
|
||||||
|
extra_postargs)
|
||||||
|
|
||||||
|
|
||||||
def link_shared_object (self,
|
def link_shared_object (self,
|
||||||
|
@ -182,7 +192,8 @@ class UnixCCompiler (CCompiler):
|
||||||
output_dir=None,
|
output_dir=None,
|
||||||
libraries=None,
|
libraries=None,
|
||||||
library_dirs=None,
|
library_dirs=None,
|
||||||
build_info=None):
|
extra_preargs=None,
|
||||||
|
extra_postargs=None):
|
||||||
|
|
||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
output_dir = self.output_dir
|
output_dir = self.output_dir
|
||||||
|
@ -190,12 +201,10 @@ class UnixCCompiler (CCompiler):
|
||||||
libraries = []
|
libraries = []
|
||||||
if library_dirs is None:
|
if library_dirs is None:
|
||||||
library_dirs = []
|
library_dirs = []
|
||||||
if build_info is None:
|
|
||||||
build_info = {}
|
|
||||||
|
|
||||||
lib_opts = gen_lib_options (self.libraries + libraries,
|
lib_opts = gen_lib_options (self.library_dirs + library_dirs,
|
||||||
self.library_dirs + library_dirs,
|
self.libraries + libraries,
|
||||||
"-l%s", "-L%s")
|
"-L%s", "-l%s")
|
||||||
if output_dir is not None:
|
if output_dir is not None:
|
||||||
output_filename = os.path.join (output_dir, output_filename)
|
output_filename = os.path.join (output_dir, output_filename)
|
||||||
|
|
||||||
|
@ -215,7 +224,10 @@ class UnixCCompiler (CCompiler):
|
||||||
if newer:
|
if newer:
|
||||||
ld_args = self.ldflags_shared + lib_opts + \
|
ld_args = self.ldflags_shared + lib_opts + \
|
||||||
objects + ['-o', output_filename]
|
objects + ['-o', output_filename]
|
||||||
|
if extra_preargs:
|
||||||
|
ld_args[:0] = extra_preargs
|
||||||
|
if extra_postargs:
|
||||||
|
ld_args.extend (extra_postargs)
|
||||||
self.spawn ([self.ld_shared] + ld_args)
|
self.spawn ([self.ld_shared] + ld_args)
|
||||||
else:
|
else:
|
||||||
self.announce ("skipping %s (up-to-date)" % output_filename)
|
self.announce ("skipping %s (up-to-date)" % output_filename)
|
||||||
|
|
Loading…
Reference in New Issue