Commit Graph

59 Commits (f0b1441f5e595ffdef553b8c40a8be0850f57b60)

Author SHA1 Message Date
Peter Hutterer 2a83430572 meson.build: fix pkgconfig deprecation warning
../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>
2020-07-23 09:28:23 +03:00
Ran Benita fa300b24d2 test: fix Windows CI by rewriting symbols-leak-test from bash to python
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>
2020-07-22 13:45:17 +03:00
Peter Hutterer fc2d4fa2ab tools: add ability to compile from kccgst to rmlvo-to-keymap
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>
2020-07-08 15:21:19 +10:00
Peter Hutterer fd39147175 tools: add ability to print the KcCGST components for rmlvo-to-keymap
This makes the rmlvo-to-kccgst tool obsolete.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-08 15:21:19 +10:00
Peter Hutterer e55587f4cf meson.build: always set the default variants/options
Make this more balanced with the rules/layouts so we can rely on that #define to
exist.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-08 15:21:19 +10:00
Peter Hutterer afb26e7df9 Add libxkbregistry to query available RMLVO
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>
2020-07-06 15:15:20 +10:00
Peter Hutterer 9b1b0c5743 Add a snprintf_safe() helper function
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>
2020-07-06 15:15:20 +10:00
Peter Hutterer 362130debb meson.build: prefix all tools with xkbcommon-
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 3adbe54eac tools: move the remaining tools from test to here
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer f525f9f040 test: disentangle interactive-wayland from the test headers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 1326d5add4 test: untangle interactive-x11 from the test headers
Use the new tools headers and create a custom internal lib for the x11 tool.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer c09bf36306 test: untangle interactive-evdev from the test headers
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>
2020-06-25 10:32:08 +10:00
Peter Hutterer 6c629a10cf Use a custom internal library for the tools
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>
2020-06-25 10:32:08 +10:00
Peter Hutterer ec2bbe599c Move the various tools to a tools/ directory
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 5fb2c6769b doc: add documentation for user configuration
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>
2020-06-15 07:32:10 +03:00
Peter Hutterer a26578742c doc: add the rules-format file (as markdown)
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>
2020-06-15 07:32:10 +03:00
Jon Turney 908e014f01 Fix building X11 tests on PE targets
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)
2020-04-18 22:15:51 +03:00
Ran Benita 188a1c79f1 test: add "how to type" demo program
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>
2020-03-20 19:40:14 +02:00
Ran Benita 1b23a650ab build: fix build with byacc
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>
2020-02-18 14:12:20 +02:00
Ran Benita e3c3420a71 Bump version to 0.10.0
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-01-18 23:08:45 +02:00
Adrian Perez de Castro f09ae987bf build: Skip building some tests on MSVC for now
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.
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro 578aeac6b2 build: add some defines for MSVC to allow it to be unixy
[ran: combined some commits]
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro d59ff39d22 meson.build: Take win_bison as a possible variant for Bison
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 13:21:34 +02:00
Ran Benita 40aab05e77 build: include config.h manually
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>
2019-12-27 13:09:11 +02:00
Adrian Perez de Castro bdff8ebe3c Provide a fallback implementation of [v]asprintf()
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.
2019-12-27 12:45:34 +02:00
Adrian Perez de Castro 93a13050d6 Provide a fallback implementation of strndup()
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]
2019-12-27 12:45:14 +02:00
Peter Hutterer ca033a29d2 rules: add include statements to rules files
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>
2019-12-24 09:50:03 +02:00
Ran Benita 068e38edca meson: remove redundant malloc scribbling
Turns out meson already sets this (at least MALLOC_PERTURB) on its own
for the `test` target.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-14 13:48:10 +02:00
Ran Benita 6d83838cc2 Bump version to 0.9.1
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-10-20 23:07:52 +03:00
Ran Benita a88a0710f9 Bump version to 0.9.0
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-10-19 00:41:36 +03:00
Alan Coopersmith 934d574172 build: Solaris needs __EXTENSIONS__ instead of _GNU_SOURCE
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>
2019-09-11 20:30:37 +03:00
Ran Benita 97f41fe4ac test/symbols-leak-test: make it work with macOS diff
The <() stuff fails with an error:
    diff: extra operand `/dev/fd/61'

Signed-off-by: Ran Benita <ran234@gmail.com>
2019-07-25 13:24:00 +03:00
Daniel Stone 909cc04d2c interactive-wayland: Port to stable xdg-shell (#100)
xdg_shell v6 was pretty close to the finalised stable version of
xdg-shell. We can now just use the stable version, which is supported
everywhere (Enlightenment, KWin, Mutter, Weston, wlroots).

This requires bumping the wayland-protocols dependency.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-07-02 15:48:32 +03:00
Michael Forney 9d58bbd4ff Use bitwise test instead of popcount to check if one bit is set
We don't need to determine the total number of bits set to determine if
exactly one is set.

Additionally, on x86_64 without any -march=* flag, __builtin_popcount
will get compiled to a function call to the compiler runtime (on gcc),
or a long sequence of bit operations (on clang).

Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-10 11:15:55 -07:00
maxice8 9badb4e4a2 meson.build: use program from build machine not host or target.
We can't always execute binaries from the host or target machine,
as is the case in cross compilation.

closes #89
2019-02-23 09:04:36 +00:00
Ran Benita d40b368b2f Bump version to 0.8.4
Signed-off-by: Ran Benita <ran234@gmail.com>
2019-02-22 22:26:49 +02:00
Peter Hutterer 3f5095339f meson.build: link the sources directly into libxkbcommon-x11
Similar to 75ce741ab9, just for the -x11
sublibrary.

This works around meson bug 3937, 'link_whole' arguments don't get added into
the final static library and we end up with a virtually empty 8-byte
libxkbcommon-x11.a file, see https://github.com/mesonbuild/meson/issues/3937

The internal lib is still built for the one test case that requires it.

Fixes #86

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-11 11:35:34 +02:00
Ran Benita 9f93ebcf2b Bump version to 0.8.3
Signed-off-by: Ran Benita <ran234@gmail.com>
2019-02-08 12:39:01 +02:00
Ran Benita caddfdb0ad meson: make comment make sense now
Signed-off-by: Ran Benita <ran234@gmail.com>
2019-02-08 12:29:27 +02:00
Peter Hutterer 75ce741ab9 meson.build: manually link all sources into the library
This works around meson bug 3937, 'link_whole' arguments don't get added into
the final static library and we end up with a virtually empty 8-byte
libxkbcommon.a file, see https://github.com/mesonbuild/meson/issues/3937

Workaround is simply to add all sources to both libraries we need them in.
This obviously compiles them twice but this year's winter was cold and
bit of extra warmth will be appreciated.

Fixes #84

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-08 12:21:28 +10:00
Ran Benita 87b0765fde
Merge pull request #68 from whot/wip/xkeyboard-config-tester
xkeyboard-config combination tester
2018-08-21 09:05:09 +03:00
Peter Hutterer d1cb8ad409 test: add a tool to test-compile all LVO combinations from xkeyboard-config
This test contains of two parts:
- a simple program to convert RMLVO commandline arguments into a keymap (and
  print that keymap if requested).
- a python script that runs through rules/evdev.xml, and tries to compile a
  keymap for sort-of every layout/variant/option combination. Sort-of, because
  we can have multiple options and it really only does one per layout(variant)
  combination.

Same thing can be done using xkbcomp, but right now it doesn't take that as
argument, it's hard-coded.

This takes quite a while, installing python-tqdm is recommended to see fancy
progress bars instead of just miles of dumps.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-21 11:30:45 +10:00
Ran Benita d7891d0913 build: turn off strict aliasing
The benchmarks don't show any effect, so turn it off to have one less
thing to worry about. The parser does a lot of casting between AST
nodes.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-08-18 15:12:57 +03:00
Ran Benita a9ace75f64 x11: fix undefined behavior when copying the coordinates of ptr movements actions
Left shift of a negative integer. For some reason the protocol
representation here got really botched (in the spec it is just a nice
and simple INT16).

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-08-18 14:58:03 +03:00
Ran Benita f8134c8503 Bump version to 0.8.2
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-08-05 08:55:39 +03:00
Ran Benita 87046f56ef Bump version to 0.8.1
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-08-03 13:55:52 +03:00
Ran Benita 2cb5c2a3f3 Add fuzzing infrastructure
Though text formats aren't exactly fuzzer's strong suit, fuzzers can
catch many surface-level bugs.

The fuzz/ directory contains target programs, testcases and dictionaries
to drive the afl fuzzer.

This commit adds a fuzzer for the XKB keymap text format and the Compose
text format. On my slow machine, using a single core, a full cycle of
the XKB fuzzer takes 5 hours. For Compose, it takes a few minutes.

Fuzzing for the other file formats (rules files mostly) will be added
later.

To do some fuzzing, run `./fuzz/fuzz.sh`.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-30 10:35:10 +03:00
Jan Alexander Steffens (heftig) 83a553a009 meson: Fix xkbcommon-x11.pc Requires versioning
Old meson expects an array with one dependency per element. Providing a
string containing multiple deps results in only the first dep getting
its whitespace properly applied. As a result, the output was:

    Requires.private: xcb >= 1.10 xcb-xkb>=1.10

And downstream projects failed to find a package named 'xcb-xkb>=1.10'.

Specifying an array of versioned deps results in correct output:

    Requires.private: xcb >= 1.10, xcb-xkb >= 1.10

Fixes #64.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
2018-07-17 17:31:55 +02:00
Jan Alexander Steffens (heftig) a3c907d389 meson: Fix xkbcommon-x11.pc Requires
The meson-generated pkgconfig file was missing Requires and
Requires.private.

[ran: adjust for older Meson versions.]

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-17 09:30:43 +03:00
Ran Benita c8e17eede5 bench: simplify the bench helpers
Trim the API a bit.

Also, just always use gettimeofday(), which is portable. Hopefully the
system clock doesn't change while a benchmark is running.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-05 18:29:39 +03:00