AtlatestRepositorycore-channel
core-channel / tree / src / core / packagescapture.sgl
1
;;; Screen capture.2
;;;3
;;; grim is a Wayland screenshot client. It is in this channel for two4
;;; reasons, and the second is the one worth reading.5
;;;6
;;; 1. IT IS A SECOND WAYLAND CLIENT. Everything else in the Wayland half of7
;;; this channel exists to serve foot, which makes it hard to tell whether8
;;; `wayland`, `pixman` and `wayland-protocols` are packaged correctly or9
;;; merely packaged the way foot happens to need. A second, unrelated10
;;; consumer answers that.11
;;;12
;;; 2. IT MAKES A DIFFERENTIAL TEST POSSIBLE -- AND IT MUST NOT BE MISTAKEN13
;;; FOR AN INSTRUMENT. foot's acceptance evidence is a screenshot of a14
;;; nested compositor, and that screenshot is deliberately taken with the15
;;; HOST's grim, not this one. The observer has to be independent of the16
;;; observed: a grim built from the SAME pixman and the SAME wayland-client17
;;; as foot could be wrong in a correlated way, agree with foot, and produce18
;;; a convincing green. What this package is good for is the other19
;;; direction -- run both grims on the same frame and compare. Agreement is20
;;; then evidence that the channel's Wayland and pixman stack behaves like21
;;; the host's, which is a measurement rather than a caveat.22
;;;23
;;; grim vendors the `wlr-screencopy` protocol XML it needs under `protocol/`,24
;;; so it does not drag wlroots into this channel.25
(define-library (core packages capture)26
(import (sigil core)27
(core build-environments)28
(core packages compression)29
(core packages graphics)30
(core packages wayland)31
(core packages ffi)32
(core packages build-tools)33
(core packages python)34
(sigil env package)35
(sigil build external))36
(export grim)37
(begin38
(define grim39
(package40
name: "grim"41
version: "1.4.0"42
source: (external-source43
location: "https://github.com/emersion/grim/releases/download/v1.4.0/grim-1.4.0.tar.gz"44
sha256: "b6786e889ed93568634189a59f6b6429c041bf74883c10e8b6e2ed6772ae7ffb")45
buildenv: core-buildenv46
;; zlib is reached through libpng.pc's `Requires:` chain -- see the47
;; note on `fontconfig` in (core packages fonts) for why a48
;; grand-dependency has to be named here.49
dependencies: (list libpng pixman wayland wayland-protocols libffi zlib)50
;; WAYLAND IS A DEPENDENCY ONLY, AND THE SCANNER IS POINTED AT51
;; EXPLICITLY. The obvious move -- naming `wayland` in BOTH52
;; `dependencies:` and `build-inputs:`, since grim needs the library53
;; linked and the `wayland-scanner` program run -- IS REFUSED:54
;;55
;; package: duplicate input name: wayland56
;;57
;; and there is no way round it by declaration. Only build inputs put58
;; a `bin/` on PATH, and a dependency cannot export one either, because59
;; `PATH` is builder-owned and a `search-paths:` export naming it is60
;; refused as well.61
;;62
;; foot does not hit this: it reads the scanner's absolute path out of63
;; pkg-config (`wscanner.get_variable('wayland_scanner')`). grim's64
;; `protocol/meson.build:3` does a plain65
;; `find_program('wayland-scanner')`, which searches PATH:66
;;67
;; Run-time dependency wayland-client found: YES 1.24.068
;; Program wayland-scanner found: NO69
;;70
;; The library is found and the program is not, from the same package,71
;; one line apart.72
;;73
;; The answer is meson's own mechanism for exactly this -- a native74
;; file naming the binary -- fed from `${wayland}`, which interpolates75
;; because wayland IS a declared dependency. No patch to grim, no76
;; second declaration, and the path is derived from the closure rather77
;; than searched for.78
build-inputs: (list meson samurai python)79
phases: (list80
(external-phase81
kind: 'run82
args: (list "sh" "-c"83
(string-append84
"set -eu\n"85
"cat > native.ini <<'NF'\n"86
"[binaries]\n"87
"wayland-scanner = '${wayland}/bin/wayland-scanner'\n"88
"NF\n"89
"meson setup build --native-file native.ini"90
" --prefix=${out}"91
" --buildtype=plain"92
" --default-library=static"93
;; `-Dprefer_static=true` MAKES MESON ASK94
;; PKG-CONFIG THE STATIC QUESTION, and without it95
;; a fully static link fails at the last step.96
;;97
;; A `.pc` file splits its link line: `Libs:` is98
;; what a SHARED consumer needs, `Libs.private:`99
;; and `Requires.private:` are the extra100
;; transitive libraries a STATIC consumer needs.101
;; fontconfig lists expat under102
;; `Requires.private:`, so a default103
;; `dependency('fontconfig')` emits no `-lexpat`104
;; -- correct for a shared link, fatal here:105
;;106
;; ld.lld: error: undefined symbol: XML_ErrorString107
;; >>> referenced by fcxml.c108
;; >>> fcxml.o in archive libfontconfig.a109
;;110
;; The symbol is missing from the LINK, not from111
;; the closure: expat is declared, built, and112
;; present. Only the query was the wrong one.113
;; This is the same `Requires.private:` line that114
;; had to be satisfied at CONFIGURE time; it bites115
;; twice, in two different ways, and fixing the116
;; first does not fix the second.117
" -Dprefer_static=true"118
;; JPEG output would add libjpeg for a format119
;; nothing here reads.120
;; UPSTREAM'S WARNINGS-AS-ERRORS IS TURNED OFF,121
;; and this is a compiler-set difference rather122
;; than a defect in grim. grim's meson sets123
;; `werror=true`, and this toolchain's clang124
;; warns where the author's compiler did not:125
;;126
;; ../write_ppm.c:32:23: error: unused variable127
;; 'format' [-Werror,-Wunused-variable]128
;;129
;; The variable really is unused, in a PPM writer130
;; nothing in this channel calls. Distributions131
;; disable `werror` for exactly this reason: a132
;; project's warning policy is calibrated to the133
;; compilers its authors use, and turning a134
;; foreign compiler's extra warnings into build135
;; failures makes the package unbuildable for136
;; reasons unrelated to correctness.137
;;138
;; NOTE THAT FOOT DOES NOT NEED THIS. foot also139
;; sets `werror=true` and compiles clean under140
;; the same clang, so this is not a blanket141
;; concession -- it is one package's warning.142
" -Dwerror=false"143
" -Djpeg=disabled"144
;; man pages want scdoc.145
" -Dman-pages=disabled\n"146
"echo GRIM-CONFIGURED\n")))147
(external-phase148
kind: 'run149
args: (list "sh" "-c"150
(string-append151
"set -eu\n"152
"meson compile -C build\n"153
"echo GRIM-COMPILED\n")))154
(external-phase155
kind: 'run156
args: (list "sh" "-c"157
(string-append158
"set -eu\n"159
"d=\"$(dirname \"$PWD\")/install-root\"\n"160
"DESTDIR=\"$d\" meson install -C build --no-rebuild\n"161
"test -x \"$d${out}/bin/grim\"\n"162
"echo GRIM-INSTALLED\n"))))))))