diff options
-rw-r--r-- | CHANGES.txt | 13 | ||||
-rw-r--r-- | RELEASE.txt | 5 | ||||
-rw-r--r-- | SCons/Conftest.py | 12 | ||||
-rw-r--r-- | SCons/SConf.py | 4 | ||||
-rw-r--r-- | SCons/SConfTests.py | 2 | ||||
-rw-r--r-- | doc/man/scons.xml | 7 | ||||
-rw-r--r-- | test/Configure/config-h.py | 2 |
7 files changed, 33 insertions, 12 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 5a9d9e345..43669e035 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,15 @@ NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer supported RELEASE VERSION/DATE TO BE FILLED IN LATER + From Ataf Fazledin Ahamed: + - Use of NotImplemented instead of NotImplementedError for special methods + of _ListVariable class + + From Joseph Brill: + - Add an optional argument list string to configures CheckFunc method so + that the generated function argument list matches the function's + prototype when including a header file. Fixes GH Issue #4320 + From Michał Górny: - Remove unecessary dependencies on pypi packages from setup.cfg @@ -15,9 +24,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fix of the --debug=sconscript option to return exist statements when using return statement with stop flag enabled - From Ataf Fazledin Ahamed: - - Use of NotImplemented instead of NotImplementedError for special methods - of _ListVariable class + RELEASE 4.6.0 - Sun, 19 Nov 2023 17:22:20 -0700 diff --git a/RELEASE.txt b/RELEASE.txt index 7599d43fd..572ce4ba2 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -26,8 +26,9 @@ DEPRECATED FUNCTIONALITY CHANGED/ENHANCED EXISTING FUNCTIONALITY --------------------------------------- -- List modifications to existing features, where the previous behavior - wouldn't actually be considered a bug +- Add an optional argument list string to configures CheckFunc method so + that the generated function argument list matches the function's + prototype when including a header file. Fixes GH Issue #4320 FIXES ----- diff --git a/SCons/Conftest.py b/SCons/Conftest.py index 6af5e7889..cd122e7f4 100644 --- a/SCons/Conftest.py +++ b/SCons/Conftest.py @@ -231,13 +231,15 @@ def _check_empty_program(context, comp, text, language, use_shared: bool = False return context.CompileProg(text, suffix) -def CheckFunc(context, function_name, header = None, language = None): +def CheckFunc(context, function_name, header = None, language = None, funcargs = None): """ 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(). + Optional "funcargs" can be defined to define an argument list for the + generated function invocation. 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. @@ -274,6 +276,9 @@ char %s(void);""" % function_name context.Display("Cannot check for %s(): %s\n" % (function_name, msg)) return msg + if not funcargs: + funcargs = '' + text = """ %(include)s #include <assert.h> @@ -287,14 +292,15 @@ int main(void) { #if defined (__stub_%(name)s) || defined (__stub___%(name)s) #error "%(name)s has a GNU stub, cannot check" #else - %(name)s(); + %(name)s(%(args)s); #endif return 0; } """ % { 'name': function_name, 'include': includetext, - 'hdr': header } + 'hdr': header, + 'args': funcargs} context.Display("Checking for %s function %s()... " % (lang, function_name)) ret = context.BuildProg(text, suffix) diff --git a/SCons/SConf.py b/SCons/SConf.py index e522c8bb7..53666e63e 100644 --- a/SCons/SConf.py +++ b/SCons/SConf.py @@ -1002,8 +1002,8 @@ def SConf(*args, **kw): return SCons.Util.Null() -def CheckFunc(context, function_name, header = None, language = None) -> bool: - res = SCons.Conftest.CheckFunc(context, function_name, header = header, language = language) +def CheckFunc(context, function_name, header = None, language = None, funcargs = None) -> bool: + res = SCons.Conftest.CheckFunc(context, function_name, header = header, language = language, funcargs = funcargs) context.did_show_result = 1 return not res diff --git a/SCons/SConfTests.py b/SCons/SConfTests.py index 2903ba675..6e9aa6268 100644 --- a/SCons/SConfTests.py +++ b/SCons/SConfTests.py @@ -676,6 +676,8 @@ int main(void) { assert r, "did not find strcpy" r = sconf.CheckFunc('strcpy', '/* header */ char strcpy();') assert r, "did not find strcpy" + r = sconf.CheckFunc('strcpy', header='/* header */ char *strcpy(char *dest, char *src);', funcargs='"", ""') + assert r, "did not find strcpy" r = sconf.CheckFunc('hopefullynofunction') assert not r, "unexpectedly found hopefullynofunction" diff --git a/doc/man/scons.xml b/doc/man/scons.xml index aaebc2c27..81a9d0edb 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -3954,7 +3954,7 @@ Returns a boolean indicating success or failure.</para> </varlistentry> <varlistentry> - <term><replaceable>context</replaceable>.<methodname>CheckFunc</methodname>(<parameter>function_name, [header, language]</parameter>)</term> + <term><replaceable>context</replaceable>.<methodname>CheckFunc</methodname>(<parameter>function_name, [header, language, funcargs]</parameter>)</term> <listitem> <para>Checks if <parameter>function_name</parameter> is usable in the context's local environment, using the compiler @@ -3974,6 +3974,11 @@ If omitted, the default stanza will be (with <parameter>function_name</parameter> appropriately substituted): </para> + <para> + The optional <parameter>funcargs</parameter> can be defined to specify an argument list for the generated + function invocation. + </para> + <programlisting language="C"> #ifdef __cplusplus extern "C" diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index e5df6258f..aca18e42a 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -41,7 +41,7 @@ env = Environment() import os env.AppendENVPath('PATH', os.environ['PATH']) conf = Configure(env, config_h = 'config.h') -r1 = conf.CheckFunc('printf') +r1 = conf.CheckFunc('printf', header='#include <stdio.h>', funcargs='""') r2 = conf.CheckFunc('noFunctionCall') r3 = conf.CheckFunc('memmove') r4 = conf.CheckType('int') |