summaryrefslogtreecommitdiff
path: root/tools/generate-gperfs.py
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-28 20:19:41 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-11-28 20:19:41 +0900
commit6ec439fd4b93ecb660b7cc8bc15f8a59ecc530bd (patch)
tree570ca5d2adf369c6441ac6deada4ea1b2b5f5610 /tools/generate-gperfs.py
parentcb3108669d623afe58a36077e36ae4c66ff7d1c3 (diff)
downloadsystemd-6ec439fd4b93ecb660b7cc8bc15f8a59ecc530bd.tar.gz
tools: move generate-gperfs.py to tools/
Diffstat (limited to 'tools/generate-gperfs.py')
-rwxr-xr-xtools/generate-gperfs.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/generate-gperfs.py b/tools/generate-gperfs.py
new file mode 100755
index 0000000000..aca9ab1fe9
--- /dev/null
+++ b/tools/generate-gperfs.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+"""Generate %-from-name.gperf from %-list.txt
+"""
+
+import sys
+
+name, prefix, input = sys.argv[1:]
+
+print("""\
+%{
+#if __GNUC__ >= 7
+_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
+#endif
+%}""")
+print("""\
+struct {}_name {{ const char* name; int id; }};
+%null-strings
+%%""".format(name))
+
+for line in open(input):
+ print("{0}, {1}{0}".format(line.rstrip(), prefix))