Bundle resources alongside a built executable (:bundle) #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
stift buildproduces an executable (viaasdf:make→program-op), but arunnable program usually needs non-Lisp files beside it: shared libraries the
binding layer loads (e.g. a Windows
freetype.dll), fonts, data files,shaders, licence texts — arbitrarily many things. Today stift copies none of
them, so producing a working, shippable artifact needs an out-of-band step.
stift already knows each build-list project's pinned,
verify-able checkout,so it is well placed to copy declared files out of those trees and lay them out
beside the build output — reproducibly, with provenance.
This should be a general "lay these files out beside the artifact"
mechanism, not a native-library feature. A bundled DLL is just the special case
whose destination is the executable's own directory.
Proposal: a
:bundlekey in the stiftfileA project declares files it carries that should ship beside an executable built
from it — or from anything that requires it:
Each entry is
(SOURCE &key to when):declaring project's root. Copied from the pinned tree (cache /
vendor//workspace member), preserving file modes.
:to— destination relative to the built executable's directory,cp/install-like: trailing slash = copy into that directory keeping thebasename; no slash = exact path (rename); omitted = basename at the root (so a
bare DLL lands beside the exe). A directory source places its contents at the
destination.
:when— optional condition, tested against the build host, in cl-ffi'sclause vocabulary:
:windows,:linux,:darwin,:unix, and(:or …),(:and …),(:not …). Kept to OS/arch keywords so stift can evaluate ititself without consulting the build Lisp.
The anchor is the directory of the primary build output, so this works for
program-opandimage-opalike, and is orthogonal to--compressandSBCL-vs-CCL.
Composition
:bundlecomposes up the build list like:require(and unlike:replace/:exclude, which are main-project-only): a library that needs aresource shipped declares it, and it propagates to any artifact built from
something that uses it. Entries are inert data; sources come only from pinned,
verify-able trees; stift copies plain files, no eval.Collisions
When two projects target the same destination (two
freetype.dlls at the root,two
fonts/Inter.ttf), stift stops and names both contributors, as it alreadydoes for system collisions. No automatic per-project namespacing — it would
produce paths the program can't predict. A main-project override to resolve a
collision is a possible later refinement.
When it runs
stift buildbundles by default — the point is a runnable artifact, and onWindows the exe won't start without its DLLs beside it.
--no-bundleproducesthe bare binary. A separate
stift bundle(assemble/refresh without rebuilding)is a possible addition, not needed first.
Boundary: runtime discovery is the program's job
stift guarantees a known directory layout beside the artifact and nothing more.
Finding the files at runtime is the program's concern: for shared libraries it
is the OS loader plus a by-name fallback in the binding; for everything else the
program computes paths from its own executable location (
uiop:argv0/ itstruename's directory). stift never learns what a bundled file is for.
Application-level policy — third-party notice assembly, resource lookup — layers
on top.
Open question: the rebuild record
stift buildwrites its outputs anew each time, so bundling must remove files aprevious build bundled but the current one does not (as
stift vendorremovescopies of projects that left the list). That needs stift to remember what it
placed. The same record would give
verify-style provenance and let a programenumerate bundled resources. Placement is undecided:
enumeration, but ships a stift metadata file in the distributable;
output directory is moved.
Notes
stift build's public behaviour.