build: Remove the need to modify sources for new drivers

Instead of having to modify both fp_internal.h to list each driver
definition structure, and core.c to add those drivers to arrays we
can loop over, generate both of those using meson.
This commit is contained in:
Bastien Nocera 2018-05-24 12:16:18 +02:00
parent ff09456cf5
commit fc92f62136
5 changed files with 35 additions and 128 deletions

View file

@ -123,73 +123,7 @@ static void register_driver(struct fp_driver *drv)
fp_dbg("registered driver %s", drv->name);
}
static struct fp_driver * const primitive_drivers[] = {
#ifdef ENABLE_UPEKTS
&upekts_driver,
#endif
};
static struct fp_img_driver * const img_drivers[] = {
#ifdef ENABLE_AES3500
&aes3500_driver,
#endif
#ifdef ENABLE_AES4000
&aes4000_driver,
#endif
#ifdef ENABLE_AES2501
&aes2501_driver,
#endif
#ifdef ENABLE_AES2550
&aes2550_driver,
#endif
#ifdef ENABLE_URU4000
&uru4000_driver,
#endif
#ifdef ENABLE_VCOM5S
&vcom5s_driver,
#endif
#ifdef ENABLE_UPEKSONLY
&upeksonly_driver,
#endif
#ifdef ENABLE_AES1610
&aes1610_driver,
#endif
#ifdef ENABLE_AES1660
&aes1660_driver,
#endif
#ifdef ENABLE_AES2660
&aes2660_driver,
#endif
#ifdef ENABLE_VFS101
&vfs101_driver,
#endif
#ifdef ENABLE_VFS301
&vfs301_driver,
#endif
#ifdef ENABLE_VFS5011
&vfs5011_driver,
#endif
#ifdef ENABLE_UPEKTC
&upektc_driver,
#endif
#ifdef ENABLE_UPEKTC_IMG
&upektc_img_driver,
#endif
#ifdef ENABLE_ETES603
&etes603_driver,
#endif
#ifdef ENABLE_VFS0050
&vfs0050_driver,
#endif
#ifdef ENABLE_ELAN
&elan_driver,
#endif
/*#ifdef ENABLE_FDU2000
&fdu2000_driver,
#endif
*/
};
#include "drivers_arrays.h"
static void register_drivers(void)
{

1
libfprint/empty_file Normal file
View file

@ -0,0 +1 @@

View file

@ -222,66 +222,7 @@ struct fp_img_driver {
void (*deactivate)(struct fp_img_dev *dev);
};
#ifdef ENABLE_UPEKTS
extern struct fp_driver upekts_driver;
#endif
#ifdef ENABLE_UPEKTC
extern struct fp_img_driver upektc_driver;
#endif
#ifdef ENABLE_UPEKSONLY
extern struct fp_img_driver upeksonly_driver;
#endif
#ifdef ENABLE_URU4000
extern struct fp_img_driver uru4000_driver;
#endif
#ifdef ENABLE_AES1610
extern struct fp_img_driver aes1610_driver;
#endif
#ifdef ENABLE_AES1660
extern struct fp_img_driver aes1660_driver;
#endif
#ifdef ENABLE_AES2501
extern struct fp_img_driver aes2501_driver;
#endif
#ifdef ENABLE_AES2550
extern struct fp_img_driver aes2550_driver;
#endif
#ifdef ENABLE_AES2660
extern struct fp_img_driver aes2660_driver;
#endif
#ifdef ENABLE_AES3500
extern struct fp_img_driver aes3500_driver;
#endif
#ifdef ENABLE_AES4000
extern struct fp_img_driver aes4000_driver;
#endif
#ifdef ENABLE_FDU2000
extern struct fp_img_driver fdu2000_driver;
#endif
#ifdef ENABLE_VCOM5S
extern struct fp_img_driver vcom5s_driver;
#endif
#ifdef ENABLE_VFS101
extern struct fp_img_driver vfs101_driver;
#endif
#ifdef ENABLE_VFS301
extern struct fp_img_driver vfs301_driver;
#endif
#ifdef ENABLE_VFS5011
extern struct fp_img_driver vfs5011_driver;
#endif
#ifdef ENABLE_UPEKTC_IMG
extern struct fp_img_driver upektc_img_driver;
#endif
#ifdef ENABLE_ETES603
extern struct fp_img_driver etes603_driver;
#endif
#ifdef ENABLE_VFS0050
extern struct fp_img_driver vfs0050_driver;
#endif
#ifdef ENABLE_ELAN
extern struct fp_img_driver elan_driver;
#endif
#include "drivers_definitions.h"
extern libusb_context *fpi_usb_ctx;
extern GSList *opened_devices;

View file

@ -128,7 +128,6 @@ foreach driver: drivers
if driver == 'elan'
drivers_sources += [ 'drivers/elan.c', 'drivers/elan.h' ]
endif
drivers_cflags += [ '-DENABLE_' + driver.to_upper() + '=1' ]
endforeach
if aeslib
@ -146,6 +145,22 @@ if imaging_dep.found()
other_sources += [ 'pixman.c' ]
endif
libfprint_sources += configure_file(input: 'empty_file',
output: 'drivers_definitions.h',
capture: true,
command: [
'/bin/echo',
drivers_struct_list
])
libfprint_sources += configure_file(input: 'empty_file',
output: 'drivers_arrays.h',
capture: true,
command: [
'/bin/echo',
drivers_primitive_array + '\n\n' + drivers_img_array
])
deps = [ mathlib_dep, glib_dep, libusb_dep, nss_dep, imaging_dep ]
libfprint = library('fprint',
libfprint_sources + drivers_sources + nbis_sources + other_sources,

View file

@ -46,6 +46,7 @@ mathlib_dep = cc.find_library('m', required: false)
# Drivers
drivers = get_option('drivers').split(',')
all_drivers = [ 'upekts', 'upektc', 'upeksonly', 'vcom5s', 'uru4000', 'aes1610', 'aes1660', 'aes2501', 'aes2550', 'aes2660', 'aes3500', 'aes4000', 'vfs101', 'vfs301', 'vfs5011', 'upektc_img', 'etes603', 'vfs0050', 'elan' ]
primitive_drivers = [ 'upekts' ]
if drivers == [ 'all' ]
drivers = all_drivers
@ -71,6 +72,21 @@ foreach driver: drivers
endif
endforeach
# Export the drivers' structures to the core code
drivers_struct_list = ''
drivers_img_array = 'static struct fp_img_driver * const img_drivers[] = {\n'
drivers_primitive_array = 'static struct fp_driver * const primitive_drivers[] = {\n'
foreach driver: drivers
if primitive_drivers.contains(driver)
drivers_struct_list += 'extern struct fp_driver ' + driver + '_driver;\n'
drivers_primitive_array += ' &' + driver + '_driver,\n'
else
drivers_struct_list += 'extern struct fp_img_driver ' + driver + '_driver;\n'
drivers_img_array += ' &' + driver + '_driver,\n'
endif
endforeach
drivers_img_array += '};'
drivers_primitive_array += '};'
root_inc = include_directories('.')