Binary Aliens: Shipping Tools, Not Just Libraries #7
sanko
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Perl's Alien ecosystem has always been synonymous with one thing: fine grained access to shared libraries. You write an Alien module so that
FFI::Platypuscan callzlibVersion(), or so thatInline::Ccan link againstlibpng. The package metadata is full ofcflags,libs, andlinkdirs. Any tools you might need to build the libs will need their own Aliens which may be unmaintained or maybe not even exist.What we really need is an Alien that can automatically provide tools:
ninjato drive a build,cmaketo configure one,pythonto run a code generator,meson,go,rust,node... Until now, a Perl distribution that depended on a tool had to either require the system administrator to install it or write a fragileAlientoolchain recipe.Alien::Xrepofixes this by treating binaries and libraries as first-class citizens of the same package store. Installlibpngandninjain the same line; run them both from Perl.What is a "binary" package?
When you ask xrepo to install
ninja, the registry hands you a package with akindofbinaryrather thanlibrary. It has no header files, no shared object, no-lflags. Instead it ships executables — and Alien::Xrepo knows exactly where they live:The key difference from a library package is that
bin_dirpoints to abin/directory full of executables, not alib/directory full of.dll/.sofiles.Running a binary tool
There are two common patterns for calling an installed tool from Perl.
Option A: run it directly
Resolve the exact executable name (
.exeon Windows, bare name on Unix) insidebin_dir:Option B: put
bin_dironPATHPrepend
bin_dirtoPATHso that everysystemcall in this process (and every child it spawns) finds the tool:Option B is especially useful when a build tool (like
meson) invokes another tool (likeninja) as a subprocess.Libraries and binaries in the same store
You are free to install a library and a tool side by side — they share the same package store:
There is no conflict:
libpnglives underlib/andinclude/, whileninjalives underbin/. Both report theirkindcorrectly so you can branch on it in your code:A practical example: build a C project against an installed library
If you are building a small C program and want to link it against
libpngwhile driving the build withninja, you can fetch the compiler flags from one and the build tool from the other:No system-level
apt installorbrew installrequired — everything is resolved by Perl at runtime.When is this useful?
Build.PLorMakefile.PLcan pullmesonandninjaautomatically, so a user doesn't need them on the system PATH.ninjaorcmakeversion in acpanfile(requires 'ninja', '1.13';) ensures every CI runner uses the same build infrastructure.pythonornodeto run a code-generation step without depending on the system interpreter being the right version.Binary packages close the last mile: Perl now controls both what it links against and what drives the build.
All reactions