Package SCons :: Module SConf :: Class SConfBase
[hide private]
[frames] | no frames]

Class SConfBase

source code

object --+
         |
        SConfBase

This is simply a class to represent a configure context. After
creating a SConf object, you can call any tests. After finished with your
tests, be sure to call the Finish() method, which returns the modified
environment.
Some words about caching: In most cases, it is not necessary to cache
Test results explicitely. Instead, we use the scons dependency checking
mechanism. For example, if one wants to compile a test program
(SConf.TryLink), the compiler is only called, if the program dependencies
have changed. However, if the program could not be compiled in a former
SConf run, we need to explicitely cache this error.



Nested Classes [hide private]
  TestWrapper
A wrapper around Tests (to ensure sanity)
Instance Methods [hide private]
 
__init__(self, env, custom_tests={}, conf_dir='$CONFIGUREDIR', log_file='$CONFIGURELOG', config_h=False, _depth=0)
Constructor.
source code
 
Finish(self)
Call this method after finished with your tests:...
source code
 
Define(self, name, value=False, comment=False)
Define a pre processor symbol name, with the optional given value in the current config header.
source code
 
BuildNodes(self, nodes)
Tries to build the given nodes immediately.
source code
 
pspawn_wrapper(self, sh, escape, cmd, args, env)
Wrapper function for handling piped spawns.
source code
 
TryBuild(self, builder, text=False, extension='')
Low level TryBuild implementation.
source code
 
TryAction(self, action, text=False, extension='')
Tries to execute the given action with optional source file contents <text> and optional source file extension <extension>, Returns the status (0 : failed, 1 : ok) and the contents of the output file.
source code
 
TryCompile(self, text, extension)
Compiles the program given in text to an env.Object, using extension as file extension (e.g.
source code
 
TryLink(self, text, extension)
Compiles the program given in text to an executable env.Program, using extension as file extension (e.g.
source code
 
TryRun(self, text, extension)
Compiles and runs the program given in text, using extension as file extension (e.g.
source code
 
AddTest(self, test_name, test_instance)
Adds test_class to this SConf instance.
source code
 
AddTests(self, tests)
Adds all the tests given in the tests dictionary to this SConf...
source code
 
_createDir(self, node) source code
 
_startup(self)
Private method.
source code
 
_shutdown(self)
Private method.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, env, custom_tests={}, conf_dir='$CONFIGUREDIR', log_file='$CONFIGURELOG', config_h=False, _depth=0)
(Constructor)

source code 
Constructor. Pass additional tests in the custom_tests-dictinary,
e.g. custom_tests={'CheckPrivate':MyPrivateTest}, where MyPrivateTest
defines a custom test.
Note also the conf_dir and log_file arguments (you may want to
build tests in the VariantDir, not in the SourceDir)

Overrides: object.__init__

Finish(self)

source code 
Call this method after finished with your tests:
env = sconf.Finish()

Define(self, name, value=False, comment=False)

source code 

Define a pre processor symbol name, with the optional given value in the
current config header.

If value is None (default), then #define name is written. If value is not
none, then #define name value is written.

comment is a string which will be put as a C comment in the
header, to explain the meaning of the value (appropriate C comments /* and
*/ will be put automatically.

BuildNodes(self, nodes)

source code 

Tries to build the given nodes immediately. Returns 1 on success,
0 on error.

pspawn_wrapper(self, sh, escape, cmd, args, env)

source code 
Wrapper function for handling piped spawns.

This looks to the calling interface (in Action.py) like a "normal"
spawn, but associates the call with the PSPAWN variable from
the construction environment and with the streams to which we
want the output logged.  This gets slid into the construction
environment as the SPAWN variable so Action.py doesn't have to
know or care whether it's spawning a piped command or not.

TryBuild(self, builder, text=False, extension='')

source code 
Low level TryBuild implementation. Normally you don't need to
call that - you can use TryCompile / TryLink / TryRun instead

TryCompile(self, text, extension)

source code 
Compiles the program given in text to an env.Object, using extension
as file extension (e.g. '.c'). Returns 1, if compilation was
successful, 0 otherwise. The target is saved in self.lastTarget (for
further processing).

TryLink(self, text, extension)

source code 
Compiles the program given in text to an executable env.Program,
using extension as file extension (e.g. '.c'). Returns 1, if
compilation was successful, 0 otherwise. The target is saved in
self.lastTarget (for further processing).

TryRun(self, text, extension)

source code 
Compiles and runs the program given in text, using extension
as file extension (e.g. '.c'). Returns (1, outputStr) on success,
(0, '') otherwise. The target (a file containing the program's stdout)
is saved in self.lastTarget (for further processing).

AddTest(self, test_name, test_instance)

source code 
Adds test_class to this SConf instance. It can be called with
self.test_name(...)

AddTests(self, tests)

source code 
Adds all the tests given in the tests dictionary to this SConf
instance

_startup(self)

source code 
Private method. Set up logstream, and set the environment
variables necessary for a piped build

_shutdown(self)

source code 
Private method. Reset to non-piped spawn