Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
distutils.emxccompiler.EMXCCompiler Class Reference
Inheritance diagram for distutils.emxccompiler.EMXCCompiler:
Inheritance graph
[legend]
Collaboration diagram for distutils.emxccompiler.EMXCCompiler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def link
def object_filenames
def find_library_file
def preprocess
def create_static_lib
def library_dir_option
def runtime_library_dir_option
def library_option

Public Attributes

 dll_libraries

Static Public Attributes

string compiler_type = 'emx'
string obj_extension = ".obj"
string static_lib_extension = ".lib"
string shared_lib_extension = ".dll"
string static_lib_format = "%s%s"
string shared_lib_format = "%s%s"
string res_extension = ".res"
string exe_extension = ".exe"
dictionary executables
list src_extensions = [".c",".C",".cc",".cxx",".cpp",".m"]
string dylib_lib_extension = ".dylib"

Private Member Functions

def _compile

Detailed Description

Definition at line 29 of file emxccompiler.py.


Constructor & Destructor Documentation

def distutils.emxccompiler.EMXCCompiler.__init__ (   self,
  verbose = 0,
  dry_run = 0,
  force = 0 
)

Definition at line 43 of file emxccompiler.py.

00043 
00044                   force=0):
00045 
00046         UnixCCompiler.__init__ (self, verbose, dry_run, force)
00047 
00048         (status, details) = check_config_h()
00049         self.debug_print("Python's GCC status: %s (details: %s)" %
00050                          (status, details))
00051         if status is not CONFIG_H_OK:
00052             self.warn(
00053                 "Python's pyconfig.h doesn't seem to support your compiler.  " +
00054                 ("Reason: %s." % details) +
00055                 "Compiling may fail because of undefined preprocessor macros.")
00056 
00057         (self.gcc_version, self.ld_version) = \
00058             get_versions()
00059         self.debug_print(self.compiler_type + ": gcc %s, ld %s\n" %
00060                          (self.gcc_version,
00061                           self.ld_version) )
00062 
00063         # Hard-code GCC because that's what this is all about.
00064         # XXX optimization, warnings etc. should be customizable.
00065         self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
00066                              compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
00067                              linker_exe='gcc -Zomf -Zmt -Zcrtdll',
00068                              linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')
00069 
00070         # want the gcc library statically linked (so that we don't have
00071         # to distribute a version dependent on the compiler we have)
00072         self.dll_libraries=["gcc"]

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def distutils.emxccompiler.EMXCCompiler._compile (   self,
  obj,
  src,
  ext,
  cc_args,
  extra_postargs,
  pp_opts 
) [private]

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 75 of file emxccompiler.py.

00075 
00076     def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
00077         if ext == '.rc':
00078             # gcc requires '.rc' compiled to binary ('.res') files !!!
00079             try:
00080                 self.spawn(["rc", "-r", src])
00081             except DistutilsExecError as msg:
00082                 raise CompileError(msg)
00083         else: # for other files use the C-compiler
00084             try:
00085                 self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
00086                            extra_postargs)
00087             except DistutilsExecError as msg:
00088                 raise CompileError(msg)

Here is the call graph for this function:

def distutils.unixccompiler.UnixCCompiler.create_static_lib (   self,
  objects,
  output_libname,
  output_dir = None,
  debug = 0,
  target_lang = None 
) [inherited]

Definition at line 179 of file unixccompiler.py.

00179 
00180                           output_dir=None, debug=0, target_lang=None):
00181         objects, output_dir = self._fix_object_args(objects, output_dir)
00182 
00183         output_filename = \
00184             self.library_filename(output_libname, output_dir=output_dir)
00185 
00186         if self._need_link(objects, output_filename):
00187             self.mkpath(os.path.dirname(output_filename))
00188             self.spawn(self.archiver +
00189                        [output_filename] +
00190                        objects + self.objects)
00191 
00192             # Not many Unices required ranlib anymore -- SunOS 4.x is, I
00193             # think the only major Unix that does.  Maybe we need some
00194             # platform intelligence here to skip ranlib if it's not
00195             # needed -- or maybe Python's configure script took care of
00196             # it for us, hence the check for leading colon.
00197             if self.ranlib:
00198                 try:
00199                     self.spawn(self.ranlib + [output_filename])
00200                 except DistutilsExecError as msg:
00201                     raise LibError(msg)
00202         else:
00203             log.debug("skipping %s (up-to-date)", output_filename)

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.emxccompiler.EMXCCompiler.find_library_file (   self,
  dirs,
  lib,
  debug = 0 
)

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 207 of file emxccompiler.py.

00207 
00208     def find_library_file(self, dirs, lib, debug=0):
00209         shortlib = '%s.lib' % lib
00210         longlib = 'lib%s.lib' % lib    # this form very rare
00211 
00212         # get EMX's default library directory search path
00213         try:
00214             emx_dirs = os.environ['LIBRARY_PATH'].split(';')
00215         except KeyError:
00216             emx_dirs = []
00217 
00218         for dir in dirs + emx_dirs:
00219             shortlibp = os.path.join(dir, shortlib)
00220             longlibp = os.path.join(dir, longlib)
00221             if os.path.exists(shortlibp):
00222                 return shortlibp
00223             elif os.path.exists(longlibp):
00224                 return longlibp
00225 
00226         # Oops, didn't find it in *any* of 'dirs'
00227         return None
00228 
00229 # class EMXCCompiler
00230 
00231 
00232 # Because these compilers aren't configured in Python's pyconfig.h file by
00233 # default, we should at least warn the user if he is using a unmodified
00234 # version.

Here is the call graph for this function:

def distutils.unixccompiler.UnixCCompiler.library_dir_option (   self,
  dir 
) [inherited]

Definition at line 262 of file unixccompiler.py.

00262 
00263     def library_dir_option(self, dir):
00264         return "-L" + dir

def distutils.unixccompiler.UnixCCompiler.library_option (   self,
  lib 
) [inherited]

Definition at line 310 of file unixccompiler.py.

00310 
00311     def library_option(self, lib):
00312         return "-l" + lib

def distutils.emxccompiler.EMXCCompiler.link (   self,
  target_desc,
  objects,
  output_filename,
  output_dir = None,
  libraries = None,
  library_dirs = None,
  runtime_library_dirs = None,
  export_symbols = None,
  debug = 0,
  extra_preargs = None,
  extra_postargs = None,
  build_temp = None,
  target_lang = None 
)

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 102 of file emxccompiler.py.

00102 
00103               target_lang=None):
00104 
00105         # use separate copies, so we can modify the lists
00106         extra_preargs = copy.copy(extra_preargs or [])
00107         libraries = copy.copy(libraries or [])
00108         objects = copy.copy(objects or [])
00109 
00110         # Additional libraries
00111         libraries.extend(self.dll_libraries)
00112 
00113         # handle export symbols by creating a def-file
00114         # with executables this only works with gcc/ld as linker
00115         if ((export_symbols is not None) and
00116             (target_desc != self.EXECUTABLE)):
00117             # (The linker doesn't do anything if output is up-to-date.
00118             # So it would probably better to check if we really need this,
00119             # but for this we had to insert some unchanged parts of
00120             # UnixCCompiler, and this is not what we want.)
00121 
00122             # we want to put some files in the same directory as the
00123             # object files are, build_temp doesn't help much
00124             # where are the object files
00125             temp_dir = os.path.dirname(objects[0])
00126             # name of dll to give the helper files the same base name
00127             (dll_name, dll_extension) = os.path.splitext(
00128                 os.path.basename(output_filename))
00129 
00130             # generate the filenames for these files
00131             def_file = os.path.join(temp_dir, dll_name + ".def")
00132 
00133             # Generate .def file
00134             contents = [
00135                 "LIBRARY %s INITINSTANCE TERMINSTANCE" % \
00136                 os.path.splitext(os.path.basename(output_filename))[0],
00137                 "DATA MULTIPLE NONSHARED",
00138                 "EXPORTS"]
00139             for sym in export_symbols:
00140                 contents.append('  "%s"' % sym)
00141             self.execute(write_file, (def_file, contents),
00142                          "writing %s" % def_file)
00143 
00144             # next add options for def-file and to creating import libraries
00145             # for gcc/ld the def-file is specified as any other object files
00146             objects.append(def_file)
00147 
00148         #end: if ((export_symbols is not None) and
00149         #        (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
00150 
00151         # who wants symbols and a many times larger output file
00152         # should explicitly switch the debug mode on
00153         # otherwise we let dllwrap/ld strip the output file
00154         # (On my machine: 10KB < stripped_file < ??100KB
00155         #   unstripped_file = stripped_file + XXX KB
00156         #  ( XXX=254 for a typical python extension))
00157         if not debug:
00158             extra_preargs.append("-s")
00159 
00160         UnixCCompiler.link(self,
00161                            target_desc,
00162                            objects,
00163                            output_filename,
00164                            output_dir,
00165                            libraries,
00166                            library_dirs,
00167                            runtime_library_dirs,
00168                            None, # export_symbols, we do this in our def-file
00169                            debug,
00170                            extra_preargs,
00171                            extra_postargs,
00172                            build_temp,
00173                            target_lang)

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.emxccompiler.EMXCCompiler.object_filenames (   self,
  source_filenames,
  strip_dir = 0,
  output_dir = '' 
)

Definition at line 183 of file emxccompiler.py.

00183 
00184                           output_dir=''):
00185         if output_dir is None: output_dir = ''
00186         obj_names = []
00187         for src_name in source_filenames:
00188             # use normcase to make sure '.rc' is really '.rc' and not '.RC'
00189             (base, ext) = os.path.splitext (os.path.normcase(src_name))
00190             if ext not in (self.src_extensions + ['.rc']):
00191                 raise UnknownFileError("unknown file type '%s' (from '%s')" % \
00192                       (ext, src_name))
00193             if strip_dir:
00194                 base = os.path.basename (base)
00195             if ext == '.rc':
00196                 # these need to be compiled to object files
00197                 obj_names.append (os.path.join (output_dir,
00198                                             base + self.res_extension))
00199             else:
00200                 obj_names.append (os.path.join (output_dir,
00201                                             base + self.obj_extension))
00202         return obj_names

Here is the caller graph for this function:

def distutils.unixccompiler.UnixCCompiler.preprocess (   self,
  source,
  output_file = None,
  macros = None,
  include_dirs = None,
  extra_preargs = None,
  extra_postargs = None 
) [inherited]

Definition at line 143 of file unixccompiler.py.

00143 
00144                    include_dirs=None, extra_preargs=None, extra_postargs=None):
00145         fixed_args = self._fix_compile_args(None, macros, include_dirs)
00146         ignore, macros, include_dirs = fixed_args
00147         pp_opts = gen_preprocess_options(macros, include_dirs)
00148         pp_args = self.preprocessor + pp_opts
00149         if output_file:
00150             pp_args.extend(['-o', output_file])
00151         if extra_preargs:
00152             pp_args[:0] = extra_preargs
00153         if extra_postargs:
00154             pp_args.extend(extra_postargs)
00155         pp_args.append(source)
00156 
00157         # We need to preprocess: either we're being forced to, or we're
00158         # generating output to stdout, or there's a target output file and
00159         # the source file is newer than the target (or the target doesn't
00160         # exist).
00161         if self.force or output_file is None or newer(source, output_file):
00162             if output_file:
00163                 self.mkpath(os.path.dirname(output_file))
00164             try:
00165                 self.spawn(pp_args)
00166             except DistutilsExecError as msg:
00167                 raise CompileError(msg)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 268 of file unixccompiler.py.

00268 
00269     def runtime_library_dir_option(self, dir):
00270         # XXX Hackish, at the very least.  See Python bug #445902:
00271         # http://sourceforge.net/tracker/index.php
00272         #   ?func=detail&aid=445902&group_id=5470&atid=105470
00273         # Linkers on different platforms need different options to
00274         # specify that directories need to be added to the list of
00275         # directories searched for dependencies when a dynamic library
00276         # is sought.  GCC on GNU systems (Linux, FreeBSD, ...) has to
00277         # be told to pass the -R option through to the linker, whereas
00278         # other compilers and gcc on other systems just know this.
00279         # Other compilers may need something slightly different.  At
00280         # this time, there's no way to determine this information from
00281         # the configuration data stored in the Python installation, so
00282         # we use this hack.
00283         compiler = os.path.basename(sysconfig.get_config_var("CC"))
00284         if sys.platform[:6] == "darwin":
00285             # MacOSX's linker doesn't understand the -R flag at all
00286             return "-L" + dir
00287         elif sys.platform[:5] == "hp-ux":
00288             if self._is_gcc(compiler):
00289                 return ["-Wl,+s", "-L" + dir]
00290             return ["+s", "-L" + dir]
00291         elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5":
00292             return ["-rpath", dir]
00293         else:
00294             if self._is_gcc(compiler):
00295                 # gcc on non-GNU systems does not need -Wl, but can
00296                 # use it anyway.  Since distutils has always passed in
00297                 # -Wl whenever gcc was used in the past it is probably
00298                 # safest to keep doing so.
00299                 if sysconfig.get_config_var("GNULD") == "yes":
00300                     # GNU ld needs an extra option to get a RUNPATH
00301                     # instead of just an RPATH.
00302                     return "-Wl,--enable-new-dtags,-R" + dir
00303                 else:
00304                     return "-Wl,-R" + dir
00305             else:
00306                 # No idea how --enable-new-dtags would be passed on to
00307                 # ld if this system was using GNU ld.  Don't know if a
00308                 # system like this even exists.
00309                 return "-R" + dir

Here is the call graph for this function:


Member Data Documentation

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 31 of file emxccompiler.py.

Definition at line 71 of file emxccompiler.py.

Definition at line 137 of file unixccompiler.py.

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 38 of file emxccompiler.py.

Initial value:
{'preprocessor' : None,
                   'compiler'     : ["cc"],
                   'compiler_so'  : ["cc"],
                   'compiler_cxx' : ["cc"],
                   'linker_so'    : ["cc", "-shared"],
                   'linker_exe'   : ["cc"],
                   'archiver'     : ["ar", "-cr"],
                   'ranlib'       : None,
                  }

Definition at line 114 of file unixccompiler.py.

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 32 of file emxccompiler.py.

Definition at line 37 of file emxccompiler.py.

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 34 of file emxccompiler.py.

Definition at line 36 of file emxccompiler.py.

list distutils.unixccompiler.UnixCCompiler.src_extensions = [".c",".C",".cc",".cxx",".cpp",".m"] [static, inherited]

Definition at line 133 of file unixccompiler.py.

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 33 of file emxccompiler.py.

Reimplemented from distutils.unixccompiler.UnixCCompiler.

Definition at line 35 of file emxccompiler.py.


The documentation for this class was generated from the following file: