Generate X11 constants from headers at build-time.

The X11 constants are different between versions.

For example, Debian doesn't have XF86XK_WWAN
https://salsa.debian.org/xorg-team/proto/x11proto-core/blob/debian-unstable/XF86keysym.h

But Arch Linux does.
https://www.archlinux.org/packages/extra/any/xorgproto/

I've got following error on Debian stretch

```
 /home/sei/src/github.com/k0kubun/xremap/src/x11_constants.c:2710:20: error: ‘XF86XK_WWAN’ undeclared (first use in this function)
    define_x11_const(XF86XK_WWAN);
```

To avoid macro undeclared error, wrap the `define_x11_const` with #ifdef

```
#ifdef XF86XK_WWAN
define_x11_const(XF86XK_WWAN)
#endif
```

Or generate code at build-time.
pull/31/head
Seiei Miyagi 6 years ago
parent c7a69cadcd
commit 6ceda05568
No known key found for this signature in database
GPG Key ID: CECD34C119139FA8

2
.gitignore vendored

@ -2,3 +2,5 @@
/mruby
tags
TAGS
src/x11_constants.inc
src/x11_constants_XF86.inc

@ -22,5 +22,11 @@ mruby:
git clone https://github.com/mruby/mruby
git -C mruby reset --hard $(REVISION)
mruby/build/host/bin/xremap: mruby build_config.rb $(CSRCS) $(MRBSRCS) $(MRBCSRCS)
src/x11_constants.inc:
cat /usr/include/X11/keysymdef.h | ruby -e 'puts STDIN.read.split("\n").select {|l| l.match(/\A(#define XK_|#ifdef|#endif)/) }.map{|l| l.match(/\A#define XK_/) ? %Q[ define_x11_const(#{l.split(" ")[1]});] : l }.join("\n")' > src/x11_constants.inc
src/x11_constants_XF86.inc:
cat /usr/include/X11/X.h | ruby -e 'puts STDIN.read.split("\n").select {|l| l.start_with?("#")}[2..-2].map{|l| l.start_with?("#define") ? %Q[ define_x11_const(#{l.split(" ")[1]});] : l}' > src/x11_constants_XF86.inc
mruby/build/host/bin/xremap: mruby build_config.rb src/x11_constants.inc src/x11_constants_XF86.inc $(CSRCS) $(MRBSRCS) $(MRBCSRCS)
cd mruby && MRUBY_CONFIG="$(current_dir)/build_config.rb" make

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save