132.1. cxx-rust-cssparser-1.1.0
C++ library over Mozilla's Rust cssparser crate, for Union's style sheets
| Version | 1.1.0, release 1 |
| Shelf | kde — KDE Plasma and Gear platform pieces outside Frameworks that have no other domain: KIO workers, thumbnailers, Plasma integration, KDE Wayland glue |
| Phase | 41_system (System), 721 of 1047 in build order |
| Licence | (LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL) AND BSD-2-Clause AND MPL-2.0 AND MIT AND (MIT OR Apache-2.0) AND Zlib |
| Homepage | https://invent.kde.org/libraries/cxx-rust-cssparser |
| Build time | 1.8 SBU |
| Installed size | 2.8 MiB in 18 files |
| Recipe | ports/core/kde/cxx-rust-cssparser/kpkgbuild |
About
cxx-rust-cssparser is a C++ library over Mozilla’s cssparser and Servo’s selectors crates, the CSS tokeniser and selector matcher of Firefox’s style engine. It parses a style sheet into rules, selectors and typed property values, and hands them to C++ through a cxx bridge. Union, the Qt style engine that plasma-workspace requires, reads its style sheets with it. The library is libcxx-rust-cssparser, found with find_package(cxx-rust-cssparser); its closure holds no Qt and no graphics library, so the port is built in 41_system.
The Rust half is a static library that CMake builds through corrosion and links into the shared C++ library, so the port carries a Rust vendor bundle.
Sources
cxx-rust-cssparser-1.1.0.tar.xz(54.5 KiB)
sha256c88f883f67d132240f7ef5c8b8fe4f743a79c448b98ac88f2be3b68264840358
upstream: https://download.kde.org/stable/cxx-rust-cssparser/cxx-rust-cssparser-1.1.0.tar.xz
archive copy: sources-3/kde--cxx-rust-cssparser-1.1.0.tar.xzcxx-rust-cssparser-vendor-1.1.0.tar.xz(3.8 MiB)
sha256eb810926a49963d8c850ee4fc291405728b92064c1c2f30241eaf021f11653bd
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-3/kde--cxx-rust-cssparser-vendor-1.1.0.tar.xz
Dependencies
Depends on: cmake, ninja, extra-cmake-modules, corrosion, rust.
Required by (1): union.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install cxx-rust-cssparser'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/kde/cxx-rust-cssparser.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/kde/cxx-rust-cssparser
echo 'c88f883f67d132240f7ef5c8b8fe4f743a79c448b98ac88f2be3b68264840358 cxx-rust-cssparser-1.1.0.tar.xz' | sha256sum -c -
echo 'eb810926a49963d8c850ee4fc291405728b92064c1c2f30241eaf021f11653bd cxx-rust-cssparser-vendor-1.1.0.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/cxx-rust-cssparser
SRC=$SRC_ROOT/cxx-rust-cssparser-1.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf cxx-rust-cssparser-1.1.0.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers vendordir and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf "$PORT_SRC/$name-vendor-$version.tar.xz" -C rust
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export CARGO_NET_OFFLINE=true
cmake -S . -B build -G Ninja \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_INSTALL_LIBDIR=lib \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_TESTING=OFF \
-D BUILD_DOCS=OFF \
-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
The switches, and why each is set:
-D CMAKE_INSTALL_LIBDIR=lib— The project includesGNUInstallDirsitself and installs toCMAKE_INSTALL_LIBDIR; it reads ECM’s install directories only for its documentation, which is off.-D BUILD_DOCS=OFF— Build no QDoc documentation. Upstream’s default is on, and the build then needs Qt’sqdoc, which this port’sdependsdoes not name.-C target-feature=-crt-static— InRUSTFLAGS: build the crate for musl’s shared C library. The musl target otherwise links its C library statically, and the static library Corrosion links intolibcxx-rust-cssparser.sowould carry that choice into a library every consumer loads beside the shared one; see rust.CARGO_NET_OFFLINE=true— Keep cargo off the network. Every crate resolves from the bundle’svendor/.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/cxx-rust-cssparser, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf cxx-rust-cssparser-1.1.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/cxx-rust-cssparser, and runs the triggers its paths call for.
Contents
Installed programs: cxx-rust-cssparser-parse.
Installed libraries: libcxx-rust-cssparser.so.
Installed directories: /usr/include/cxx-rust-cssparser, /usr/lib/cmake/cxx-rust-cssparser, /usr/share/licenses/cxx-rust-cssparser.
Notes
The crate’s Cargo.toml and Cargo.lock are in rust/, not at the top of the tarball, so the recipe sets vendordir = rust and build.sh unpacks the bundle there; Corrosion runs cargo from that directory, and cargo finds the bundle’s .cargo/config.toml by walking up from it. The bundle holds the 61 crates of that lock file. The crates linked into the library bring their licences into license: cssparser, cssparser-color, dtoa-short and selectors are MPL-2.0, foldhash is Zlib, and the rest MIT or Apache-2.0; cxx-build, syn and the other build-time crates run only during the build.
The example program, cxx-rust-cssparser-parse, is built and installed whatever the switches say: it reads a CSS file and prints what the library parsed, which makes it the quickest check of the library on an installed system.