Package mbuild :: Module env :: Class env_t
[frames] | no frames]

Class env_t

source code

object --+
         |
        env_t

The is the environment for compilation. The environment includes a dictionary for holding everything custom about this environment. The default environment includes:

Instance Methods
 
__contains__(self, k) source code
 
__getitem__(self, k)
Read the environment dictionary.
source code
 
__init__(self, init_verbose=1, default_knobs=True)
Build up the environment for compilation.
source code
 
__setitem__(self, k, value)
Write a value to the environment dictionary
source code
 
__str__(self)
Print out the environment
source code
 
add_as_define(self, newdef)
Add a define or list defines to the ASFLAGS
source code
 
add_cc_define(self, newdef)
Add a define or list defines to the CCFLAGS
source code
 
add_common_knobs(self) source code
 
add_cxx_define(self, newdef)
Add a define or list defines to the CXXFLAGS
source code
 
add_default_knobs(self) source code
 
add_define(self, newdef)
Add a define or list defines to the CXXFLAGS and CCFLAGS
source code
 
add_include_dir(self, include_dir)
Add a directory or list of directories to the CPPPATH.
source code
 
add_link_dir(self, link_dir)
Add a directory or list of directories to the LINKPATH.
source code
 
add_system_include_dir(self, sys_include_dir)
Add a directory or list of directories to the SYSTEMINCLUDE.
source code
 
add_to_var(self, var, value)
Add or append value to the environment variable var.
source code
plan_t
assemble(self, source, obj=None)
Indirection function.
source code
 
build(self, work_queue, dag, phase='BUILD', terminate_on_errors=False)
Build everything in the work queue
source code
string or list of strings
build_dir_join(self, files)
Make the file (or list of files) with the build directory name.
source code
plan_t
cc_compile(self, source, obj=None)
Indirection function.
source code
bool
check_mac_ver(self, x, y, z)
Returns: True iff on a mac and the version is later than x.y.z
source code
 
compile(self, dag, sources)
Build all the sources by adding them to the dag.
source code
 
compile_and_link(self, dag, sources, exe, shared_object=False, libs=[])
Build all the sources by adding them to the dag.
source code
 
compile_and_static_lib(self, dag, sources, libname)
Build all the sources by adding them to the dag.
source code
 
copy_settings(self, incoming_env, kwds, replace=False)
Update the environment dictionary with elements of kwds from the dictionary in the incoming_env.
source code
plan_t
cxx_compile(self, source, obj=None)
Indirection function.
source code
string
default_compiler(self)
Default to ms on windows and gnu everywhere else.
source code
plan_t
dynamic_lib(self, objs, libname, relocate=False)
Indirection function.
source code
 
dynamic_lib_name(self, base) source code
 
escape_string(self, s) source code
 
expand(self, command_string, newenv=None)
Alias for expand_string()
source code
string
expand_key(self, k, newenv=None)
Read the the value of k from the environment dictionary, doing recursive substitutions from the environment.
source code
string
expand_string(self, command_string, newenv=None)
Read the environment dictionary, doing recursive substitutions from the environment.
source code
plan_t
link(self, objs, exename, relocate=False)
Indirection function.
source code
 
mac_ver(self) source code
 
make_derived_flags(self)
Put together any derived flags.
source code
string
make_obj(self, flist)
Take file or list of files and return a file or list of files with the OBJEXT extension from the environment.
source code
 
number_of_cpus(self)
Return the number of CPUs or 0 if we don't know anything for sure
source code
bool
on_cygwin(self)
Returns: True iff on cygwin
source code
bool
on_freebsd(self)
Returns: True iff on freebsd
source code
bool
on_ia32(self)
Returns: True iff on IA32
source code
bool
on_intel64(self)
Returns: True iff on Intel64
source code
bool
on_ipf(self)
Returns: True iff on IA64
source code
bool
on_leopard(self)
Returns: True iff on Mac running OS X Leopard 10.5.x
source code
bool
on_linux(self)
Returns: True iff on linux
source code
bool
on_mac(self)
Returns: True iff on Mac OSX Darwin
source code
bool
on_tiger(self)
Returns: True iff on Mac running OS X Tiger 10.4.x
source code
bool
on_windows(self)
Returns: True iff on windows
source code
 
osenv_add_to_front(self, evar, newstring, osenv=None)
Add newstring to front of the environment variable osenv if given if not given add to os.environ
source code
 
parse_args(self, user_default_options=None)
Call this to re-initialize the environment from the command line arguments.
source code
 
path_search(self, exe) source code
 
process_user_settings(self)
Set the initial derived environment settings
source code
 
rc_file(self, rc_file, res_file=None)
Indirection function.
source code
 
remove_from_var(self, var, value)
Remove a substring (or list entry) from env[var].
source code
string
resuffix(self, fn, newext)
Replace the suffix of single fn (or list of files) with newext.
source code
 
set_compiler_env(self, compiler_family=None)
Initialize the build environment based on the compiler environment variable setting.
source code
 
set_defaults(self, dct)
Take the dictionary of defaults and apply to the environment.
source code
 
shared_lib_name(self, base) source code
string or list of strings
src_dir_join(self, files)
Prefix file (or list of files) with the src directory name.
source code
plan_t
static_lib(self, objs, libname, relocate=False)
Indirection function.
source code
 
static_lib_name(self, base) source code
 
supports_avx(self)
Return True if system supports AVX1.
source code
 
update(self, targets=None)
Post process the current environment, setting targets and bindings
source code
 
update_dict(self, dct)
Update the environment dictionary with another dictionary.
source code
 
verbose_startup(self) source code
string
version(self)
Emit the version string.
source code
bool
windows_native(self)
Returns: True iff on windows native -- not using cygwin
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables
  assignment_pattern = re.compile(r'(?P<name>[-A-Za-z0-9_]+)=(?P...
  mbuild_subs_pattern = re.compile(r'%\([^\)]+\)')
  obj_pattern = re.compile(r'.obj$')
  objext_pattern = re.compile(r'%\(OBJEXT\)s$')
  supplement_pattern = re.compile(r'(?P<name>[-A-Za-z0-9_]+)\+=(...
Properties

Inherited from object: __class__

Method Details

__getitem__(self, k)
(Indexing operator)

source code 

Read the environment dictionary. Not doing any substitutions.

__init__(self, init_verbose=1, default_knobs=True)
(Constructor)

source code 

Build up the environment for compilation.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

Print out the environment

Overrides: object.__str__

add_as_define(self, newdef)

source code 

Add a define or list defines to the ASFLAGS

Parameters:
  • newdef (string or list of strings) - string to add to the ASFLAGS environment variable.

add_cc_define(self, newdef)

source code 

Add a define or list defines to the CCFLAGS

Parameters:
  • newdef (string or list of strings) - string to add to the CCFLAGS environment variable.

add_cxx_define(self, newdef)

source code 

Add a define or list defines to the CXXFLAGS

Parameters:
  • newdef (string or list of strings) - string to add to the CXXFLAGS environment variable.

add_define(self, newdef)

source code 

Add a define or list defines to the CXXFLAGS and CCFLAGS

Parameters:
  • newdef (string or list of strings) - string to add to the CXXFLAGS and CCFLAGS environment variables.

add_include_dir(self, include_dir)

source code 

Add a directory or list of directories to the CPPPATH. Just a short cut for adding things to the list of files in the env['CPPPATH']

Parameters:
  • include_dir (string or list of strings) - string to add to the CPPPATH environment variable

add_link_dir(self, link_dir)

source code 

Add a directory or list of directories to the LINKPATH. These get included in the LINKFLAGS

Parameters:
  • link_dir (string or list of strings) - string to add to the LINKPATH variable

add_system_include_dir(self, sys_include_dir)

source code 

Add a directory or list of directories to the SYSTEMINCLUDE. Just a short cut for adding things to the list of files in the env['SYSTEMINCLUDE']

Parameters:
  • sys_include_dir (string or list of strings) - string to add to the SYSTEMINCLUDE environment variable

add_to_var(self, var, value)

source code 

Add or append value to the environment variable var. If the variable is not in the environment, then it is added as is. Otherwise if the variable is in the environment and is a list then value is appended. Otherwise, the value is appended as a string with a leading space. This will *NOT* do variable substitution when adding to a variable.

Parameters:
  • var (string) - name of a dictionary key
  • value (string) - the value to add or append

assemble(self, source, obj=None)

source code 

Indirection function. Reads builder function from the environment variable ASSEMBLER_BUILDER. Assemble a source file to the obj file. If no obj file name is given one will be created in the build directory.

Parameters:
  • source (string) - filename to assemble
  • obj (string) - output filename.
Returns: plan_t
an input for the DAG

build_dir_join(self, files)

source code 

Make the file (or list of files) with the build directory name.

Parameters:
  • files (string or list of strings) - filename(s)
Returns: string or list of strings
filenames prepended with the current build_dir

cc_compile(self, source, obj=None)

source code 

Indirection function. Reads builder function from the environment variable CC_COMPILE_BUILDER. C-compile a source file to a file named obj. If no obj file name is given one will be created in the build directory.

Parameters:
  • source (string) - filename to compile
  • obj (string) - output filename.
Returns: plan_t
an input for the DAG

check_mac_ver(self, x, y, z)

source code 
Returns: bool
True iff on a mac and the version is later than x.y.z

compile(self, dag, sources)

source code 

Build all the sources by adding them to the dag. Use the suffixes to figure out how to handle the files. The dag can be passed to a work queue. See the build function.

compile_and_link(self, dag, sources, exe, shared_object=False, libs=[])

source code 

Build all the sources by adding them to the dag. Use the suffixes to figure out how to handle the files. The dag can be passed to a work queue. See the build function.

compile_and_static_lib(self, dag, sources, libname)

source code 

Build all the sources by adding them to the dag. Use the suffixes to figure out how to handle the files. The dag can be passed to a work queue. See the build function.

copy_settings(self, incoming_env, kwds, replace=False)

source code 

Update the environment dictionary with elements of kwds from the dictionary in the incoming_env. Lists are extended with the incoming elements and other types of elements are assigned directly.

Parameters:
  • incoming_env (env_t) - the source environment
  • kwds (list of strings) - elements to copy from the source enviornment
  • replace (bool) - if True, replace lists in the source environment

cxx_compile(self, source, obj=None)

source code 

Indirection function. Reads builder function from the environment variable CXX_COMPILE_BUILDER. C++-compile a source file to a file called obj. If no obj file name is given one will be created in the build directory.

Parameters:
  • source (string) - filename to compile
  • obj (string) - output filename.
Returns: plan_t
an input for the DAG

default_compiler(self)

source code 

Default to ms on windows and gnu everywhere else.

Returns: string
"ms" on windows, "clang" on mac, otherwise "gnu"

dynamic_lib(self, objs, libname, relocate=False)

source code 

Indirection function. Reads builder function from the environment variable DYNAMIC_LIBRARY_BUILDER. Make a dynamic library libname from objs. If relocate is True, then prefix libname with the build directory name

Parameters:
  • objs (list of strings) - filenames to link
  • libname (string) - output filename.
  • relocate (bool) - If true, relocate the library to the build directory.
Returns: plan_t
an input for the DAG

expand_key(self, k, newenv=None)

source code 

Read the the value of k from the environment dictionary, doing recursive substitutions from the environment. If no environment is supplied, then the default environment is used.

Parameters:
  • k (string or list of strings) - A string (or strings) containing a single key name(s)
  • newenv (env_t) - An environment within which to do the expansion. If null, the default environment is used.
Returns: string

expand_string(self, command_string, newenv=None)

source code 

Read the environment dictionary, doing recursive substitutions from the environment. If no environment is supplied, then the default environment is used.

Parameters:
  • command_string (string or list of strings) - A string with %(...)s variables in it
  • newenv (env_t) - An environment within which to do the expansion. If null, the default environment is used.
Returns: string

link(self, objs, exename, relocate=False)

source code 

Indirection function. Reads builder function from the environment variable LINK_BUILDER. Link an executable from objs. If relocate is True, then prefix exename with the build directory name.

Parameters:
  • objs (list of strings) - filenames to link
  • exename (string) - output filename.
  • relocate (bool) - If true, relocate the exename to the build directory.
Returns: plan_t
an input for the DAG

make_derived_flags(self)

source code 

Put together any derived flags. This is required to be called by builder functions before they do their expansion.

make_obj(self, flist)

source code 

Take file or list of files and return a file or list of files with the OBJEXT extension from the environment.

Parameters:
  • flist (string or list of strings) - a filename (or list of filenames)
Returns: string
fn with a suffix specified %(OBJEXT)s

on_cygwin(self)

source code 
Returns: bool
True iff on cygwin

on_freebsd(self)

source code 
Returns: bool
True iff on freebsd

on_ia32(self)

source code 
Returns: bool
True iff on IA32

on_intel64(self)

source code 
Returns: bool
True iff on Intel64

on_ipf(self)

source code 
Returns: bool
True iff on IA64

on_leopard(self)

source code 
Returns: bool
True iff on Mac running OS X Leopard 10.5.x

on_linux(self)

source code 
Returns: bool
True iff on linux

on_mac(self)

source code 
Returns: bool
True iff on Mac OSX Darwin

on_tiger(self)

source code 
Returns: bool
True iff on Mac running OS X Tiger 10.4.x

on_windows(self)

source code 
Returns: bool
True iff on windows

parse_args(self, user_default_options=None)

source code 

Call this to re-initialize the environment from the command line arguments. This calls update() with the results of command line processing.

Parameters:
  • user_default_options (dict) - dictionary of default options

rc_file(self, rc_file, res_file=None)

source code 

Indirection function. For making RES files from RC files on windows.

Parameters:
  • rc_file (string) - filename for RC file
  • res_file (string) - filename for RES file

remove_from_var(self, var, value)

source code 

Remove a substring (or list entry) from env[var]. Opposite of add_to_var().

Parameters:
  • var (string) - name of a dictionary key
  • value (string) - the value to remove

resuffix(self, fn, newext)

source code 

Replace the suffix of single fn (or list of files) with newext. newext should supply its own dot if you want one.

Parameters:
  • fn (string (or list of strings)) - a filename
  • newext (string) - a new extension starting with a '.'
Returns: string
fn with a new suffix specified by newext

set_compiler_env(self, compiler_family=None)

source code 

Initialize the build environment based on the compiler environment variable setting.

Adds in the "extra" flags from the environment.

Parameters:
  • compiler_family (string) - an override for the default compiler family (gnu, ms, clang, icl, icc, iclang)

set_defaults(self, dct)

source code 

Take the dictionary of defaults and apply to the environment. Any extra bindings and targets should be listed in the 'args' list option of the dictionary

src_dir_join(self, files)

source code 

Prefix file (or list of files) with the src directory name.

Parameters:
  • files (string or list of strings) - filename(s)
Returns: string or list of strings
filenames prepended with the current src_dir

static_lib(self, objs, libname, relocate=False)

source code 

Indirection function. Reads builder function from the environment variable STATIC_LIBRARY_BUILDER. Make a static library libname from objs. If relocate is True, then prefix libname with the build directory name

Parameters:
  • objs (list of strings) - filenames to link
  • libname (string) - output filename.
  • relocate (bool) - If true, relocate the library to the build directory.
Returns: plan_t
an input for the DAG

supports_avx(self)

source code 

Return True if system supports AVX1. Does not work on windows

version(self)

source code 

Emit the version string.

Returns: string
The version string

windows_native(self)

source code 
Returns: bool
True iff on windows native -- not using cygwin

Class Variable Details

assignment_pattern

Value:
re.compile(r'(?P<name>[-A-Za-z0-9_]+)=(?P<value>.+)')

supplement_pattern

Value:
re.compile(r'(?P<name>[-A-Za-z0-9_]+)\+=(?P<value>.+)')