[PATCH libevdev 3/8] Pass linux/input.h as argument to make-event-names.py
Peter Hutterer
peter.hutterer at who-t.net
Sun Oct 13 23:14:51 PDT 2013
Rather than a hardcoded path inside the source.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
libevdev/Makefile.am | 2 +-
libevdev/make-event-names.py | 11 +++++------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/libevdev/Makefile.am b/libevdev/Makefile.am
index e47bd6b..98f4aa5 100644
--- a/libevdev/Makefile.am
+++ b/libevdev/Makefile.am
@@ -21,7 +21,7 @@ libevdevincludedir = $(includedir)/libevdev-1.0/libevdev
libevdevinclude_HEADERS = libevdev.h libevdev-uinput.h
event-names.h: Makefile make-event-names.py
- $(PYTHON) $(srcdir)/make-event-names.py --output=c > $@
+ $(PYTHON) $(srcdir)/make-event-names.py --output=c $(top_srcdir)/include/linux/input.h > $@
EXTRA_DIST = make-event-names.py
CLEANFILES = event-names.h
diff --git a/libevdev/make-event-names.py b/libevdev/make-event-names.py
index e321bd7..b1db9bc 100755
--- a/libevdev/make-event-names.py
+++ b/libevdev/make-event-names.py
@@ -9,8 +9,6 @@ import re
import sys
import argparse
-SOURCE_FILE = "/usr/include/linux/input.h"
-
class Bits(object):
pass
@@ -166,9 +164,7 @@ def parse_define(bits, line):
b = getattr(bits, attrname)
b[value] = name
-def parse(path):
- fp = open(path)
-
+def parse(fp):
bits = Bits()
lines = fp.readlines()
@@ -180,11 +176,14 @@ def parse(path):
return bits
if __name__ == "__main__":
- bits = parse(SOURCE_FILE)
parser = argparse.ArgumentParser()
parser.add_argument("--output", default="c")
+ parser.add_argument('source', metavar="/path/to/linux/input.h",
+ type=argparse.FileType('r'),
+ help='source file to parse')
args = parser.parse_args(sys.argv[1:])
+ bits = parse(args.source)
if args.output == "python":
print_python_mapping_table(bits)
else:
--
1.8.3.1
More information about the Input-tools
mailing list