Package distutils :: Module mwerkscompiler :: Class MWerksCompiler
[hide private]
[frames] | no frames]

Class MWerksCompiler

ccompiler.CCompiler --+
                      |
                     MWerksCompiler

Concrete class that implements an interface to MetroWerks CodeWarrior, as defined by the CCompiler abstract class.

Instance Methods [hide private]
 
__init__(self, verbose=0, dry_run=0, force=0)
 
compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None)
Compile one or more source files.
 
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)
Link a bunch of stuff together to create an executable or shared library file.
 
_filename_to_abs(self, filename)
 
library_dir_option(self, dir)
Return the compiler option to add 'dir' to the list of directories searched for libraries.
 
runtime_library_dir_option(self, dir)
Return the compiler option to add 'dir' to the list of directories searched for runtime libraries.
 
library_option(self, lib)
Return the compiler option to add 'dir' to the list of libraries linked into the shared library or executable.
 
find_library_file(self, dirs, lib, debug=0)
Search the specified list of directories for a static or shared library file 'lib' and return the full path to that file.

Inherited from ccompiler.CCompiler: add_include_dir, add_library, add_library_dir, add_link_object, add_runtime_library_dir, announce, create_static_lib, debug_print, define_macro, detect_language, executable_filename, execute, has_function, library_filename, link_executable, link_shared_lib, link_shared_object, mkpath, move_file, object_filenames, preprocess, set_executable, set_executables, set_include_dirs, set_libraries, set_library_dirs, set_link_objects, set_runtime_library_dirs, shared_object_filename, spawn, undefine_macro, warn

Class Variables [hide private]
  compiler_type = 'mwerks'
  executables = {}
  _c_extensions = ['.c']
  _cpp_extensions = ['.cc', '.cpp', '.cxx']
  _rc_extensions = ['.r']
  _exp_extension = '.exp'
  src_extensions = _c_extensions+ _cpp_extensions+ _rc_extensions
  res_extension = '.rsrc'
  obj_extension = '.obj'
  static_lib_extension = '.lib'
  shared_lib_extension = '.slb'
  shared_lib_format = '%s%s'
  static_lib_format = '%s%s'
  exe_extension = ''

Inherited from ccompiler.CCompiler: EXECUTABLE, SHARED_LIBRARY, SHARED_OBJECT, language_map, language_order

Method Details [hide private]

__init__(self, verbose=0, dry_run=0, force=0)
(Constructor)

 
Overrides: ccompiler.CCompiler.__init__

compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None)

 

Compile one or more source files.

'sources' must be a list of filenames, most likely C/C++ files, but in reality anything that can be handled by a particular compiler and compiler class (eg. MSVCCompiler can handle resource files in 'sources'). Return a list of object filenames, one per source filename in 'sources'. Depending on the implementation, not all source files will necessarily be compiled, but all corresponding object filenames will be returned.

If 'output_dir' is given, object files will be put under it, while retaining their original path component. That is, "foo/bar.c" normally compiles to "foo/bar.o" (for a Unix implementation); if 'output_dir' is "build", then it would compile to "build/foo/bar.o".

'macros', if given, must be a list of macro definitions. A macro definition is either a (name, value) 2-tuple or a (name,) 1-tuple. The former defines a macro; if the value is None, the macro is defined without an explicit value. The 1-tuple case undefines a macro. Later definitions/redefinitions/ undefinitions take precedence.

'include_dirs', if given, must be a list of strings, the directories to add to the default include file search path for this compilation only.

'debug' is a boolean; if true, the compiler will be instructed to output debug symbols in (or alongside) the object file(s).

'extra_preargs' and 'extra_postargs' are implementation- dependent. On platforms that have the notion of a command-line (e.g. Unix, DOS/Windows), they are most likely lists of strings: extra command-line arguments to prepand/append to the compiler command line. On other platforms, consult the implementation class documentation. In any event, they are intended as an escape hatch for those occasions when the abstract compiler framework doesn't cut the mustard.

'depends', if given, is a list of filenames that all targets depend on. If a source file is older than any file in depends, then the source file will be recompiled. This supports dependency tracking, but only at a coarse granularity.

Raises CompileError on failure.

Overrides: ccompiler.CCompiler.compile
(inherited documentation)

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)

 

Link a bunch of stuff together to create an executable or shared library file.

The "bunch of stuff" consists of the list of object files supplied as 'objects'. 'output_filename' should be a filename. If 'output_dir' is supplied, 'output_filename' is relative to it (i.e. 'output_filename' can provide directory components if needed).

'libraries' is a list of libraries to link against. These are library names, not filenames, since they're translated into filenames in a platform-specific way (eg. "foo" becomes "libfoo.a" on Unix and "foo.lib" on DOS/Windows). However, they can include a directory component, which means the linker will look in that specific directory rather than searching all the normal locations.

'library_dirs', if supplied, should be a list of directories to search for libraries that were specified as bare library names (ie. no directory component). These are on top of the system default and those supplied to 'add_library_dir()' and/or 'set_library_dirs()'. 'runtime_library_dirs' is a list of directories that will be embedded into the shared library and used to search for other shared libraries that *it* depends on at run-time. (This may only be relevant on Unix.)

'export_symbols' is a list of symbols that the shared library will export. (This appears to be relevant only on Windows.)

'debug' is as for 'compile()' and 'create_static_lib()', with the slight distinction that it actually matters on most platforms (as opposed to 'create_static_lib()', which includes a 'debug' flag mostly for form's sake).

'extra_preargs' and 'extra_postargs' are as for 'compile()' (except of course that they supply command-line arguments for the particular linker being used).

'target_lang' is the target language for which the given objects are being compiled. This allows specific linkage time treatment of certain languages.

Raises LinkError on failure.

Overrides: ccompiler.CCompiler.link
(inherited documentation)

library_dir_option(self, dir)

 

Return the compiler option to add 'dir' to the list of directories searched for libraries.

Overrides: ccompiler.CCompiler.library_dir_option

runtime_library_dir_option(self, dir)

 

Return the compiler option to add 'dir' to the list of directories searched for runtime libraries.

Overrides: ccompiler.CCompiler.runtime_library_dir_option

library_option(self, lib)

 

Return the compiler option to add 'dir' to the list of libraries linked into the shared library or executable.

Overrides: ccompiler.CCompiler.library_option

find_library_file(self, dirs, lib, debug=0)

 

Search the specified list of directories for a static or shared library file 'lib' and return the full path to that file. If 'debug' true, look for a debugging version (if that makes sense on the current platform). Return None if 'lib' wasn't found in any of the specified directories.

Overrides: ccompiler.CCompiler.find_library_file