1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-04 21:47:31 +03:00

Use same script to build key list in Makefile and meson

This commit is contained in:
Michal Suchanek 2017-06-27 11:48:45 +02:00
parent 259d1af8d6
commit 1b83323719
4 changed files with 13 additions and 20 deletions

View File

@ -3925,10 +3925,10 @@ noinst_LTLIBRARIES += \
src/udev/keyboard-keys-list.txt:
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/input.h - < /dev/null | $(AWK) '/^#define[ \t]+KEY_[^ ]+[ \t]+[0-9K]/ { if ($$2 != "KEY_MAX") { print $$2 } }' > $@
$(AM_V_GEN)$(top_srcdir)/src/udev/generate-keyboard-keys-list.sh "$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS)" > $@
src/udev/keyboard-keys-from-name.gperf: src/udev/keyboard-keys-list.txt
$(AM_V_GEN)$(AWK) 'BEGIN{ print "struct key_name { const char* name; unsigned short id; };"; print "%null-strings"; print "%%";} { print tolower(substr($$1 ,5)) ", " $$1 }' < $< > $@
$(AM_V_GEN)$(top_srcdir)/src/udev/generate-keyboard-keys-gperf.sh $< > $@
src/udev/keyboard-keys-from-name.h: src/udev/keyboard-keys-from-name.gperf
$(AM_V_GPERF)$(GPERF) -L ANSI-C -t -N keyboard_lookup_key -H hash_key_name -p -C < $< > $@

View File

@ -1,16 +0,0 @@
#!/usr/bin/env python3
"""Generate keyboard-keys-from-name.gperf from keyboard-keys-list.txt
"""
import sys
input = sys.argv[1]
print("""\
struct key_name { const char* name; unsigned short id; };
%null-strings
%%""")
for line in open(input):
print("{0}, {1}".format(line.rstrip()[4:].lower(), line.rstrip()))

View File

@ -0,0 +1,9 @@
#!/bin/sh -eu
awk ' BEGIN {
print "struct key_name { const char* name; unsigned short id; };"
print "%null-strings"
print "%%"
}
/^KEY_/ { print tolower(substr($1 ,5)) ", " $1 }
' < "$1"

View File

@ -59,13 +59,13 @@ keyboard_keys_list_txt = custom_target(
command : [generate_keyboard_keys_list, cpp],
capture : true)
generate_keyboard_gperf = find_program('generate-keyboard-gperf.py')
generate_keyboard_keys_gperf = find_program('generate-keyboard-keys-gperf.sh')
fname = 'keyboard-keys-from-name.gperf'
gperf_file = custom_target(
fname,
input : keyboard_keys_list_txt,
output : fname,
command : [generate_keyboard_gperf, '@INPUT@'],
command : [generate_keyboard_keys_gperf, '@INPUT@'],
capture : true)
fname = 'keyboard-keys-from-name.h'