meson: use string methods to avoid repeating data

Instead of writing `['HAVE_FOO_H', 'foo.h']`, use meson's string methods
to just write `['foo.h']`, and let meson create `HAVE_FOO_H` for us.
master
Dylan Baker 2022-07-29 10:38:35 -07:00
parent f947af057f
commit 1f993bc095
1 changed files with 9 additions and 9 deletions

View File

@ -19,18 +19,18 @@ add_project_arguments(
cdata = configuration_data() cdata = configuration_data()
check_functions = [ check_functions = [
['HAVE_STRLCAT', 'strlcat', 'string.h'], ['strlcat', 'string.h'],
['HAVE_STRLCPY', 'strlcpy', 'string.h'], ['strlcpy', 'string.h'],
['HAVE_STRNDUP', 'strndup', 'string.h'], ['strndup', 'string.h'],
['HAVE_STRDUP', 'strdup', 'string.h'], ['strdup', 'string.h'],
['HAVE_STRNCASECMP', 'strncasecmp', 'strings.h'], ['strncasecmp', 'strings.h'],
['HAVE_STRCASECMP', 'strcasecmp', 'strings.h'], ['strcasecmp', 'strings.h'],
['HAVE_REALLOCARRAY', 'reallocarray', 'stdlib.h'], ['reallocarray', 'stdlib.h'],
] ]
foreach f : check_functions foreach f : check_functions
if cc.has_function(f[1], prefix : '#define _BSD_SOURCE\n#include <@0@>'.format(f[2])) and cc.has_header_symbol(f[2], f[1], prefix : '#define _BSD_SOURCE') if cc.has_function(f[0], prefix : '#define _BSD_SOURCE\n#include <@0@>'.format(f[1])) and cc.has_header_symbol(f[1], f[0], prefix : '#define _BSD_SOURCE')
cdata.set(f[0], 1) cdata.set('HAVE_@0@'.format(f[0].to_upper().underscorify()), 1)
endif endif
endforeach endforeach