tools: add include path handling to rmlvo-to-keymap Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/tools/rmlvo-to-keymap.c b/tools/rmlvo-to-keymap.c
index 77e350f..f645e53 100644
--- a/tools/rmlvo-to-keymap.c
+++ b/tools/rmlvo-to-keymap.c
@@ -35,11 +35,14 @@
#include "xkbcomp/rules.h"
#include "xkbcommon/xkbcommon.h"
+#define DEFAULT_INCLUDE_PATH_PLACEHOLDER "__defaults__"
+
static bool verbose = false;
static enum output_format {
FORMAT_KEYMAP,
FORMAT_KCCGST,
} output_format = FORMAT_KEYMAP;
+static darray(const char *) includes;
static void
usage(char **argv)
@@ -53,6 +56,16 @@ usage(char **argv)
" Enable verbose debugging output\n"
" --kccgst\n"
" Print a keymap which only includes the KcCGST component names instead of the full keymap\n"
+ " --include\n"
+ " Add the given path to the include path list. This option is\n"
+ " order-dependent, include paths given first are searched first.\n"
+ " If an include path is given, the default include path list is\n"
+ " not used. Use --include-defaults to add the default include\n"
+ " paths\n"
+ " --include-defaults\n"
+ " Add the default set of include directories.\n"
+ " This option is order-dependent, include paths given first\n"
+ " are searched first.\n"
"\n"
"XKB-specific options:\n"
" --rules <rules>\n"
@@ -78,6 +91,8 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
enum options {
OPT_VERBOSE,
OPT_KCCGST,
+ OPT_INCLUDE,
+ OPT_INCLUDE_DEFAULTS,
OPT_RULES,
OPT_MODEL,
OPT_LAYOUT,
@@ -85,14 +100,16 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
OPT_OPTION,
};
static struct option opts[] = {
- {"help", no_argument, 0, 'h'},
- {"verbose", no_argument, 0, OPT_VERBOSE},
- {"kccgst", no_argument, 0, OPT_KCCGST},
- {"rules", required_argument, 0, OPT_RULES},
- {"model", required_argument, 0, OPT_MODEL},
- {"layout", required_argument, 0, OPT_LAYOUT},
- {"variant", required_argument, 0, OPT_VARIANT},
- {"options", required_argument, 0, OPT_OPTION},
+ {"help", no_argument, 0, 'h'},
+ {"verbose", no_argument, 0, OPT_VERBOSE},
+ {"kccgst", no_argument, 0, OPT_KCCGST},
+ {"include", required_argument, 0, OPT_INCLUDE},
+ {"include-defaults", no_argument, 0, OPT_INCLUDE_DEFAULTS},
+ {"rules", required_argument, 0, OPT_RULES},
+ {"model", required_argument, 0, OPT_MODEL},
+ {"layout", required_argument, 0, OPT_LAYOUT},
+ {"variant", required_argument, 0, OPT_VARIANT},
+ {"options", required_argument, 0, OPT_OPTION},
{0, 0, 0, 0},
};
@@ -113,6 +130,12 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
case OPT_KCCGST:
output_format = FORMAT_KCCGST;
break;
+ case OPT_INCLUDE:
+ darray_append(includes, optarg);
+ break;
+ case OPT_INCLUDE_DEFAULTS:
+ darray_append(includes, DEFAULT_INCLUDE_PATH_PLACEHOLDER);
+ break;
case OPT_RULES:
names->rules = optarg;
break;
@@ -188,6 +211,7 @@ main(int argc, char **argv)
.options = NULL,
};
int rc = 1;
+ const char **path;
if (argc <= 1) {
usage(argv);
@@ -206,7 +230,15 @@ main(int argc, char **argv)
}
xkb_context_sanitize_rule_names(ctx, &names);
- xkb_context_include_path_append_default(ctx);
+ if (darray_empty(includes))
+ darray_append(includes, DEFAULT_INCLUDE_PATH_PLACEHOLDER);
+
+ darray_foreach(path, includes) {
+ if (streq(*path, DEFAULT_INCLUDE_PATH_PLACEHOLDER))
+ xkb_context_include_path_append_default(ctx);
+ else
+ xkb_context_include_path_append(ctx, *path);
+ }
if (output_format == FORMAT_KEYMAP) {
rc = print_keymap(ctx, &names) ? EXIT_SUCCESS : EXIT_FAILURE;