Self-contained build foundation: embedded-bytes helpers, launcher stub, in-process app link
Adds the pieces a toolchain-free joltc needs to compile apps with no external Chez or cc: - host/chez/java/io.ss: register-embedded-bytes!/jolt-embedded-bytes, read-file-bytes, jolt-spill-embedded!, jolt-append-payload! (frames an app boot onto the stub as [stub][boot][len:le64]["JOLTBOOT"]), and jolt-chmod-755 via load-shared-object #f (no subprocess). - host/chez/stub/launcher.c: a native stub that locates its own executable, reads the trailing frame, and hands the appended boot to the Chez kernel. - host/chez/loader.ss: resolve-on-roots consults the embedded source store before disk; ldr-read-source reads baked source. Dev (empty store) is unaffected. - host/chez/build.ss: build-binary step 4 splits into build-self-contained (in-process compile-file/make-boot-file with the system error restored, then append the boot to a copy of the embedded stub) and build-with-cc (the existing dev path). The self-contained path is taken only when the stub is embedded. The legacy cc path is unchanged behaviorally; make buildsmoke still passes.
This commit is contained in:
parent
0abb958955
commit
0420cd4d79
4 changed files with 266 additions and 48 deletions
|
|
@ -122,14 +122,31 @@
|
|||
(else (loop (cdr cs) (cons (car cs) seg) segs)))))
|
||||
|
||||
;; First existing <root>/rel.clj or <root>/rel.cljc on the search roots, else #f.
|
||||
;; A self-contained joltc binary embeds jolt-core + stdlib source keyed by their
|
||||
;; root-relative path ("clojure/string.clj"); those are checked first, so a
|
||||
;; `require` resolves with no source on disk. The dev bin/joltc has an empty
|
||||
;; source store, so the two hashtable probes miss and it falls straight to disk.
|
||||
(define (resolve-on-roots rel)
|
||||
(let loop ((roots source-roots))
|
||||
(if (null? roots) #f
|
||||
(let ((clj (string-append (car roots) "/" rel ".clj"))
|
||||
(cljc (string-append (car roots) "/" rel ".cljc")))
|
||||
(cond ((file-exists? clj) clj)
|
||||
((file-exists? cljc) cljc)
|
||||
(else (loop (cdr roots))))))))
|
||||
(let ((eclj (string-append rel ".clj")) (ecljc (string-append rel ".cljc")))
|
||||
(cond
|
||||
((string? (hashtable-ref embedded-resources eclj #f)) eclj)
|
||||
((string? (hashtable-ref embedded-resources ecljc #f)) ecljc)
|
||||
(else
|
||||
(let loop ((roots source-roots))
|
||||
(if (null? roots) #f
|
||||
(let ((clj (string-append (car roots) "/" rel ".clj"))
|
||||
(cljc (string-append (car roots) "/" rel ".cljc")))
|
||||
(cond ((file-exists? clj) clj)
|
||||
((file-exists? cljc) cljc)
|
||||
(else (loop (cdr roots)))))))))))
|
||||
|
||||
;; Read a namespace source. An embedded key (resolve-on-roots above, or the
|
||||
;; build driver's app-order entries) reads its baked string; everything else is
|
||||
;; a real path read off disk. Bytevector entries (the bundled boots/stub) are not
|
||||
;; source, so a string? guard skips them.
|
||||
(define (ldr-read-source path)
|
||||
(let ((emb (hashtable-ref embedded-resources path #f)))
|
||||
(if (string? emb) emb (read-file-string path))))
|
||||
|
||||
(define (find-ns-file name) (resolve-on-roots (ns-name->rel name)))
|
||||
|
||||
|
|
@ -176,7 +193,7 @@
|
|||
;; more forms", which would silently drop the entire rest of the file; here we
|
||||
;; skip the no-op form and continue to true end-of-string.
|
||||
(define (load-jolt-file path)
|
||||
(let* ((src (read-file-string path)) (end (string-length src)))
|
||||
(let* ((src (ldr-read-source path)) (end (string-length src)))
|
||||
;; parameterize (not a bare set!) so a require nested in this file's ns form
|
||||
;; restores path when control returns to the rest of this file.
|
||||
(parameterize ((rdr-source-file path)) ; list forms read here carry :file = path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue