Package SCons :: Module Conftest
[hide private]
[frames] | no frames]

Module Conftest

source code

SCons.Conftest

Autoconf-like configuration support; low level implementation of tests.



Functions [hide private]
 
CheckBuilder(context, text=False, language=False)
Configure check to see if the compiler works.
source code
 
CheckCC(context)
Configure check for a working C compiler.
source code
 
CheckSHCC(context)
Configure check for a working shared C compiler.
source code
 
CheckCXX(context)
Configure check for a working CXX compiler.
source code
 
CheckSHCXX(context)
Configure check for a working shared CXX compiler.
source code
 
_check_empty_program(context, comp, text, language, use_shared=False)
Return 0 on success, 1 otherwise.
source code
 
CheckFunc(context, function_name, header=False, language=False)
Configure check for a function "function_name".
source code
 
CheckHeader(context, header_name, header=False, language=False, include_quotes=False)
Configure check for a C or C++ header file "header_name".
source code
 
CheckType(context, type_name, fallback=False, header=False, language=False)
Configure check for a C or C++ type "type_name".
source code
 
CheckTypeSize(context, type_name, header=False, language=False, expect=False)
This check can be used to get the size of a given type, or to check whether the type is of expected size.
source code
 
CheckDeclaration(context, symbol, includes=False, language=False)
Checks whether symbol is declared.
source code
 
CheckLib(context, libs, func_name=False, header=False, extra_libs=False, call=False, language=False, autoadd=1, append=True)
Configure check for a C or C++ libraries "libs".
source code
 
_YesNoResult(context, ret, key, text, comment=False)
Handle the result of a test with a "yes" or "no" result.
source code
 
_Have(context, key, have, comment=False)
Store result of a test in context.havedict and context.headerfilename.
source code
 
_LogFailed(context, text, msg)
Write to the log about a failed program.
source code
 
_lang2suffix(lang)
Convert a language name to a suffix.
source code
Variables [hide private]
  LogInputFiles = 1
  LogErrorMessages = 1
Function Details [hide private]

CheckBuilder(context, text=False, language=False)

source code 

Configure check to see if the compiler works.
Note that this uses the current value of compiler and linker flags, make
sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
"language" should be "C" or "C++" and is used to select the compiler.
Default is "C".
"text" may be used to specify the code to be build.
Returns an empty string for success, an error message for failure.

CheckCC(context)

source code 

Configure check for a working C compiler.

This checks whether the C compiler, as defined in the $CC construction
variable, can compile a C source file. It uses the current $CCCOM value
too, so that it can test against non working flags.

CheckSHCC(context)

source code 

Configure check for a working shared C compiler.

This checks whether the C compiler, as defined in the $SHCC construction
variable, can compile a C source file. It uses the current $SHCCCOM value
too, so that it can test against non working flags.

CheckCXX(context)

source code 

Configure check for a working CXX compiler.

This checks whether the CXX compiler, as defined in the $CXX construction
variable, can compile a CXX source file. It uses the current $CXXCOM value
too, so that it can test against non working flags.

CheckSHCXX(context)

source code 

Configure check for a working shared CXX compiler.

This checks whether the CXX compiler, as defined in the $SHCXX construction
variable, can compile a CXX source file. It uses the current $SHCXXCOM value
too, so that it can test against non working flags.

CheckFunc(context, function_name, header=False, language=False)

source code 

Configure check for a function "function_name".
"language" should be "C" or "C++" and is used to select the compiler.
Default is "C".
Optional "header" can be defined to define a function prototype, include a
header file or anything else that comes before main().
Sets HAVE_function_name in context.havedict according to the result.
Note that this uses the current value of compiler and linker flags, make
sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
Returns an empty string for success, an error message for failure.

CheckHeader(context, header_name, header=False, language=False, include_quotes=False)

source code 

Configure check for a C or C++ header file "header_name".
Optional "header" can be defined to do something before including the
header file (unusual, supported for consistency).
"language" should be "C" or "C++" and is used to select the compiler.
Default is "C".
Sets HAVE_header_name in context.havedict according to the result.
Note that this uses the current value of compiler and linker flags, make
sure $CFLAGS and $CPPFLAGS are set correctly.
Returns an empty string for success, an error message for failure.

CheckType(context, type_name, fallback=False, header=False, language=False)

source code 

Configure check for a C or C++ type "type_name".
Optional "header" can be defined to include a header file.
"language" should be "C" or "C++" and is used to select the compiler.
Default is "C".
Sets HAVE_type_name in context.havedict according to the result.
Note that this uses the current value of compiler and linker flags, make
sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
Returns an empty string for success, an error message for failure.

CheckTypeSize(context, type_name, header=False, language=False, expect=False)

source code 
This check can be used to get the size of a given type, or to check whether
the type is of expected size.

Arguments:
    - type : str
        the type to check
    - includes : sequence
        list of headers to include in the test code before testing the type
    - language : str
        'C' or 'C++'
    - expect : int
        if given, will test wether the type has the given number of bytes.
        If not given, will automatically find the size.

    Returns:
        status : int
            0 if the check failed, or the found size of the type if the check succeeded.

CheckDeclaration(context, symbol, includes=False, language=False)

source code 
Checks whether symbol is declared.

Use the same test as autoconf, that is test whether the symbol is defined
as a macro or can be used as an r-value.

Arguments:
    symbol : str
        the symbol to check
    includes : str
        Optional "header" can be defined to include a header file.
    language : str
        only C and C++ supported.

Returns:
    status : bool
        True if the check failed, False if succeeded.

CheckLib(context, libs, func_name=False, header=False, extra_libs=False, call=False, language=False, autoadd=1, append=True)

source code 

Configure check for a C or C++ libraries "libs".  Searches through
the list of libraries, until one is found where the test succeeds.
Tests if "func_name" or "call" exists in the library.  Note: if it exists
in another library the test succeeds anyway!
Optional "header" can be defined to include a header file.  If not given a
default prototype for "func_name" is added.
Optional "extra_libs" is a list of library names to be added after
"lib_name" in the build command.  To be used for libraries that "lib_name"
depends on.
Optional "call" replaces the call to "func_name" in the test code.  It must
consist of complete C statements, including a trailing ";".
Both "func_name" and "call" arguments are optional, and in that case, just
linking against the libs is tested.
"language" should be "C" or "C++" and is used to select the compiler.
Default is "C".
Note that this uses the current value of compiler and linker flags, make
sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
Returns an empty string for success, an error message for failure.

_YesNoResult(context, ret, key, text, comment=False)

source code 

Handle the result of a test with a "yes" or "no" result.
"ret" is the return value: empty if OK, error message when not.
"key" is the name of the symbol to be defined (HAVE_foo).
"text" is the source code of the program used for testing.
"comment" is the C comment to add above the line defining the symbol (the
comment is automatically put inside a /* */). If None, no comment is added.

_Have(context, key, have, comment=False)

source code 

Store result of a test in context.havedict and context.headerfilename.
"key" is a "HAVE_abc" name.  It is turned into all CAPITALS and non-
alphanumerics are replaced by an underscore.
The value of "have" can be:
1      - Feature is defined, add "#define key".
0      - Feature is not defined, add "/* #undef key */".
         Adding "undef" is what autoconf does.  Not useful for the
         compiler, but it shows that the test was done.
number - Feature is defined to this number "#define key have".
         Doesn't work for 0 or 1, use a string then.
string - Feature is defined to this string "#define key have".
         Give "have" as is should appear in the header file, include quotes
         when desired and escape special characters!

_LogFailed(context, text, msg)

source code 

Write to the log about a failed program.
Add line numbers, so that error messages can be understood.

_lang2suffix(lang)

source code 

Convert a language name to a suffix.
When "lang" is empty or None C is assumed.
Returns a tuple (lang, suffix, None) when it works.
For an unrecognized language returns (None, None, msg).
Where:
    lang   = the unified language name
    suffix = the suffix, including the leading dot
    msg    = an error message