Skip to content

Commit 06e47f7

Browse files
authored
Merge branch 'master' into jbrill-msvs-sconshome
2 parents 6b537ab + fe942c4 commit 06e47f7

File tree

8 files changed

+59
-25
lines changed

8 files changed

+59
-25
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3939
- Method unlink_files was added to the TestCmd class that unlinks a list of
4040
files from a specified directory. An attempt to unlink a file is made only
4141
when the file exists; otherwise, the file is ignored.
42+
- Fix issue #4320: add an optional argument list string to configure's CheckFunc
43+
method so that the generated function argument list matches the function's
44+
prototype when including a header file.
45+
46+
From William Deegan:
47+
- Fix sphinx config to handle SCons versions with post such as: 4.6.0.post1
4248

4349
From Michał Górny:
4450
- Remove unecessary dependencies on pypi packages from setup.cfg
@@ -47,6 +53,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
4753
- Fix of the --debug=sconscript option to return exist statements when using return
4854
statement with stop flag enabled
4955

56+
5057
RELEASE 4.6.0 - Sun, 19 Nov 2023 17:22:20 -0700
5158

5259
From Max Bachmann:

RELEASE.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ DEPRECATED FUNCTIONALITY
2929
CHANGED/ENHANCED EXISTING FUNCTIONALITY
3030
---------------------------------------
3131

32-
- List modifications to existing features, where the previous behavior
33-
wouldn't actually be considered a bug
32+
- Add an optional argument list string to configure's CheckFunc method so
33+
that the generated function argument list matches the function's
34+
prototype when including a header file. Fixes GH Issue #4320
3435

3536
FIXES
3637
-----
@@ -69,10 +70,10 @@ DOCUMENTATION
6970
DEVELOPMENT
7071
-----------
7172

72-
- List visible changes in the way SCons is developed
73+
- Fix sphinx config to handle SCons versions with post such as: 4.6.0.post1
7374

7475
Thanks to the following contributors listed below for their contributions to this release.
7576
==========================================================================================
7677
.. code-block:: text
7778

78-
git shortlog --no-merges -ns 4.0.1..HEAD
79+
git shortlog --no-merges -ns 4.6.0..HEAD

SCons/Conftest.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,22 @@ def _check_empty_program(context, comp, text, language, use_shared: bool = False
231231
return context.CompileProg(text, suffix)
232232

233233

234-
def CheckFunc(context, function_name, header = None, language = None):
234+
def CheckFunc(context, function_name, header = None, language = None, funcargs = None):
235235
"""
236236
Configure check for a function "function_name".
237237
"language" should be "C" or "C++" and is used to select the compiler.
238238
Default is "C".
239239
Optional "header" can be defined to define a function prototype, include a
240240
header file or anything else that comes before main().
241+
Optional "funcargs" can be defined to define an argument list for the
242+
generated function invocation.
241243
Sets HAVE_function_name in context.havedict according to the result.
242244
Note that this uses the current value of compiler and linker flags, make
243245
sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
244246
Returns an empty string for success, an error message for failure.
247+
248+
.. versionchanged:: 4.7.0
249+
The ``funcargs`` parameter was added.
245250
"""
246251

247252
# Remarks from autoconf:
@@ -274,6 +279,9 @@ def CheckFunc(context, function_name, header = None, language = None):
274279
context.Display("Cannot check for %s(): %s\n" % (function_name, msg))
275280
return msg
276281

282+
if not funcargs:
283+
funcargs = ''
284+
277285
text = """
278286
%(include)s
279287
#include <assert.h>
@@ -287,14 +295,15 @@ def CheckFunc(context, function_name, header = None, language = None):
287295
#if defined (__stub_%(name)s) || defined (__stub___%(name)s)
288296
#error "%(name)s has a GNU stub, cannot check"
289297
#else
290-
%(name)s();
298+
%(name)s(%(args)s);
291299
#endif
292300
293301
return 0;
294302
}
295303
""" % { 'name': function_name,
296304
'include': includetext,
297-
'hdr': header }
305+
'hdr': header,
306+
'args': funcargs}
298307

299308
context.Display("Checking for %s function %s()... " % (lang, function_name))
300309
ret = context.BuildProg(text, suffix)

SCons/SConf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,8 @@ def SConf(*args, **kw):
10021002
return SCons.Util.Null()
10031003

10041004

1005-
def CheckFunc(context, function_name, header = None, language = None) -> bool:
1006-
res = SCons.Conftest.CheckFunc(context, function_name, header = header, language = language)
1005+
def CheckFunc(context, function_name, header = None, language = None, funcargs = None) -> bool:
1006+
res = SCons.Conftest.CheckFunc(context, function_name, header = header, language = language, funcargs = funcargs)
10071007
context.did_show_result = 1
10081008
return not res
10091009

SCons/SConfTests.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,26 @@ def test_CheckFunc(self) -> None:
671671
log_file=self.test.workpath('config.log'))
672672

673673
try:
674-
# CheckFunc()
674+
# look for function using default heading
675675
r = sconf.CheckFunc('strcpy')
676676
assert r, "did not find strcpy"
677+
# no default heading, supply dummy signature
677678
r = sconf.CheckFunc('strcpy', '/* header */ char strcpy();')
678679
assert r, "did not find strcpy"
680+
# ... supply complete signature, and function args
681+
r = sconf.CheckFunc('strcpy', header='/* header */ char *strcpy(char *dest, char *src);', funcargs='"", ""')
682+
# ... supply standard header for prototype, and function args
683+
assert r, "did not find strcpy"
684+
r = sconf.CheckFunc('strcpy', header='#include <string.h>', funcargs='"", ""')
685+
# also try in C++ mode
686+
cpp_header = """\
687+
#ifdef __cplusplus
688+
extern "C"
689+
#endif
690+
char *strcpy(char *dest, char *src);
691+
"""
692+
r = sconf.CheckFunc('strcpy', header=cpp_header, funcargs='"", ""', language="C++")
693+
assert r, "did not find strcpy"
679694
r = sconf.CheckFunc('hopefullynofunction')
680695
assert not r, "unexpectedly found hopefullynofunction"
681696

doc/man/scons.xml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,7 +3954,7 @@ Returns a boolean indicating success or failure.</para>
39543954
</varlistentry>
39553955

39563956
<varlistentry>
3957-
<term><replaceable>context</replaceable>.<methodname>CheckFunc</methodname>(<parameter>function_name, [header, language]</parameter>)</term>
3957+
<term><replaceable>context</replaceable>.<methodname>CheckFunc</methodname>(<parameter>function_name, [header, language, funcargs]</parameter>)</term>
39583958
<listitem>
39593959
<para>Checks if <parameter>function_name</parameter> is usable
39603960
in the context's local environment, using the compiler
@@ -3982,17 +3982,18 @@ char function_name(void);
39823982
</programlisting>
39833983

39843984
<para>
3985-
Note: if <parameter>header</parameter> is supplied,
3986-
it should <emphasis>not</emphasis>
3987-
include the standard header file that declares
3988-
<parameter>function_name</parameter>,
3989-
and it <emphasis>should</emphasis> include a
3990-
dummy prototype similar to the default case.
3991-
Compilers reject builds where a function call does
3992-
not match the declared prototype as happens
3993-
if the "real" header is included,
3994-
and modern compilers are now rejecting
3995-
implicit function declarations.
3985+
If <parameter>header</parameter> is supplied, it should <emphasis>not</emphasis> include
3986+
the standard header file that declares <parameter>function_name</parameter> and it
3987+
<emphasis>should</emphasis> include a dummy prototype similar to the default case. If
3988+
this is not possible, the optional <parameter>funcargs</parameter> argument can be used
3989+
to specify a string containing an argument list with the same number and type of
3990+
arguments as the prototype. The arguments can simply be constant values of the correct
3991+
type. Modern C/C++ compilers reject implicit function declarations and may also reject
3992+
function calls whose arguments are not type compatible with the prototype.
3993+
</para>
3994+
3995+
<para>
3996+
<emphasis>Changed in version 4.7.0: added the <parameter>funcargs</parameter>.</emphasis>
39963997
</para>
39973998

39983999
<para>Returns a boolean indicating success or failure.</para>

doc/sphinx/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@
9898
# The full version, including alpha/beta/rc tags:
9999
release = __version__
100100
# The short X.Y version.
101-
major, minor, _ = __version__.split('.')
102-
version = '.'.join([major, minor])
101+
version_parts = __version__.split('.')
102+
major, minor, patch = version_parts[0:3]
103+
version = '.'.join([major, minor,patch])
103104

104105
# The language for content autogenerated by Sphinx. Refer to documentation
105106
# for a list of supported languages.

test/Configure/config-h.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import os
4242
env.AppendENVPath('PATH', os.environ['PATH'])
4343
conf = Configure(env, config_h = 'config.h')
44-
r1 = conf.CheckFunc('printf')
44+
r1 = conf.CheckFunc('printf', header='#include <stdio.h>', funcargs='""')
4545
r2 = conf.CheckFunc('noFunctionCall')
4646
r3 = conf.CheckFunc('memmove')
4747
r4 = conf.CheckType('int')

0 commit comments

Comments
 (0)