Re: [scons-devel] auto-configuration plans
"David Snopek" <[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
Bram Moolenaar said:
>> There *is* the current SCons API (documented in the SCons manpage). I
>> just
>> meant that this API shouldn't change.
>
> The manual page doesn't say anything about TryBuild() and the like...
> From reading the source code it's not clear what is part of the API and
> what isn't. Thus it's not clear what may change and what should not
> change to remain backwards compatible.
Copied directly from http://www.scons.org/HTML/scons-man.html
You can define your own custom checks. in addition to the predefined
checks. These are passed in a dictionary to the Configure function.
This dictionary maps the names of the checks to user defined Python
callables (either Python functions or class instances implementing the
__call__ method). The first argument of the call is always a
CheckContext instance followed by the arguments, which must be
supplied by the user of the check. These CheckContext instances define
the following methods:
CheckContext.Message(self, text)
Usually called before the check is started. text will be displayed to
the user, e.g. 'Checking for library X...'
CheckContext.Result(self,, res)
Usually called after the check is done. res can be either an integer
or a string. In the former case, 'ok' (res != 0) or 'failed' (res ==
0) is displayed to the user, in the latter case the given string is
displayed.
CheckContext.TryCompile(self, text, extension)
Checks if a file with the specified extension (e.g. '.c') containing
text can be compiled using the environment's Object builder. Returns 1
on success and 0 on failure.
CheckContext.TryLink(self, text, extension)
Checks, if a file with the specified extension (e.g. '.c') containing
text can be compiled using the environment's Program builder. Returns
1 on success and 0 on failure.
CheckContext.TryRun(self, text, extension)
Checks, if a file with the specified extension (e.g. '.c') containing
text can be compiled using the environment's Program builder. On
success, the program is run. If the program executes successfully
(that is, its return status is 0), a tuple (1, outputStr) is returned,
where outputStr is the standard output of the program. If the program
fails execution (its return status is non-zero), then (0, '') is
returned.
CheckContext.TryAction(self, action, [text, extension])
Checks if the specified action with an optional source file (contents
text , extension extension = '' ) can be executed. action may be
anything which can be converted to a scons Action. On success, (1,
outputStr) is returned, where outputStr is the content of the target
file. On failure (0, '') is returned.
CheckContext.TryBuild(self, builder, [text, extension])
Low level implementation for testing specific builds; the methods
above are based on this method. Given the Builder instance builder and
the optional text of a source file with optional extension, this
method returns 1 on success and 0 on failure. In addition,
self.lastTarget is set to the build target node, if the build was
successful.
Example for implementing and using custom tests:
def CheckQt(context, qtdir):
context.Message( 'Checking for qt ...' )
lastLIBS = context.env['LIBS']
lastLIBPATH = context.env['LIBPATH']
lastCPPPATH= context.env['CPPPATH']
context.env.Append(LIBS = 'qt', LIBPATH = qtdir + '/lib', CPPPATH =
qtdir + '/include' )
ret = context.TryLink("""
#include <qapp.h>
int main(int argc, char **argv) {
QApplication qapp(argc, argv);
return 0;
}
""")
if not ret:
context.env.Replace(LIBS = lastLIBS, LIBPATH=lastLIBPATH,
CPPPATH=lastCPPPATH)
context.Result( ret )
return ret
env = Environment()
conf = Configure( env, custom_tests = { 'CheckQt' : CheckQt } )
if not conf.CheckQt('/usr/lib/qt'):
print 'We really need qt!'
Exit(1)
env = conf.Finish()
Thank you.
-- David Snopek
Satellite Computing Solutions, LLC
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01