meson: Move generated source to fpi- prefix and use more readable code

Instead of concatenating strings, use an array of strings and finally join
them using newline.
This commit is contained in:
Marco Trevisan (Treviño) 2019-12-04 13:44:08 +01:00
parent a176fa1d34
commit b2e55308d6
2 changed files with 15 additions and 8 deletions

View file

@ -172,11 +172,11 @@ fpi_enums = gnome.mkenums_simple('fpi-enums',
fpi_enums_h = fpi_enums[1] fpi_enums_h = fpi_enums[1]
drivers_sources += configure_file(input: 'empty_file', drivers_sources += configure_file(input: 'empty_file',
output: 'fp-drivers.c', output: 'fpi-drivers.c',
capture: true, capture: true,
command: [ command: [
'echo', 'echo',
drivers_type_list + '\n\n' + drivers_type_func '\n'.join(drivers_type_list + [] + drivers_type_func)
]) ])
mapfile = 'libfprint.ver' mapfile = 'libfprint.ver'

View file

@ -117,15 +117,22 @@ foreach driver: drivers
endforeach endforeach
# Export the drivers' types to the core code # Export the drivers' types to the core code
drivers_type_list = '#include <glib-object.h>\n' drivers_type_list = []
drivers_type_list += '#include "fpi-context.h"\n' drivers_type_func = []
drivers_type_func = 'void fpi_get_driver_types(GArray *drivers)\n{\n\tGType t;\n' drivers_type_list += '#include <glib-object.h>'
drivers_type_list += '#include "fpi-context.h"'
drivers_type_list += ''
drivers_type_func += 'void fpi_get_driver_types (GArray *drivers)'
drivers_type_func += ' {'
drivers_type_func += ' GType t;'
drivers_type_func += ''
foreach driver: drivers foreach driver: drivers
drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);\n' drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);'
drivers_type_func += ' t = fpi_device_' + driver + '_get_type(); g_array_append_val (drivers, t);\n' drivers_type_func += ' t = fpi_device_' + driver + '_get_type ();'
drivers_type_func += ' g_array_append_val (drivers, t);\n'
endforeach endforeach
drivers_type_list += '' drivers_type_list += ''
drivers_type_func += '};' drivers_type_func += '}'
root_inc = include_directories('.') root_inc = include_directories('.')