jolt build: bundle native libs + resources into standalone binaries
A built binary dropped its deps.edn :jolt/native declarations and its
resource roots, so an FFI+resources app (ring-app) failed at runtime:
sockets/sqlite gave 'no entry for socket' and io/resource returned nil.
The buildsmoke fixture is pure compute, so neither path was exercised.
The launcher now loads required + :process native libs before the app's
top-level forms (a library's defcfn resolves its foreign-procedure symbols
at top-level eval during startup, so the libs must be loaded first);
optional libs load in the scheme-start launcher, where a missing lib is
caught rather than aborting the heap build.
deps.edn :jolt/build {:embed [dirs]} bakes those dirs' files into the heap
(register-embedded-resource! at heap build), so io/resource serves them with
no files on disk. Non-embedded resources resolve at runtime against JOLT_PWD,
and io/file reads (e.g. config.edn) stay external.
build-binary now takes the encoded natives, embed dirs, and project paths
from cmd-build; deps/resolve-project surfaces them. Buildsmoke fixture grows
an embedded resource + a :process native to cover both paths.
This commit is contained in:
parent
22c08d30f2
commit
1d345bfd0f
10 changed files with 227 additions and 36 deletions
|
|
@ -1 +1,8 @@
|
|||
{:paths ["src"]}
|
||||
{:paths ["src" "resources"]
|
||||
|
||||
;; exercise the build's native-lib loading: a :process spec loads the running
|
||||
;; binary's own symbols (libc) at startup — no external file, always succeeds.
|
||||
:jolt/native [{:name "libc" :process true}]
|
||||
|
||||
;; bake resources/ into the binary so io/resource resolves with no file on disk.
|
||||
:jolt/build {:embed ["resources"]}}
|
||||
|
|
|
|||
1
test/chez/build-app/resources/greeting.txt
Normal file
1
test/chez/build-app/resources/greeting.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
embedded resource ok
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
(ns app.core
|
||||
(:require [app.util :as util]))
|
||||
(:require [app.util :as util]
|
||||
[clojure.java.io :as io]))
|
||||
|
||||
(defn -main [& args]
|
||||
;; the resource is baked into the binary (deps.edn :jolt/build :embed), so this
|
||||
;; resolves with no resources/ dir on disk, run from any cwd.
|
||||
(println (slurp (io/resource "greeting.txt")))
|
||||
(util/twice (println (util/shout "hello from a built binary")))
|
||||
(println "args:" (vec args))
|
||||
(println "sum:" (reduce + (map count args))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue