AtlatestRepositorycore-channel
core-channel / tree / src / core / packagesdatastructures.sgl
1
;;; Generic data-structure libraries.2
;;;3
;;; tllist is a header-only typed linked list. It is in this channel because4
;;; fcft and foot both `dependency('tllist')`, and foot's fallback for it is a5
;;; `[wrap-git]` subproject pointing at a live git URL -- which cannot resolve6
;;; inside a build sandbox, so a real package is not optional.7
(define-library (core packages datastructures)8
(import (sigil core)9
(core build-environments)10
(sigil env package)11
(sigil build external))12
(export tllist)13
(begin14
;; TLLIST IS HEADER-ONLY AND IS STILL DECLARED AS A `dependencies:` ENTRY15
;; BY ITS CONSUMERS, WHICH PUTS A BUILD-TIME-ONLY LIBRARY IN THEIR RUNTIME16
;; CLOSURE. That is not sloppiness; the channel has no other category for17
;; it, and the reason is worth knowing before someone "fixes" it.18
;;19
;; `build-inputs:` contributes the input's `bin/` to PATH and nothing else20
;; -- no `-I`, no `-L`, no `PKG_CONFIG_PATH`. It can additionally carry a21
;; package's own `search-paths:` exports, so a header-only library CAN22
;; reach a build as a build input by exporting `CPATH`.23
;;24
;; What it cannot do is be found by PKG-CONFIG. `PKG_CONFIG_PATH` is25
;; composed by the builder from DEPENDENCIES only, and it is builder-owned,26
;; so a package may not export it -- that is refused by name. fcft and27
;; foot both locate this library with `dependency('tllist')`, which is a28
;; pkg-config lookup, so it has to be a dependency.29
;;30
;; So: THERE IS NO "BUILD-TIME LIBRARY" CATEGORY HERE. A package that is31
;; discovered through pkg-config is a runtime dependency by construction,32
;; whether or not anything of it survives into the binary. For a33
;; header-only library nothing does.35
;; INSTALLED BY HAND RATHER THAN BY MESON, DELIBERATELY.36
;;37
;; tllist is one header and a `.pc` file. Its meson.build does exactly38
;; two things when it is not a subproject: `install_headers('tllist.h')`39
;; and `pkg.generate(...)`. Running a full meson configure to copy one40
;; header would put meson, samurai and python on the critical path of a41
;; package that needs none of them -- and this package was written before42
;; meson had been proven in this channel at all, which is the actual43
;; reason: it removes a dependency from the ordering, not just from the44
;; build.45
;;46
;; The `.pc` is hand-written to match what meson's pkgconfig module would47
;; have emitted. NOTE THE ABSENCE OF `${prefix}`-STYLE VARIABLES: a48
;; pkg-config file would normally define `prefix=` and refer to it, but49
;; `${...}` inside a run-phase argument is intercepted by SIGIL's50
;; interpolation, not by the shell or by pkg-config, and any name that is51
;; not `out` or a declared input is an error at evaluation time. Absolute52
;; paths are what the rest of this channel bakes anyway.53
(define tllist54
(package55
name: "tllist"56
version: "1.1.0"57
source: (external-source58
location: "https://codeberg.org/dnkl/tllist/releases/download/1.1.0/tllist-1.1.0.tar.gz"59
sha256: "a1f0ce0dc4fcb4ce59c37202a1d914c853a8bd2d7c5d57d623b15a8dd9778767")60
buildenv: core-buildenv61
phases: (list62
(external-phase63
kind: 'run64
args: (list "sh" "-c"65
(string-append66
"set -eu\n"67
"d=\"$(dirname \"$PWD\")/install-root\"\n"68
"mkdir -p \"$d${out}/include\" \"$d${out}/lib/pkgconfig\"\n"69
;; `install -m` rather than `cp`, so the installed mode is a70
;; function of the derivation and not of the71
;; ambient umask.72
"install -m 644 tllist.h \"$d${out}/include/tllist.h\"\n"73
"cat > \"$d${out}/lib/pkgconfig/tllist.pc\" <<'PC'\n"74
"Name: tllist\n"75
"Description: A C header file only implementation of a typed linked list\n"76
"Version: 1.1.0\n"77
"Cflags: -I${out}/include\n"78
"PC\n"79
;; Prove the artifact rather than trust the copy:80
;; the header must be there AND pkg-config must81
;; be able to answer a query about it, which is82
;; what every consumer will actually do.83
"test -f \"$d${out}/include/tllist.h\"\n"84
"PKG_CONFIG_PATH=\"$d${out}/lib/pkgconfig\" pkg-config --exists tllist\n"85
"PKG_CONFIG_PATH=\"$d${out}/lib/pkgconfig\" pkg-config --modversion tllist\n"86
"echo TLLIST-INSTALLED\n"))))))))