42.8. swig-4.5.1
Generate scripting interfaces to C/C++ code
| Version | 4.5.1, release 1 |
| Shelf | toolchain — The native compilers, the linker, the C library, and the LLVM family |
| Phase | 30_foundation (Build Foundation), 87 of 127 in build order |
| Licence | GPL-3.0-or-later AND BSD-3-Clause |
| Homepage | https://www.swig.org/ |
| Build time | 0.5 SBU |
| Installed size | 5.2 MiB in 845 files |
| Recipe | ports/core/toolchain/swig/kpkgbuild |
About
SWIG reads C and C++ headers, with an interface file saying what to expose, and writes the glue code that lets a scripting language call that library. In KDOS it is a build tool only: the ports that ship Python or other language bindings generated by SWIG name it in depends: gdal, lldb, kicad, freecad and its pivy and ifcopenshell, gnucash, obs-studio, kodi and libcec.
Sources
swig-4.5.1.tar.gz(8.8 MiB)
sha2567fec50b27deddab5455a9633780b6341eddfb96215a7619e93a76eb27178f653
upstream: https://downloads.sourceforge.net/swig/swig-4.5.1.tar.gz
archive copy: sources-4/toolchain--swig-4.5.1.tar.gz
Dependencies
Depends on: pcre2.
Required by (10): freecad, gdal, gnucash, ifcopenshell, kicad, kodi, libcec, lldb, obs-studio, pivy.
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/30_foundation/phase.env && kpkg install swig'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/toolchain/swig.
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/toolchain/swig
echo '7fec50b27deddab5455a9633780b6341eddfb96215a7619e93a76eb27178f653 swig-4.5.1.tar.gz' | 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/swig
SRC=$SRC_ROOT/swig-4.5.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf swig-4.5.1.tar.gz -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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
./configure \
--prefix=/usr \
--without-maximum-compile-warnings \
--with-pcre
make
make DESTDIR=$PKG install
The switches, and why each is set:
--without-maximum-compile-warnings— SWIG’sconfigureadds-Wall -W -pedanticto the flags it compiles SWIG itself with unless this is given. It changes only the warnings printed while SWIG is compiled, not the code built.--with-pcre— build SWIG with PCRE2. This is upstream’s default too, and with itconfigurestops if it cannot findpcre2-config, rather than building a smaller SWIG. PCRE2 is what theregex:form of%renameuses to apply a Perl-style substitution to identifiers; a SWIG built without it stops on any interface file that uses that form, with “PCRE regex support not enabled in this SWIG build”.
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/swig, 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 swig-4.5.1-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/swig, and runs the triggers its paths call for.
Contents
Installed programs: ccache-swig, swig.
Installed directories: /usr/share/licenses/swig, /usr/share/swig.