[pve-devel] [PATCH pve-qemu 3/3] update keycodemapdb for 6.0

Stefan Reiter s.reiter at proxmox.com
Thu May 27 12:43:34 CEST 2021


QEMU 6.0 requires the updated version to build correctly, as the
keymap-gen tool gained some new parameters.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 keycodemapdb/data/keymaps.csv |  16 +-
 keycodemapdb/meson.build      |   1 +
 keycodemapdb/tests/Makefile   |  84 +++++++----
 keycodemapdb/tools/keymap-gen | 267 ++++++++++++++++++++++++++++------
 4 files changed, 288 insertions(+), 80 deletions(-)
 create mode 100644 keycodemapdb/meson.build

diff --git a/keycodemapdb/data/keymaps.csv b/keycodemapdb/data/keymaps.csv
index bc2376c..6b1631e 100644
--- a/keycodemapdb/data/keymaps.csv
+++ b/keycodemapdb/data/keymaps.csv
@@ -145,12 +145,12 @@ KEY_KPDOT,83,ANSI_KeypadDecimal,0x41,0x53,0x71,0x71,99,VK_DECIMAL,0x6e,83,83,XK_
 KEY_KPDOT,83,ANSI_KeypadDecimal,0x41,0x53,0x71,0x71,99,VK_DECIMAL,0x6e,83,83,XK_KP_Decimal,0xffae,NumpadDecimal,KPDC,kp_decimal,0x32,0x41
 ,84,,,0x54,,,,,,,,,,,,,,
 KEY_ZENKAKUHANKAKU,85,,,0x76,0x5f,,148,,,,,,,Lang5,HZTG,,,
-KEY_102ND,86,,,0x56,0x61,0x13,100,VK_OEM_102,0xe1,86,86,,,IntlBackslash,LSGT,less,0x7c,
+KEY_102ND,86,,,0x56,0x61,0x13,100,VK_OEM_102,0xe2,86,86,,,IntlBackslash,LSGT,less,0x7c,
 KEY_F11,87,F11,0x67,0x57,0x78,0x56,68,VK_F11,0x7a,87,87,XK_F11,0xffc8,F11,FK11,f11,0x09,0x67
 KEY_F12,88,F12,0x6f,0x58,0x07,0x5e,69,VK_F12,0x7b,88,88,XK_F12,0xffc9,F12,FK12,f12,0x0b,0x6f
-KEY_RO,89,,,0x73,0x51,,135,,,,,,,IntlRo,AB11,ro,,
-KEY_KATAKANA,90,JIS_Kana,0x68,0x78,0x63,,146,VK_KANA,0x15,,,,,Katakana,KATA,,,
-KEY_KATAKANA,90,JIS_Kana,0x68,0x78,0x63,,146,VK_KANA,0x15,,,,,Lang3,KATA,,,
+KEY_RO,89,JIS_Underscore,0x5e,0x73,0x51,,135,,,,,,,IntlRo,AB11,ro,,
+KEY_KATAKANA,90,,,0x78,0x63,,146,VK_KANA,0x15,,,,,Katakana,KATA,,,
+KEY_KATAKANA,90,,,0x78,0x63,,146,VK_KANA,0x15,,,,,Lang3,KATA,,,
 KEY_HIRAGANA,91,,,0x77,0x62,0x87,147,,,,,,,Hiragana,HIRA,hiragana,,
 KEY_HIRAGANA,91,,,0x77,0x62,0x87,147,,,,,,,Lang4,HIRA,hiragana,,
 KEY_HENKAN,92,,,0x79,0x64,0x86,138,,,,,,,Convert,HENK,henkan,,
@@ -192,8 +192,8 @@ KEY_PAUSE,119,,,0xe046,0xe077,0x62,72,VK_PAUSE,0x013,0x66,0x66,XK_Pause,0xff13,P
 KEY_SCALE,120,,,0xe00b,,,,,,,,,,,I128,,,
 KEY_KPCOMMA,121,,,0x7e,0x6d,,133,VK_SEPARATOR??,0x6c,,,,,NumpadComma,KPCO,kp_comma,,
 KEY_KPCOMMA,121,,,0x7e,0x6d,,133,VK_SEPARATOR??,0x6c,,,,,NumpadComma,I129,,,
-KEY_HANGEUL,122,,,,,,144,VK_HANGEUL,0x15,,,,,,HNGL,,,
-KEY_HANJA,123,,,0xe00d,,,145,VK_HANJA,0x19,,,,,,HJCV,,,
+KEY_HANGEUL,122,JIS_Kana,0x68,0x72,,,144,VK_HANGEUL,0x15,,0x71,,,Lang1,HNGL,,,
+KEY_HANJA,123,JIS_Eisu,0x66,0x71,,,145,VK_HANJA,0x19,,0x72,,,Lang2,HJCV,,,
 KEY_YEN,124,JIS_Yen,0x5d,0x7d,0x6a,0x5d,137,,,0x7d,0x7d,,,IntlYen,AE13,yen,,
 KEY_LEFTMETA,125,Command,0x37,0xe05b,0xe01f,0x8b,227,VK_LWIN,0x5b,0x6b,0x6b,XK_Meta_L,0xffe7,MetaLeft,LMTA,meta_l,0x78,0x37
 KEY_LEFTMETA,125,Command,0x37,0xe05b,0xe01f,0x8b,227,VK_LWIN,0x5b,0x6b,0x6b,XK_Meta_L,0xffe7,MetaLeft,LWIN,meta_l,0x78,0x37
@@ -250,8 +250,8 @@ KEY_ISO,170,ISO_Section,0xa,,,,,,,,,,,,I178,,,
 KEY_CONFIG,171,,,0xe001,,,,,,,,,,,I179,,,
 KEY_HOMEPAGE,172,,,0xe032,0xe03a,0x97,,VK_BROWSER_HOME,0xac,,,,,BrowserHome,I180,ac_home,,
 KEY_REFRESH,173,,,0xe067,0xe020,,250,VK_BROWSER_REFRESH,0xa8,,,,,BrowserRefresh,I181,ac_refresh,,
-KEY_EXIT,174,,,0x71,,,,,,,,,,,I182,,,
-KEY_MOVE,175,,,0x72,,,,,,,,,,,I183,,,
+KEY_EXIT,174,,,,,,,,,,,,,,I182,,,
+KEY_MOVE,175,,,,,,,,,,,,,,I183,,,
 KEY_EDIT,176,,,0xe008,,,247,,,,,,,,I184,,,
 KEY_SCROLLUP,177,,,0x75,,,245,,,,,,,,I185,,,
 KEY_SCROLLDOWN,178,,,0xe00f,,,246,,,,,,,,I186,,,
diff --git a/keycodemapdb/meson.build b/keycodemapdb/meson.build
new file mode 100644
index 0000000..eb9416b
--- /dev/null
+++ b/keycodemapdb/meson.build
@@ -0,0 +1 @@
+project('keycodemapdb')
diff --git a/keycodemapdb/tests/Makefile b/keycodemapdb/tests/Makefile
index b25c77c..e1b3875 100644
--- a/keycodemapdb/tests/Makefile
+++ b/keycodemapdb/tests/Makefile
@@ -13,49 +13,81 @@ SOURCES := $(GEN) $(DATA)
 
 .DELETE_ON_ERROR:
 
-stdc: stdc.c osx2win32.h osx2win32_name.h \
-             osx2xkb.h osx2xkb_name.h \
-             html2win32.h html2win32_name.h \
-             osx.h osx_name.h
-	$(CC) -Wall -o $@ $^
-osx2win32.h: $(SOURCES)
+stdc: stdc.c osx2win32.h osx2win32.c osx2win32_name.h osx2win32_name.c \
+             osx2xkb.h osx2xkb.c osx2xkb_name.h osx2xkb_name.c \
+             html2win32.h html2win32.c html2win32_name.h html2win32_name.c \
+             osx.h osx.c osx_name.h osx_name.c
+	$(CC) -Wall -o $@ $(filter %.c, $^)
+osx2win32.c: $(SOURCES)
 	$(GEN) --lang stdc code-map $(DATA) osx win32 > $@
-osx2win32_name.h: $(SOURCES)
+osx2win32.h: $(SOURCES)
+	$(GEN) --lang stdc-header code-map $(DATA) osx win32 > $@
+osx2win32_name.c: $(SOURCES)
 	$(GEN) --lang stdc name-map $(DATA) osx win32 > $@
-osx2xkb.h: $(SOURCES)
+osx2win32_name.h: $(SOURCES)
+	$(GEN) --lang stdc-header name-map $(DATA) osx win32 > $@
+osx2xkb.c: $(SOURCES)
 	$(GEN) --lang stdc code-map $(DATA) osx xkb > $@
-osx2xkb_name.h: $(SOURCES)
+osx2xkb.h: $(SOURCES)
+	$(GEN) --lang stdc-header code-map $(DATA) osx xkb > $@
+osx2xkb_name.c: $(SOURCES)
 	$(GEN) --lang stdc name-map $(DATA) osx xkb > $@
-html2win32.h: $(SOURCES)
+osx2xkb_name.h: $(SOURCES)
+	$(GEN) --lang stdc-header name-map $(DATA) osx xkb > $@
+html2win32.c: $(SOURCES)
 	$(GEN) --lang stdc code-map $(DATA) html win32 > $@
-html2win32_name.h: $(SOURCES)
+html2win32.h: $(SOURCES)
+	$(GEN) --lang stdc-header code-map $(DATA) html win32 > $@
+html2win32_name.c: $(SOURCES)
 	$(GEN) --lang stdc name-map $(DATA) html win32 > $@
-osx.h: $(SOURCES)
+html2win32_name.h: $(SOURCES)
+	$(GEN) --lang stdc-header name-map $(DATA) html win32 > $@
+osx.c: $(SOURCES)
 	$(GEN) --lang stdc code-table $(DATA) osx > $@
-osx_name.h: $(SOURCES)
+osx.h: $(SOURCES)
+	$(GEN) --lang stdc-header code-table $(DATA) osx > $@
+osx_name.c: $(SOURCES)
 	$(GEN) --lang stdc name-table $(DATA) osx > $@
+osx_name.h: $(SOURCES)
+	$(GEN) --lang stdc-header name-table $(DATA) osx > $@
 
-stdc++: stdc++.cc osx2win32.hh osx2win32_name.hh \
-             osx2xkb.hh osx2xkb_name.hh \
-             html2win32.hh html2win32_name.hh \
-             osx.hh osx_name.hh
-	$(CXX) -Wall -std=c++11 -o $@ $^
-osx2win32.hh: $(SOURCES)
+stdc++: stdc++.cc osx2win32.hh osx2win32.cc osx2win32_name.hh osx2win32_name.cc \
+             osx2xkb.hh osx2xkb.cc osx2xkb_name.hh osx2xkb_name.cc \
+             html2win32.hh html2win32.cc html2win32_name.hh html2win32_name.cc \
+             osx.hh osx.cc osx_name.hh osx_name.cc
+	$(CXX) -Wall -std=c++11 -o $@ $(filter %.cc, $^)
+osx2win32.cc: $(SOURCES)
 	$(GEN) --lang stdc++ code-map $(DATA) osx win32 > $@
-osx2win32_name.hh: $(SOURCES)
+osx2win32.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header code-map $(DATA) osx win32 > $@
+osx2win32_name.cc: $(SOURCES)
 	$(GEN) --lang stdc++ name-map $(DATA) osx win32 > $@
-osx2xkb.hh: $(SOURCES)
+osx2win32_name.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header name-map $(DATA) osx win32 > $@
+osx2xkb.cc: $(SOURCES)
 	$(GEN) --lang stdc++ code-map $(DATA) osx xkb > $@
-osx2xkb_name.hh: $(SOURCES)
+osx2xkb.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header code-map $(DATA) osx xkb > $@
+osx2xkb_name.cc: $(SOURCES)
 	$(GEN) --lang stdc++ name-map $(DATA) osx xkb > $@
-html2win32.hh: $(SOURCES)
+osx2xkb_name.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header name-map $(DATA) osx xkb > $@
+html2win32.cc: $(SOURCES)
 	$(GEN) --lang stdc++ code-map $(DATA) html win32 > $@
-html2win32_name.hh: $(SOURCES)
+html2win32.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header code-map $(DATA) html win32 > $@
+html2win32_name.cc: $(SOURCES)
 	$(GEN) --lang stdc++ name-map $(DATA) html win32 > $@
-osx.hh: $(SOURCES)
+html2win32_name.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header name-map $(DATA) html win32 > $@
+osx.cc: $(SOURCES)
 	$(GEN) --lang stdc++ code-table $(DATA) osx > $@
-osx_name.hh: $(SOURCES)
+osx.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header code-table $(DATA) osx > $@
+osx_name.cc: $(SOURCES)
 	$(GEN) --lang stdc++ name-table $(DATA) osx > $@
+osx_name.hh: $(SOURCES)
+	$(GEN) --lang stdc++-header name-table $(DATA) osx > $@
 
 python2: osx2win32.py osx2win32_name.py \
          osx2xkb.py osx2xkb_name.py \
diff --git a/keycodemapdb/tools/keymap-gen b/keycodemapdb/tools/keymap-gen
index f0269e3..22b4f71 100755
--- a/keycodemapdb/tools/keymap-gen
+++ b/keycodemapdb/tools/keymap-gen
@@ -317,9 +317,8 @@ class LanguageGenerator(object):
         raise NotImplementedError()
 
     def generate_header(self, database, args):
-        today = time.strftime("%Y-%m-%d %H:%M")
         self._boilerplate([
-            "This file is auto-generated from keymaps.csv on %s" % today,
+            "This file is auto-generated from keymaps.csv",
             "Database checksum sha256(%s)" % database.mapchecksum,
             "To re-generate, run:",
             "  %s" % args,
@@ -509,7 +508,7 @@ class LanguageDocGenerator(LanguageGenerator):
     def _array_code_entry(self, value, name):
         raise NotImplementedError()
 
-    def generate_name_docs(self, varname, database, mapname):
+    def generate_name_docs(self, title, subtitle, database, mapname):
         if mapname not in database.mapname:
             raise Exception("Unknown map %s, expected one of %s" % (
                             mapname, ", ".join(database.mapname.keys())))
@@ -518,10 +517,12 @@ class LanguageDocGenerator(LanguageGenerator):
         keys.sort()
         names = [database.mapname[Database.MAP_LINUX].get(key, "unnamed") for key in keys]
 
-        if varname is None:
-            varname = mapname
+        if title is None:
+            title = mapname
+        if subtitle is None:
+            subtitle = "Docs for %s" % mapname
 
-        self._array_start_name_doc(varname, mapname)
+        self._array_start_name_doc(title, subtitle, mapname)
 
         for i in range(len(keys)):
             key = keys[i]
@@ -531,7 +532,7 @@ class LanguageDocGenerator(LanguageGenerator):
         self._array_end()
 
 
-    def generate_code_docs(self, varname, database, mapname):
+    def generate_code_docs(self, title, subtitle, database, mapname):
         if mapname not in database.mapfrom:
             raise Exception("Unknown map %s, expected one of %s" % (
                             mapname, ", ".join(database.mapfrom.keys())))
@@ -546,10 +547,12 @@ class LanguageDocGenerator(LanguageGenerator):
             names = database.mapname[Database.MAP_LINUX]
             namemap = Database.MAP_LINUX
 
-        if varname is None:
-            varname = mapname
+        if title is None:
+            title = mapname
+        if subtitle is None:
+            subtitle = "Docs for %s" % mapname
 
-        self._array_start_code_doc(varname, mapname, namemap)
+        self._array_start_code_doc(title, subtitle, mapname, namemap)
 
         for i in range(len(keys)):
             key = keys[i]
@@ -623,6 +626,68 @@ class CLanguageGenerator(LanguageSrcGenerator):
         else:
             print(("  {" + indexfmt + ", " + valuefmt + "}, /* %s */") % (index, value, comment))
 
+class StdCLanguageGenerator(CLanguageGenerator):
+
+    def __init__(self):
+        super(StdCLanguageGenerator, self).__init__("unsigned short", "char *", "unsigned int")
+
+class GLib2LanguageGenerator(CLanguageGenerator):
+
+    def __init__(self):
+        super(GLib2LanguageGenerator, self).__init__("guint16", "gchar *", "guint")
+
+class CHeaderLanguageGenerator(LanguageSrcGenerator):
+
+    def __init__(self, inttypename, strtypename, lentypename):
+        self.inttypename = inttypename
+        self.strtypename = strtypename
+        self.lentypename = lentypename
+
+    def _boilerplate(self, lines):
+        print("/*")
+        for line in lines:
+            print(" * %s" % line)
+        print("*/")
+
+    def _array_start(self, varname, length, defvalue, fromtype, totype):
+        self._varname = varname
+        if fromtype == self.TYPE_STRING:
+            self._length = 0
+        else:
+            self._length = length
+
+    def _array_end(self, fromtype, totype):
+        totypename = self.strtypename if totype == self.TYPE_STRING else self.inttypename
+        if fromtype == self.TYPE_STRING:
+            vartypename = "struct _%s" % self._varname
+            print("%s {" % vartypename)
+            print("  const %s from;" % self.strtypename)
+            print("  const %s to;" % totypename)
+            print("};")
+        else:
+            vartypename = totypename
+        if type(self._length) == str:
+            print("extern const %s %s[%s];" % (vartypename, self._varname, self._length))
+        else:
+            print("extern const %s %s[%d];" % (vartypename, self._varname, self._length))
+        print("extern const %s %s_len;" % (self.lentypename, self._varname))
+
+    def _array_entry(self, index, value, comment, fromtype, totype):
+        if value is None:
+            return
+        if fromtype == self.TYPE_STRING:
+            self._length += 1
+
+class StdCHeaderLanguageGenerator(CHeaderLanguageGenerator):
+
+    def __init__(self):
+        super(StdCHeaderLanguageGenerator, self).__init__("unsigned short", "char *", "unsigned int")
+
+class GLib2HeaderLanguageGenerator(CHeaderLanguageGenerator):
+
+    def __init__(self):
+        super(GLib2HeaderLanguageGenerator, self).__init__("guint16", "gchar *", "guint")
+
 class CppLanguageGenerator(CLanguageGenerator):
 
     def _array_start(self, varname, length, defvalue, fromtype, totype):
@@ -631,10 +696,12 @@ class CppLanguageGenerator(CLanguageGenerator):
         totypename = "const " + self.strtypename if totype == self.TYPE_STRING else self.inttypename
         if fromtype == self.TYPE_INT:
             print("#include <vector>")
+            print("extern const std::vector<%s> %s;" % (totypename, varname));
             print("const std::vector<%s> %s = {" % (totypename, varname))
         else:
             print("#include <map>")
             print("#include <string>")
+            print("extern const std::map<const std::string, %s> %s;" % (totypename, varname))
             print("const std::map<const std::string, %s> %s = {" % (totypename, varname))
 
     def _array_end(self, fromtype, totype):
@@ -654,20 +721,36 @@ class CppLanguageGenerator(CLanguageGenerator):
         else:
             print("  \"%s\", /* %s */" % (value, comment))
 
-class StdCLanguageGenerator(CLanguageGenerator):
-
-    def __init__(self):
-        super(StdCLanguageGenerator, self).__init__("unsigned short", "char *", "unsigned int")
-
 class StdCppLanguageGenerator(CppLanguageGenerator):
 
     def __init__(self):
         super(StdCppLanguageGenerator, self).__init__("unsigned short", "char *", "unsigned int")
 
-class GLib2LanguageGenerator(CLanguageGenerator):
+class CppHeaderLanguageGenerator(CHeaderLanguageGenerator):
+
+    def _array_start(self, varname, length, defvalue, fromtype, totype):
+        if fromtype == self.TYPE_ENUM:
+            raise NotImplementedError("Enums not supported as source in C++ generator")
+        totypename = "const " + self.strtypename if totype == self.TYPE_STRING else self.inttypename
+        if fromtype == self.TYPE_INT:
+            print("#include <vector>")
+            print("extern const std::vector<%s> %s;" % (totypename, varname));
+        else:
+            print("#include <map>")
+            print("#include <string>")
+            print("extern const std::map<const std::string, %s> %s;" % (totypename, varname))
+
+    def _array_end(self, fromtype, totype):
+        pass
+
+    # designated initializers not available in C++
+    def _array_entry(self, index, value, comment, fromtype, totype):
+        pass
+
+class StdCppHeaderLanguageGenerator(CppHeaderLanguageGenerator):
 
     def __init__(self):
-        super(GLib2LanguageGenerator, self).__init__("guint16", "gchar *", "guint")
+        super(StdCppHeaderLanguageGenerator, self).__init__("unsigned short", "char *", "unsigned int")
 
 class PythonLanguageGenerator(LanguageSrcGenerator):
 
@@ -793,16 +876,24 @@ class PodLanguageGenerator(LanguageDocGenerator):
             print("# %s" % line)
         print("#")
 
-    def _array_start_name_doc(self, varname, namemap):
-        print("=head1 %s" % varname)
+    def _array_start_name_doc(self, title, subtitle, namemap):
+        print("=head1 NAME")
+        print("")
+        print("%s - %s" % (title, subtitle))
+        print("")
+        print("=head1 DESCRIPTION")
         print("")
         print("List of %s key code names, with corresponding key code values" % namemap)
         print("")
         print("=over 4")
         print("")
 
-    def _array_start_code_doc(self, varname, codemap, namemap):
-        print("=head1 %s" % varname)
+    def _array_start_code_doc(self, title, subtitle, codemap, namemap):
+        print("=head1 NAME")
+        print("")
+        print("%s - %s" % (title, subtitle))
+        print("")
+        print("=head1 DESCRIPTION")
         print("")
         print("List of %s key code values, with corresponding %s key code names" % (codemap, namemap))
         print("")
@@ -825,10 +916,70 @@ class PodLanguageGenerator(LanguageDocGenerator):
         print("Key name %s" % name)
         print("")
 
+class RSTLanguageGenerator(LanguageDocGenerator):
+
+    def _boilerplate(self, lines):
+        print("..")
+        for line in lines:
+            print("   %s" % line)
+        print("")
+
+    def _array_start_name_doc(self, title, subtitle, namemap):
+        print("=" * len(title))
+        print(title)
+        print("=" * len(title))
+        print("")
+        print("-" * len(subtitle))
+        print(subtitle)
+        print("-" * len(subtitle))
+        print("")
+        print(":Manual section: 7")
+        print(":Manual group: Virtualization Support")
+        print("")
+        print("DESCRIPTION")
+        print("===========")
+        print("List of %s key code names, with corresponding key code values" % namemap)
+        print("")
+
+    def _array_start_code_doc(self, title, subtitle, codemap, namemap):
+        print("=" * len(title))
+        print(title)
+        print("=" * len(title))
+        print("")
+        print("-" * len(subtitle))
+        print(subtitle)
+        print("-" * len(subtitle))
+        print("")
+        print(":Manual section: 7")
+        print(":Manual group: Virtualization Support")
+        print("")
+        print("DESCRIPTION")
+        print("===========")
+        print("List of %s key code values, with corresponding %s key code names" % (codemap, namemap))
+        print("")
+
+    def _array_end(self):
+        print("")
+
+    def _array_name_entry(self, value, name):
+        print("* %s" % name)
+        print("")
+        print("  Key value %d (0x%x)" % (value, value))
+        print("")
+
+    def _array_code_entry(self, value, name):
+        print("* %d (0x%x)" % (value, value))
+        print("")
+        print("  Key name %s" % name)
+        print("")
+
 SRC_GENERATORS = {
     "stdc": StdCLanguageGenerator(),
+    "stdc-header": StdCHeaderLanguageGenerator(),
     "stdc++": StdCppLanguageGenerator(),
+    "stdc++-header": StdCppHeaderLanguageGenerator(),
     "glib2": GLib2LanguageGenerator(),
+    "glib2-header": GLib2HeaderLanguageGenerator(),
     "python2": PythonLanguageGenerator(),
     "python3": PythonLanguageGenerator(),
     "perl": PerlLanguageGenerator(),
@@ -836,16 +987,17 @@ SRC_GENERATORS = {
 }
 DOC_GENERATORS = {
     "pod": PodLanguageGenerator(),
+    "rst": RSTLanguageGenerator(),
 }
 
 def code_map(args):
     database = Database()
     database.load(args.keymaps)
 
-    cliargs = ["keymap-gen", "--lang=%s" % args.lang]
+    cliargs = ["keymap-gen", "code-map", "--lang=%s" % args.lang]
     if args.varname is not None:
         cliargs.append("--varname=%s" % args.varname)
-    cliargs.extend(["code-map", "keymaps.csv", args.frommapname, args.tomapname])
+    cliargs.extend(["keymaps.csv", args.frommapname, args.tomapname])
     SRC_GENERATORS[args.lang].generate_header(database, " ".join(cliargs))
 
     SRC_GENERATORS[args.lang].generate_code_map(args.varname, database, args.frommapname, args.tomapname)
@@ -854,10 +1006,10 @@ def code_table(args):
     database = Database()
     database.load(args.keymaps)
 
-    cliargs = ["keymap-gen", "--lang=%s" % args.lang]
+    cliargs = ["keymap-gen", "code-table", "--lang=%s" % args.lang]
     if args.varname is not None:
         cliargs.append("--varname=%s" % args.varname)
-    cliargs.extend(["code-table", "keymaps.csv", args.mapname])
+    cliargs.extend(["keymaps.csv", args.mapname])
     SRC_GENERATORS[args.lang].generate_header(database, " ".join(cliargs))
 
     SRC_GENERATORS[args.lang].generate_code_table(args.varname, database, args.mapname)
@@ -866,10 +1018,10 @@ def name_map(args):
     database = Database()
     database.load(args.keymaps)
 
-    cliargs = ["keymap-gen", "--lang=%s" % args.lang]
+    cliargs = ["keymap-gen", "name-map", "--lang=%s" % args.lang]
     if args.varname is not None:
         cliargs.append("--varname=%s" % args.varname)
-    cliargs.extend(["name-map", "keymaps.csv", args.frommapname, args.tomapname])
+    cliargs.extend(["keymaps.csv", args.frommapname, args.tomapname])
     SRC_GENERATORS[args.lang].generate_header(database, " ".join(cliargs))
 
     SRC_GENERATORS[args.lang].generate_name_map(args.varname, database, args.frommapname, args.tomapname)
@@ -879,10 +1031,10 @@ def name_table(args):
     database.load(args.keymaps)
 
 
-    cliargs = ["keymap-gen", "--lang=%s" % args.lang]
+    cliargs = ["keymap-gen", "name-table", "--lang=%s" % args.lang]
     if args.varname is not None:
         cliargs.append("--varname=%s" % args.varname)
-    cliargs.extend(["name-table", "keymaps.csv", args.mapname])
+    cliargs.extend(["keymaps.csv", args.mapname])
     SRC_GENERATORS[args.lang].generate_header(database, " ".join(cliargs))
 
     SRC_GENERATORS[args.lang].generate_name_table(args.varname, database, args.mapname)
@@ -892,26 +1044,30 @@ def code_docs(args):
     database.load(args.keymaps)
 
 
-    cliargs = ["keymap-gen", "--lang=%s" % args.lang]
-    if args.varname is not None:
-        cliargs.append("--varname=%s" % args.varname)
-    cliargs.extend(["code-docs", "keymaps.csv", args.mapname])
+    cliargs = ["keymap-gen", "code-docs", "--lang=%s" % args.lang]
+    if args.title is not None:
+        cliargs.append("--title=%s" % args.title)
+    if args.subtitle is not None:
+        cliargs.append("--subtitle=%s" % args.subtitle)
+    cliargs.extend(["keymaps.csv", args.mapname])
     DOC_GENERATORS[args.lang].generate_header(database, " ".join(cliargs))
 
-    DOC_GENERATORS[args.lang].generate_code_docs(args.varname, database, args.mapname)
+    DOC_GENERATORS[args.lang].generate_code_docs(args.title, args.subtitle, database, args.mapname)
 
 def name_docs(args):
     database = Database()
     database.load(args.keymaps)
 
 
-    cliargs = ["keymap-gen", "--lang=%s" % args.lang]
-    if args.varname is not None:
-        cliargs.append("--varname=%s" % args.varname)
-    cliargs.extend(["name-docs", "keymaps.csv", args.mapname])
+    cliargs = ["keymap-gen", "name-docs", "--lang=%s" % args.lang]
+    if args.title is not None:
+        cliargs.append("--title=%s" % args.title)
+    if args.subtitle is not None:
+        cliargs.append("--subtitle=%s" % args.subtitle)
+    cliargs.extend(["keymaps.csv", args.mapname])
     DOC_GENERATORS[args.lang].generate_header(database, " ".join(cliargs))
 
-    DOC_GENERATORS[args.lang].generate_name_docs(args.varname, database, args.mapname)
+    DOC_GENERATORS[args.lang].generate_name_docs(args.title, args.subtitle, database, args.mapname)
 
 def usage():
     print ("Please select a command:")
@@ -921,43 +1077,62 @@ def usage():
 def main():
     parser = argparse.ArgumentParser()
 
-    parser.add_argument("--lang", default="stdc",
-                        help="Output language, (src=%s, doc=%s)" % (
-                            ",".join(SRC_GENERATORS.keys()),
-                            ",".join(DOC_GENERATORS.keys())))
-    parser.add_argument("--varname", default=None,
-                        help="Data variable name")
-
     subparsers = parser.add_subparsers(help="sub-command help")
 
     codemapparser = subparsers.add_parser("code-map", help="Generate a mapping between code tables")
+    codemapparser.add_argument("--varname", default=None, help="Data variable name")
+    codemapparser.add_argument("--lang", default="stdc",
+                        help="Output language (%s)" % (
+                            ",".join(SRC_GENERATORS.keys())))
     codemapparser.add_argument("keymaps", help="Path to keymap CSV data file")
     codemapparser.add_argument("frommapname", help="Source code table name")
     codemapparser.add_argument("tomapname", help="Target code table name")
     codemapparser.set_defaults(func=code_map)
 
     codetableparser = subparsers.add_parser("code-table", help="Generate a flat code table")
+    codetableparser.add_argument("--lang", default="stdc",
+                        help="Output language (%s)" % (
+                            ",".join(SRC_GENERATORS.keys())))
+    codetableparser.add_argument("--varname", default=None, help="Data variable name")
     codetableparser.add_argument("keymaps", help="Path to keymap CSV data file")
     codetableparser.add_argument("mapname", help="Code table name")
     codetableparser.set_defaults(func=code_table)
 
     namemapparser = subparsers.add_parser("name-map", help="Generate a mapping to names")
+    namemapparser.add_argument("--lang", default="stdc",
+                        help="Output language (%s)" % (
+                            ",".join(SRC_GENERATORS.keys())))
+    namemapparser.add_argument("--varname", default=None, help="Data variable name")
     namemapparser.add_argument("keymaps", help="Path to keymap CSV data file")
     namemapparser.add_argument("frommapname", help="Source code table name")
     namemapparser.add_argument("tomapname", help="Target name table name")
     namemapparser.set_defaults(func=name_map)
 
     nametableparser = subparsers.add_parser("name-table", help="Generate a flat name table")
+    nametableparser.add_argument("--lang", default="stdc",
+                        help="Output language, (%s)" % (
+                            ",".join(SRC_GENERATORS.keys())))
+    nametableparser.add_argument("--varname", default=None, help="Data variable name")
     nametableparser.add_argument("keymaps", help="Path to keymap CSV data file")
     nametableparser.add_argument("mapname", help="Name table name")
     nametableparser.set_defaults(func=name_table)
 
     codedocsparser = subparsers.add_parser("code-docs", help="Generate code documentation")
+    codedocsparser.add_argument("--lang", default="pod",
+                        help="Output language (%s)" % (
+                            ",".join(DOC_GENERATORS.keys())))
+    codedocsparser.add_argument("--title", default=None, help="Document title")
+    codedocsparser.add_argument("--subtitle", default=None, help="Document subtitle")
     codedocsparser.add_argument("keymaps", help="Path to keymap CSV data file")
     codedocsparser.add_argument("mapname", help="Code table name")
     codedocsparser.set_defaults(func=code_docs)
 
     namedocsparser = subparsers.add_parser("name-docs", help="Generate name documentation")
+    namedocsparser.add_argument("--lang", default="pod",
+                        help="Output language (%s)" % (
+                            ",".join(DOC_GENERATORS.keys())))
+    namedocsparser.add_argument("--title", default=None, help="Document title")
+    namedocsparser.add_argument("--subtitle", default=None, help="Document subtitle")
     namedocsparser.add_argument("keymaps", help="Path to keymap CSV data file")
     namedocsparser.add_argument("mapname", help="Name table name")
     namedocsparser.set_defaults(func=name_docs)
-- 
2.20.1






More information about the pve-devel mailing list