Conftest.py (SCons-4.3.0) | : | Conftest.py (SCons-4.4.0) | ||
---|---|---|---|---|
skipping to change at line 26 | skipping to change at line 26 | |||
# in all copies or substantial portions of the Software. | # in all copies or substantial portions of the Software. | |||
# | # | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | |||
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | |||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
"""Autoconf-like configuration support | r"""Autoconf-like configuration support | |||
The purpose of this module is to define how a check is to be performed. | The purpose of this module is to define how a check is to be performed. | |||
A context class is used that defines functions for carrying out the tests, | A context class is used that defines functions for carrying out the tests, | |||
logging and messages. The following methods and members must be present: | logging and messages. The following methods and members must be present: | |||
context.Display(msg) | context.Display(msg) | |||
Function called to print messages that are normally displayed | Function called to print messages that are normally displayed | |||
for the user. Newlines are explicitly used. The text should | for the user. Newlines are explicitly used. The text should | |||
also be written to the logfile! | also be written to the logfile! | |||
skipping to change at line 86 | skipping to change at line 86 | |||
If present, must be a string, which will be filled with the | If present, must be a string, which will be filled with the | |||
contents of a config_h file. | contents of a config_h file. | |||
context.vardict | context.vardict | |||
Dictionary holding variables used for the tests and stores results | Dictionary holding variables used for the tests and stores results | |||
from the tests, used for the build commands. Normally contains | from the tests, used for the build commands. Normally contains | |||
"CC", "LIBS", "CPPFLAGS", etc. | "CC", "LIBS", "CPPFLAGS", etc. | |||
context.havedict | context.havedict | |||
Dictionary holding results from the tests that are to be used | Dictionary holding results from the tests that are to be used | |||
inside a program. Names often start with "HAVE_". These are zero | inside a program. Names often start with "HAVE\_". These are zero | |||
(feature not present) or one (feature present). Other variables | (feature not present) or one (feature present). Other variables | |||
may have any value, e.g., "PERLVERSION" can be a number and | may have any value, e.g., "PERLVERSION" can be a number and | |||
"SYSTEMNAME" a string. | "SYSTEMNAME" a string. | |||
""" | """ | |||
import re | import re | |||
# | # | |||
# PUBLIC VARIABLES | # PUBLIC VARIABLES | |||
# | # | |||
skipping to change at line 567 | skipping to change at line 567 | |||
; | ; | |||
return 0; | return 0; | |||
} | } | |||
""" % (symbol, symbol) | """ % (symbol, symbol) | |||
st = context.CompileProg(src, suffix) | st = context.CompileProg(src, suffix) | |||
_YesNoResult(context, st, "HAVE_DECL_" + symbol, src, | _YesNoResult(context, st, "HAVE_DECL_" + symbol, src, | |||
"Set to 1 if %s is defined." % symbol) | "Set to 1 if %s is defined." % symbol) | |||
return st | return st | |||
def CheckMember(context, aggregate_member, header = None, language = None): | ||||
""" | ||||
Configure check for a C or C++ member "aggregate_member". | ||||
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". | ||||
Note that this uses the current value of compiler and linker flags, make | ||||
sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly. | ||||
Arguments: | ||||
aggregate_member : str | ||||
the member to check. For example, 'struct tm.tm_gmtoff'. | ||||
includes : str | ||||
Optional "header" can be defined to include a header file. | ||||
language : str | ||||
only C and C++ supported. | ||||
Returns the status (0 or False = Passed, True/non-zero = Failed). | ||||
""" | ||||
lang, suffix, msg = _lang2suffix(language) | ||||
if msg: | ||||
context.Display("Cannot check for member %s: %s\n" % (aggregate_member, | ||||
msg)) | ||||
return True | ||||
context.Display("Checking for %s member %s... " % (lang, aggregate_member)) | ||||
fields = aggregate_member.split('.') | ||||
if len(fields) != 2: | ||||
msg = "shall contain just one dot, for example 'struct tm.tm_gmtoff'" | ||||
context.Display("Cannot check for member %s: %s\n" % (aggregate_member, | ||||
msg)) | ||||
return True | ||||
aggregate, member = fields[0], fields[1] | ||||
# Include "confdefs.h" first, so that the header can use HAVE_HEADER_H. | ||||
if context.headerfilename: | ||||
includetext = '#include "%s"' % context.headerfilename | ||||
else: | ||||
includetext = '' | ||||
if not header: | ||||
header = '' | ||||
text = ''' | ||||
%(include)s | ||||
%(header)s | ||||
int main(void) { | ||||
if (sizeof ((%(aggregate)s *) 0)->%(member)s) | ||||
return 0; | ||||
}''' % {'include': includetext, | ||||
'header': header, | ||||
'aggregate': aggregate, | ||||
'member': member} | ||||
ret = context.BuildProg(text, suffix) | ||||
_YesNoResult(context, ret, "HAVE_" + aggregate_member, text, | ||||
"Define to 1 if the system has the member `%s`." % aggregate_me | ||||
mber) | ||||
return ret | ||||
def CheckLib(context, libs, func_name = None, header = None, | def CheckLib(context, libs, func_name = None, header = None, | |||
extra_libs = None, call = None, language = None, autoadd = 1, | extra_libs = None, call = None, language = None, autoadd = 1, | |||
append = True): | append = True): | |||
""" | """ | |||
Configure check for a C or C++ libraries "libs". Searches through | Configure check for a C or C++ libraries "libs". Searches through | |||
the list of libraries, until one is found where the test succeeds. | 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 | Tests if "func_name" or "call" exists in the library. Note: if it exists | |||
in another library the test succeeds anyway! | in another library the test succeeds anyway! | |||
Optional "header" can be defined to include a header file. If not given a | Optional "header" can be defined to include a header file. If not given a | |||
default prototype for "func_name" is added. | default prototype for "func_name" is added. | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 61 lines changed or added |