From caa9267290c51a32073fc0d12380164e7ac0792c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 14 Oct 2013 15:40:51 +1000 Subject: [PATCH] Pass linux/input.h as argument to make-event-names.py Rather than a hardcoded path inside the source. Signed-off-by: Peter Hutterer --- 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 e87c72c..3833d61 100644 --- a/libevdev/Makefile.am +++ b/libevdev/Makefile.am @@ -22,7 +22,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: -- 2.7.4