AtlatestRepositorycore-channel

core-channel / tree / src / core / packagesinput.sgl

1;;; Keyboard handling.
2;;;
3;;; libxkbcommon compiles XKB keymaps and turns key codes into keysyms and
4;;; UTF-8. A Wayland client needs it because the compositor hands over its
5;;; keymap as an XKB TEXT description over a file descriptor and each client
6;;; compiles that itself.
7;;;
8;;; THAT IS ALSO WHY `xkeyboard-config` IS NOT IN THIS CHANNEL. The keymap
9;;; DATABASE -- rules, symbols, geometry -- is what an X server or a
10;;; compositor reads to BUILD a keymap. A Wayland client is handed the
11;;; finished text and never opens the database, so `xkb-config-root` is left
12;;; at its default and nothing resolves it at runtime. Worth stating because
13;;; the default points at a path that does not exist here, and a reader who
14;;; assumes it is load-bearing will go looking for a missing package.
15(define-library (core packages input)
16 (import (sigil core)
17 (core build-environments)
18 (core packages build-tools)
19 (core packages python)
20 (sigil env package)
21 (sigil build external))
22 (export libxkbcommon)
23 (begin
24 ;; VERSION 1.7.0, AND IT IS CHOSEN RATHER THAN INHERITED.
25 ;;
26 ;; Two reasons, and they point the same way:
27 ;;
28 ;; PROVENANCE. `xkbcommon.org/download/` stops at 1.7.0 -- every later
29 ;; version 404s there -- and GitHub publishes no release asset for this
30 ;; project, only auto-generated source archives. Those archives are not
31 ;; release artifacts: their bytes can be regenerated and have changed
32 ;; under people before. 1.7.0 is the newest version with a real upstream
33 ;; dist tarball.
34 ;;
35 ;; COST. 1.7.0's meson.build:157 makes bison `required: false` and falls
36 ;; back to `find_program('byacc')`. 1.13.2 requires `bison >= 3.6`
37 ;; outright, and bison needs GNU m4 to build -- so the newer version
38 ;; would have added TWO packages to this channel, in exchange for weaker
39 ;; provenance.
40 ;;
41 ;; foot asks only for `xkbcommon >= 1.0.0`, so 1.7.0 is comfortably inside
42 ;; what it needs. If a future consumer wants a newer one, that is a scoped
43 ;; upgrade with an upstream-tarball question attached, not a reason to put
44 ;; a synthetic archive on this path.
45 ;;
46 ;; The byacc fallback is why `core/byacc` installs itself under BOTH names:
47 ;; the fallback looks for a program called `byacc`, and byacc's own
48 ;; makefile installs only `yacc`. See the note there.
49 (define libxkbcommon
50 (package
51 name: "libxkbcommon"
52 version: "1.7.0"
53 source: (external-source
54 location: "https://xkbcommon.org/download/libxkbcommon-1.7.0.tar.xz"
55 sha256: "65782f0a10a4b455af9c6baab7040e2f537520caa2ec2092805cdfd36863b247")
56 buildenv: core-buildenv
57 build-inputs: (list meson samurai python byacc)
58 phases: (list
59 (external-phase
60 kind: 'run
61 args: (list "sh" "-c"
62 (string-append
63 "set -eu\n"
64 "meson setup build"
65 " --prefix=${out}"
66 " --buildtype=plain"
67 " --default-library=static"
68 ;; X11 support would want libxcb; the registry
69 ;; and the tools would want more still. foot is
70 ;; a Wayland client and links only the core
71 ;; library.
72 " -Denable-x11=false"
73 " -Denable-xkbregistry=false"
74 " -Denable-wayland=false"
75 " -Denable-tools=false"
76 " -Denable-docs=false"
77 " -Denable-bash-completion=false\n"
78 "echo XKBCOMMON-CONFIGURED\n")))
79 (external-phase
80 kind: 'run
81 args: (list "sh" "-c"
82 (string-append
83 "set -eu\n"
84 ;; Prove the yacc fallback actually ran, rather
85 ;; than assuming it: the parser is GENERATED, and
86 ;; a byacc without backtracking dies on this
87 ;; grammar's `%destructor`.
88 ;;
89 ;; SEARCHED RATHER THAN NAMED, because the first
90 ;; version of this check asserted
91 ;; `build/src/xkbcomp/parser.c` -- a path I had
92 ;; guessed. meson actually emits it into
93 ;; per-target directories
94 ;; (`build/libxkbcommon.a.p/parser.c`), so the
95 ;; check failed on a build where all 121 targets
96 ;; had linked successfully. A gate that names a
97 ;; path it has not observed is asserting its
98 ;; author's expectations, not the product.
99 "meson compile -C build\n"
100 "n=$(find build -name parser.c | wc -l)\n"
101 "echo \"XKBCOMMON-GENERATED-PARSERS=$n\"\n"
102 "test \"$n\" -ge 1\n"
103 "echo XKBCOMMON-PARSER-GENERATED\n")))
104 (external-phase
105 kind: 'run
106 args: (list "sh" "-c"
107 (string-append
108 "set -eu\n"
109 "d=\"$(dirname \"$PWD\")/install-root\"\n"
110 "DESTDIR=\"$d\" meson install -C build --no-rebuild\n"
111 "test -f \"$d${out}/lib/pkgconfig/xkbcommon.pc\"\n"
112 "echo XKBCOMMON-INSTALLED\n"))))))))