AtlatestRepositorycore-channel

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

1;;; Asynchronous event notification.
2;;;
3;;; libevent lands in its own module rather than beside ncurses in
4;;; (core packages terminal), even though tmux is the only thing in the channel
5;;; that wants it today. Two reasons, and the second is the one that matters:
6;;;
7;;; * it follows the channel's existing shape. compression/, databases/,
8;;; parsing/ and xml/ are each a single-package module named for a DOMAIN,
9;;; not for a consumer. libevent's domain is event loops, not terminals.
10;;;
11;;; * filing it under `terminal` would encode "libevent exists to serve tmux"
12;;; in the module layout, and the next consumer of libevent will not be a
13;;; terminal program. That is the same mistake in a different place as the
14;;; builder hardcoding `include/ncursesw` for every package -- one
15;;; consumer's situation written down somewhere general.
16(define-library (core packages event)
17 (import (sigil core)
18 (core build-environments)
19 (sigil env package)
20 (sigil build external))
21 (export libevent)
22 (begin
23 ;; NO `search-paths:` DECLARATION, and that is an answered question rather
24 ;; than an omission. ncurses needs one because `--enable-widec` puts every
25 ;; header under `include/ncursesw/` and leaves `include/` empty, so the
26 ;; builder's own `-I<dep>/include` reaches nothing. libevent installs
27 ;; `event.h`, `evutil.h` and friends directly in `include/`, with the
28 ;; modern API under `include/event2/` -- and `#include <event2/event.h>`,
29 ;; which is what tmux compiles, resolves relative to `include/`. The
30 ;; builder's own flag is therefore sufficient; measured on the built store
31 ;; item, see the task note.
32 ;;
33 ;; The `.pc` files matter more than the headers here: tmux finds libevent
34 ;; through PKG_CHECK_MODULES, and the builder puts every dependency's
35 ;; `lib/pkgconfig` on PKG_CONFIG_PATH already. Measured on the installed
36 ;; item, THREE of the four generated files carry an empty `Requires:`
37 ;; (`libevent_pthreads.pc` has `Requires: libevent`) and all four carry an
38 ;; empty `Conflicts:`. That empty-dependency-list shape is what makes
39 ;; pkgconf read past the start of its buffer and abort with SIGABRT under
40 ;; Zig's runtime safety.
41 ;;
42 ;; IT IS NOT A VERSION PROBLEM AND MUST NOT BE RECORDED AS ONE. The seed's
43 ;; own build script measured the identical defective line in pkgconf 1.9.5
44 ;; (parser.c:88) and 2.4.3 (parser.c:95) and states plainly that no pkgconf
45 ;; release fixes it -- a version bump is not a fix. What makes the seed's
46 ;; pkgconf safe is a SOURCE PATCH the seed applies itself, plus two
47 ;; refusals guarding it; see seed/scripts/build-seed.sh. Naming "2.4.3" as
48 ;; the reason would invite exactly the wrong repair later.
49 ;;
50 ;; Verified against the seed's own binary on all four files this package
51 ;; installs: `--exists`, `--cflags --libs` and `--static` all exit 0, with
52 ;; an absent-package negative control still exiting 1.
53 (define libevent
54 (package
55 name: "libevent"
56 version: "2.1.13-stable"
57 source: (external-source
58 location: "https://github.com/libevent/libevent/releases/download/release-2.1.13-stable/libevent-2.1.13-stable.tar.gz"
59 sha256: "f7e9383b8c0baa81b687e5b5eecc01beefaf1b19b64151d95ed61647fe7a315c")
60 buildenv: core-buildenv
61 phases: (list
62 (external-phase
63 kind: 'configure
64 args: (list "--prefix=${out}"
65 ;; static only, consistent with the channel
66 "--disable-shared"
67 "--enable-static"
68 ;; openssl is not in the channel
69 "--disable-openssl"
70 ;; nothing here is installed, and both build
71 ;; test programs we would only throw away
72 "--disable-samples"
73 "--disable-libevent-regress"
74 "--disable-doxygen-html"))
75 (external-phase kind: 'make)
76 (external-phase kind: 'install))))))