mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-09-10 13:00:08 +00:00
build: Add script to update the unsupported devices from wiki
Avoid some more manual labor
This commit is contained in:
committed by
Marco Trevisan
parent
833d39ab59
commit
b72feabc58
@@ -26,9 +26,10 @@
|
|||||||
|
|
||||||
static const FpIdEntry allowlist_id_table[] = {
|
static const FpIdEntry allowlist_id_table[] = {
|
||||||
/* Currently known and unsupported devices.
|
/* Currently known and unsupported devices.
|
||||||
* You can generate this list from the wiki page using e.g.:
|
* You can regenerate this list from the wiki page with:
|
||||||
* gio cat https://gitlab.freedesktop.org/libfprint/wiki/-/wikis/Unsupported-Devices.md | sed -n 's!|.*\([0-9a-fA-F]\{4\}\):\([0-9a-fA-F]\{4\}\).*|.*! { .vid = 0x\1, .pid = 0x\2 },!p'
|
* meson compile -C <build-dir> sync-unsupported-devices
|
||||||
*/
|
*/
|
||||||
|
/* --- BEGIN GENERATED IDS --- */
|
||||||
{ .vid = 0x0a5c, .pid = 0x5802 },
|
{ .vid = 0x0a5c, .pid = 0x5802 },
|
||||||
{ .vid = 0x047d, .pid = 0x00f2 },
|
{ .vid = 0x047d, .pid = 0x00f2 },
|
||||||
{ .vid = 0x047d, .pid = 0x8054 },
|
{ .vid = 0x047d, .pid = 0x8054 },
|
||||||
@@ -166,6 +167,7 @@ static const FpIdEntry allowlist_id_table[] = {
|
|||||||
{ .vid = 0x298d, .pid = 0x2033 },
|
{ .vid = 0x298d, .pid = 0x2033 },
|
||||||
{ .vid = 0x2df0, .pid = 0x0003 },
|
{ .vid = 0x2df0, .pid = 0x0003 },
|
||||||
{ .vid = 0x3538, .pid = 0x0930 },
|
{ .vid = 0x3538, .pid = 0x0930 },
|
||||||
|
/* --- END GENERATED IDS --- */
|
||||||
{ .vid = 0 },
|
{ .vid = 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -301,8 +301,9 @@ libfprint_private_dep = declare_dependency(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
udev_hwdb_list_file = files('fprint-list-udev-hwdb.c')
|
||||||
udev_hwdb = executable('fprint-list-udev-hwdb',
|
udev_hwdb = executable('fprint-list-udev-hwdb',
|
||||||
'fprint-list-udev-hwdb.c',
|
udev_hwdb_list_file,
|
||||||
dependencies: libfprint_private_dep,
|
dependencies: libfprint_private_dep,
|
||||||
link_with: libfprint_drivers,
|
link_with: libfprint_drivers,
|
||||||
install: false,
|
install: false,
|
||||||
@@ -366,6 +367,10 @@ sync_udev_udb = custom_target('sync-udev-hwdb',
|
|||||||
|
|
||||||
alias_target('sync-udev-hwdb', sync_udev_udb)
|
alias_target('sync-udev-hwdb', sync_udev_udb)
|
||||||
|
|
||||||
|
run_target('sync-unsupported-devices',
|
||||||
|
command: [ sync_unsupported_files, udev_hwdb_list_file ]
|
||||||
|
)
|
||||||
|
|
||||||
supported_devices = executable('fprint-list-supported-devices',
|
supported_devices = executable('fprint-list-supported-devices',
|
||||||
'fprint-list-supported-devices.c',
|
'fprint-list-supported-devices.c',
|
||||||
dependencies: libfprint_private_dep,
|
dependencies: libfprint_private_dep,
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ project('libfprint', [ 'c', 'cpp' ],
|
|||||||
fs = import('fs')
|
fs = import('fs')
|
||||||
gnome = import('gnome')
|
gnome = import('gnome')
|
||||||
|
|
||||||
|
python3 = find_program('python3')
|
||||||
|
|
||||||
libfprint_conf = configuration_data()
|
libfprint_conf = configuration_data()
|
||||||
libfprint_conf.set_quoted('LIBFPRINT_VERSION', meson.project_version())
|
libfprint_conf.set_quoted('LIBFPRINT_VERSION', meson.project_version())
|
||||||
|
|
||||||
@@ -101,6 +103,8 @@ mathlib_dep = cc.find_library('m', required: false)
|
|||||||
sh = find_program('sh', required: true)
|
sh = find_program('sh', required: true)
|
||||||
cairo_dep = dependency('cairo', required: false)
|
cairo_dep = dependency('cairo', required: false)
|
||||||
|
|
||||||
|
sync_unsupported_files = files('scripts' / 'sync-unsupported-devices.py')
|
||||||
|
|
||||||
# introspection scanning and Gio-2.0.gir
|
# introspection scanning and Gio-2.0.gir
|
||||||
gobject_introspection = dependency('gobject-introspection-1.0', required: get_option('introspection'))
|
gobject_introspection = dependency('gobject-introspection-1.0', required: get_option('introspection'))
|
||||||
|
|
||||||
|
|||||||
Executable
+71
@@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Update the hardcoded allowlist of currently unsupported devices in
|
||||||
|
# fprint-list-udev-hwdb.c from the libfprint wiki page.
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from urllib.request import urlopen
|
||||||
|
|
||||||
|
DEFAULT_URL = (
|
||||||
|
"https://gitlab.freedesktop.org/libfprint/wiki/-/wikis/Unsupported-Devices.md"
|
||||||
|
)
|
||||||
|
|
||||||
|
ID_RE = re.compile(r"\|.*([0-9a-fA-F]{4}):([0-9a-fA-F]{4}).*\|.*")
|
||||||
|
|
||||||
|
BEGIN_MARKER = " /* --- BEGIN GENERATED IDS --- */\n"
|
||||||
|
END_MARKER = " /* --- END GENERATED IDS --- */\n"
|
||||||
|
|
||||||
|
|
||||||
|
def fetch(url):
|
||||||
|
try:
|
||||||
|
with urlopen(url) as response:
|
||||||
|
return response.read().decode("utf-8")
|
||||||
|
except OSError as exc:
|
||||||
|
print(f"Could not download {url}: {exc}", file=sys.stderr)
|
||||||
|
sys.exit(77)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_entries(text):
|
||||||
|
devices = set()
|
||||||
|
for line in text.splitlines():
|
||||||
|
match = ID_RE.match(line)
|
||||||
|
if match:
|
||||||
|
devices.add((match.group(1).lower(), match.group(2).lower()))
|
||||||
|
return [f" {{ .vid = 0x{vid}, .pid = 0x{pid} }}," for vid, pid in sorted(devices)]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("source_file", help="Path to hwdb file")
|
||||||
|
parser.add_argument("--url", default=DEFAULT_URL, help="Wiki page URL")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
entries = parse_entries(fetch(args.url))
|
||||||
|
if not entries:
|
||||||
|
sys.exit("No device ids found on the wiki page")
|
||||||
|
|
||||||
|
with open(args.source_file, "r", encoding="utf-8") as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
before, begin, rest = content.partition(BEGIN_MARKER)
|
||||||
|
_, end, after = rest.partition(END_MARKER)
|
||||||
|
if not begin or not end:
|
||||||
|
sys.exit("Could not locate generated id markers in " + args.source_file)
|
||||||
|
|
||||||
|
block = BEGIN_MARKER + "\n".join(entries) + "\n" + END_MARKER
|
||||||
|
new_content = before + block + after
|
||||||
|
|
||||||
|
if new_content == content:
|
||||||
|
print("allowlist_id_table is already up to date")
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(args.source_file, "w", encoding="utf-8") as f:
|
||||||
|
f.write(new_content)
|
||||||
|
|
||||||
|
print(f"Updated allowlist_id_table with {len(entries)} entries")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -26,8 +26,6 @@ envs.set('FP_PRINTS_PATH', meson.project_source_root() / 'examples' / 'prints')
|
|||||||
|
|
||||||
envs.set('NO_AT_BRIDGE', '1')
|
envs.set('NO_AT_BRIDGE', '1')
|
||||||
|
|
||||||
python3 = find_program('python3')
|
|
||||||
|
|
||||||
installed_tests = get_option('installed-tests')
|
installed_tests = get_option('installed-tests')
|
||||||
installed_tests_execdir = libexecdir / 'installed-tests' / versioned_libname
|
installed_tests_execdir = libexecdir / 'installed-tests' / versioned_libname
|
||||||
installed_tests_testdir = datadir / 'installed-tests' / versioned_libname
|
installed_tests_testdir = datadir / 'installed-tests' / versioned_libname
|
||||||
|
|||||||
Reference in New Issue
Block a user