summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Suchanek <msuchanek@suse.de>2017-06-27 11:48:45 +0200
committerMichal Suchanek <msuchanek@suse.de>2017-06-27 13:27:37 +0200
commit1b833237198ae8bcba38c4824dc849b402eab163 (patch)
tree63254899f258e483426d96d9d053d8df8948b1b6
parent259d1af8d6fbb4918a3d43597dbca8cafe06a979 (diff)
downloadsystemd-1b833237198ae8bcba38c4824dc849b402eab163.tar.gz
Use same script to build key list in Makefile and meson
-rw-r--r--Makefile.am4
-rwxr-xr-xsrc/udev/generate-keyboard-gperf.py16
-rwxr-xr-xsrc/udev/generate-keyboard-keys-gperf.sh9
-rw-r--r--src/udev/meson.build4
4 files changed, 13 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am
index c61f371a8e..86343eec39 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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 < $< > $@
diff --git a/src/udev/generate-keyboard-gperf.py b/src/udev/generate-keyboard-gperf.py
deleted file mode 100755
index 03d3bba7d3..0000000000
--- a/src/udev/generate-keyboard-gperf.py
+++ /dev/null
@@ -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()))
diff --git a/src/udev/generate-keyboard-keys-gperf.sh b/src/udev/generate-keyboard-keys-gperf.sh
new file mode 100755
index 0000000000..36ce0bd6cc
--- /dev/null
+++ b/src/udev/generate-keyboard-keys-gperf.sh
@@ -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"
diff --git a/src/udev/meson.build b/src/udev/meson.build
index 9c81bce545..eeb341f8d1 100644
--- a/src/udev/meson.build
+++ b/src/udev/meson.build
@@ -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'