mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
meson: do a build-time check for strlcpy before attempting runtime check
In cross-compilation environments the runtime check isn't possible so it is up to the builder to seed the cross file, but we can definitely state that strlcpy doesn't exist with a build test.
This commit is contained in:
parent
3c44026dc4
commit
fc88e56bfc
35
meson.build
35
meson.build
@ -1859,24 +1859,27 @@ if host_system != 'windows' and get_option('xattr')
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Test if we have strlcpy/strlcat with a compatible implementation:
|
# If strlcpy is present (BSD and similar), check that it conforms to the BSD
|
||||||
# https://bugzilla.gnome.org/show_bug.cgi?id=53933
|
# specification. Specifically Solaris 8's strlcpy() does not, see
|
||||||
if cc_can_run
|
# https://bugzilla.gnome.org/show_bug.cgi?id=53933 for further context.
|
||||||
rres = cc.run('''#include <stdlib.h>
|
if cc.has_function('strlcpy')
|
||||||
#include <string.h>
|
if cc_can_run
|
||||||
int main() {
|
rres = cc.run('''#include <stdlib.h>
|
||||||
char p[10];
|
#include <string.h>
|
||||||
(void) strlcpy (p, "hi", 10);
|
int main() {
|
||||||
if (strlcat (p, "bye", 0) != 3)
|
char p[10];
|
||||||
return 1;
|
(void) strlcpy (p, "hi", 10);
|
||||||
return 0;
|
if (strlcat (p, "bye", 0) != 3)
|
||||||
}''',
|
return 1;
|
||||||
name : 'OpenBSD strlcpy/strlcat')
|
return 0;
|
||||||
if rres.compiled() and rres.returncode() == 0
|
}''',
|
||||||
|
name : 'OpenBSD strlcpy/strlcat')
|
||||||
|
if rres.compiled() and rres.returncode() == 0
|
||||||
|
glib_conf.set('HAVE_STRLCPY', 1)
|
||||||
|
endif
|
||||||
|
elif meson.get_cross_property('have_strlcpy', false)
|
||||||
glib_conf.set('HAVE_STRLCPY', 1)
|
glib_conf.set('HAVE_STRLCPY', 1)
|
||||||
endif
|
endif
|
||||||
elif meson.get_cross_property('have_strlcpy', false)
|
|
||||||
glib_conf.set('HAVE_STRLCPY', 1)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
python = import('python').find_installation('python3')
|
python = import('python').find_installation('python3')
|
||||||
|
Loading…
Reference in New Issue
Block a user