The tools previously linked against a static version (by simply recompiling
everythiong). This isn't necessary, we can link them against libxkbcommon.so.
Only exception: The xbkcli-compile-keymap tool needs a private API for the
--kccgst flag. Avoid this by disabling this flag in the installed tool and
building the same tool, statically linked but not-installed.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Drop the ronn source files, check in the generated files instead. This gets rid
of the ruby+gem+ronn toolchain requirement at the cost of having to edit raw man
pages.
ronn files are as-generated but with the preamble and generation date removed.
The latter isn't important enough to keep, it'll just go stale for manually
maintained files and it's not worth setting up a configure_file() just for that
date.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
A pytest wrapper around our xkbcli tool - copied from libinput.
This calls our various xkbcli tools with varying options and check that they
either succeed or return the right error code. The coverage is limited, it
does not (and cannot) test for all possible combinations but it should provide a
good red flag if we have inconsistent behavior or accidentally break some
combination of flags.
Meanwhile, we can at least assume that all our commandline arguments are parsed
without segfaulting or worse.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
On all platforms we build on where getopt.h is available, getopt_long is also
available. Only Windows doesn't have either but that's no reason for us to
differentiate between the two.
If we need to special-case getopt vs getopt_long, it's probably better to
implement our own cross-platform version of it and use that.
Fixes#161
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Requiring long options for this tool means it's immediately obvious what an
invocation does, compare e.g.
xkbcli interactive-evdev -gcd
to the equivalent:
xkbcli interactive-evdev --consumed-mode=gtk --enalbe-compose --report-state-changes
This drops the evdev offset argument - that offset should never be anything
other than 8, having this as argument here is more likely to confuse or
produce misleading debugging logs.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The xkbcli tool usage help is ifdef'd out where the tool isn't built but the
man page always includes all tools. Easier that way.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This is the base tool, no subtools are currently connected so you only get help
and version for now. The goal here is to have a git-like infrastructure where
/usr/bin/xkbcli is the main tool, anything else will hide in libexec.
The infrastructure for this is copied from libinput. Tools themselves will
will be installed in $prefix/libexec/xkbcommon and the xkbcli tool forks
off whatever argv[1] is after modifying the PATH to include the libexec dir.
libinput has additional code for checking whether we're running this from the
builddir but it's a bit iffy and it's usefulness is limited - if you're in the
builddir anyway you can just run ./builddir/xkbcli-<toolname> directly.
So for this code here, running ./builddir/xkbcli <toolname> will execute the
one in the prefix/libexecdir.
Since we want that tool available everywhere even where some of the subtools
aren't present, we need to ifdef the getopt handling.
man page generation is handled via ronn which is a ruby program but allows
markdown for the sources. It's hidden behind a meson option to disable where
downloading ronn isn't an option. The setup is generic enough that we can add
other man-pages by just appending to the array.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Windows doesn't have getopt.h. This would prevent building the tools but
they are behind other checks that cause them to be disabled. The only tools
that don't need getopt.h are interactive-wayland and interactive-x11 but
neither is particularly useful on Windows. Just hide all tools behind the getopt
check in preparation for the upcoming tool consolidation work.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
meson complains because this requires 0.50.0 and we don't require that. But
since it defaults to false anyway, let's just omit it.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This way we can invoke the expected setup with
meson test --setup=valgrind
And because we don't care about valgrinding python script, mark that test as
part of the "python-tests" suite and skip it during our CI valgrind run.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Ran Benita <ran@unusedvar.com>
../meson.build:239: DEPRECATION: Library xkbcommon was passed to the "libraries"
keyword argument of a previous call to generate() method instead of first
positional argument. Adding xkbcommon to "Requires" field, but this is a
deprecated behaviour that will change in a future version of Meson. Please
report the issue if this warning cannot be avoided in your case.
This was introduced in meson 0.49.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The CI started installing some wrapper instead of a real bash which is
what gets found.
See:
https://github.com/actions/virtual-environments/pull/1081
Given meson is written in python, it should always be available
hopefully.
Disabled valgrind wrapper for now because it now also applies to the
python interpreter which leaks like a sieve.
Signed-off-by: Ran Benita <ran@unusedvar.com>
This obsoletes the print-compiled-keymap tool though we now require that the
kccgst components are passed via stdin, there is no file loading ability.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This library is the replacement for clients parsing evdev.xml directly.
Instead, they should use the API here so that in the future we may even
be able to swap evdev.xml for a more suitable data format.
The library parses through evdev.xml (using libxml2) and - if requested -
through evdev.extras.xml as well. The merge approach is optimised for
the default case where we have a system-installed rules XML and another file in
$XDG_CONFIG_DIR that adds a few entries. We load the system file first, then
append any custom ones to that. It's not possible to overwrite the MLVO list
provided by the system files - if you want to do that, get the change upstream.
XML validation is handled through the DTD itself which means we only need to
check for a nonempty name, everything else the DTD validation should complain
about.
The logging system is effectively identical to xkbcommon.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Returns true on success or false on error _or_ truncation. Since truncation is
almost always an error anyway, we might as well make this easier to check.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Move (sometimes duplicate) the required bits into new shared files
tools-common.(c|h) that are compiled into the internal tools library. Rename the
test_foo() functions to tools_foo() and in one case just copy the code of the
keymap compile function to the tool.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This is currently identical to the internal test library, but it's a start to
disentangle the two.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Most of this is currently hidden in the commit message for ca033a29d2, let's
make it a bit more public so we have a link to point users to.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Useful to have this as part of the documentation. The rendering isn't great but
at least not any worse than pure text. Markdown escapes % so explaining our use
of %S and %H would require a double % - not idea. Let's just wrap it as a code
block and done.
Includes two typo fixes too, yay.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Link libxkbcommon_x11_internal with libxkbcommon_test_internal, rather
than libxkbcommon.
This avoids some tests linking with both libxkbcommon_test_internal and
libxkbcommon, which causes duplicate symbol problems on PE targets (e.g.
Cygwin) (as all the symbols from libxkbcommon are pulled in at link
time, which clash with libxkbcommon_test_internal)
The program takes a unicode codepoint and an RMLVO and prints out all
key + modifier combinations that would result in that codepoint.
The program was written to exercise the new
xkb_keymap_key_get_mods_for_level() function. It's handy and can be
extended in several ways, but enough for now.
Example:
$ ./build/how-to-type -l us,il,ru 0x41 | column -ts $'\t'
keysym: A (0x41)
KEYCODE KEY NAME LAYOUT# LAYOUT NAME LEVEL# MODIFIERS
38 AC01 1 English (US) 2 [ Shift ]
38 AC01 1 English (US) 2 [ Lock ]
38 AC01 2 Hebrew 2 [ Shift ]
38 AC01 2 Hebrew 2 [ Lock ]
$ ./build/how-to-type -l de -v neo 0x3b6 | column -ts $'\t'
keysym: Greek_zeta (0x7e6)
KEYCODE KEY NAME LAYOUT# LAYOUT NAME LEVEL# MODIFIERS
56 AB05 1 German (Neo 2) 4 [ Shift Mod5 ]
56 AB05 1 German (Neo 2) 4 [ Shift Mod2 Mod3 Mod5 ]
56 AB05 1 German (Neo 2) 4 [ Shift Lock Mod5 ]
56 AB05 1 German (Neo 2) 4 [ Lock Mod2 Mod3 Mod5 ]
Signed-off-by: Ran Benita <ran@unusedvar.com>
We apparently broke byacc support in the switch to meson.
byacc only supports short option names. And to make things fun, bison
only supports long option for `--defines`.
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/133
Signed-off-by: Ran Benita <ran@unusedvar.com>
This is a stopgap measure to quickly get tests building with MSVC for
now, at some point the tests could be rewritten to avoid using getopt()
and mkdtemp() or to ship an implementation.
Previously we included it with an `-include` compiler directive. But
that's not portable. And it's better to be explicit anyway.
Every .c file should have `include "config.h"` first thing.
Signed-off-by: Ran Benita <ran@unusedvar.com>
Some environments (e.g. Windows + MSVC) do not provide asprintf() or
vasprintf(). This tries to detect their presence, and provides suitable
fallback implementations when not available.
Some environments (e.g. Windows + MSVC) do not provide strndup(), this
tries to detect its presence and provide a fallback implementation when
not available.
[ran: some tweaks]
The majority use-case for extending XKB on a machine is to override one or a
few keys with custom keycodes, not to define whole layouts.
Previously, we relied on the rules file to be a single file, making it hard to
extend. libxkbcommon parses $XDG_CONFIG_HOME/xkb/ but that only works as long
as there is a rule that matches the user-specified RMLVO. This works for MLV
but not for options which don't have a wildcard defined. Users have to copy
the whole rules file and then work from there - not something easy to extend
and maintain.
This patch adds a new ! include directive to rules files that allows including
another file. The file path must be without quotes and may not start with the
literal "include". Two directives are supported, %H to $HOME and %S for the
system-installed rules directory (usually /usr/share/X11/xkb/rules).
A user would typically use a custom rules file like this:
! option = symbols
custom:foo = +custom(foo)
custom:bar = +custom(baz)
! include %S/evdev
Where the above defines the two options and then includes the system-installed
evdev rule. Since most current implementations default to loading the "evdev"
ruleset, it's best to name this $XDG_CONFIG_HOME/xkb/rules/evdev, but any
valid name is allowed.
The include functionally replaces the line with the content of the included
file which means the behavior of rules files is maintained. Specifically,
custom options must be defined before including another file because the first
match usually wins. In other words, the following ruleset will not assign
my_model as one would expect:
! include %S/evdev
! model = symbols
my_model = +custom(foo)
The default evdev ruleset has wildcards for model and those match before the
my_model is hit.
The actual resolved components need only be in one of the XKB lookup
directories, e.g. for the example above:
$ cat $XDG_CONFIG_HOME/xkb/symbols/custom
partial alphanumeric_keys
xkb_symbols "foo" {
key <TLDE> { [ VoidSymbol ] };
};
partial alphanumeric_keys
xkb_symbols "baz" {
key <AB01> { [ k, K ] };
};
This can then be loaded with the XKB option "custom:foo,custom:bar".
The use of "custom" is just as an example, there are no naming requirements
beyond avoiding already-used ones. Also note the bar/baz above - the option
names don't have to match the component names.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Fix meson build on Solaris by using __EXTENSIONS__ where Linux & other
platforms use _GNU_SOURCE. Without this the build fails due to missing
prototypes for functions like strdup & getopt not defined in the C99
standard. (In autoconf, this was handled by AC_USE_SYSTEM_EXTENSIONS.)
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>