Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions host/chez/build.ss
Original file line number Diff line number Diff line change
Expand Up @@ -1098,24 +1098,25 @@
(map rdr-form->data (ei-read-all src))))
(reverse reqs)))

;; Host classes a file's forms reference that a LIBRARY provides (jolt-lang/time,
;; jolt-crypto, …). At runtime a class-miss autoloads the provider's install
;; namespace off the source roots (host-static.ss jt-try-autoload! /
;; lib-try-autoload!); a built binary has no source roots, so the scan must pull
;; the provider into flat.ss instead — otherwise the binary throws the RFC 0008
;; "add io.github.jolt-lang/time" error for a dependency the project did declare.
;; Mirrors the runtime predicates: a jt-library class (or java.time.*) ->
;; "jolt.time"; anything else consults lib-class-providers. A provider is pulled
;; only when its source is actually on the roots (find-ns-file) — off the roots
;; the runtime's unknown-class message is the contract and the build must keep
;; succeeding exactly as before.
;; Host classes a file's forms reference that a PROVIDER installs (RFC 0014). At
;; runtime a class-miss autoloads the provider's install namespace off the source
;; roots (host-static.ss lib-try-autoload!); a built binary has no source roots,
;; so the scan must pull the provider into flat.ss instead — otherwise the binary
;; throws the "add it to your deps.edn" error for a dependency the project did
;; declare.
;;
;; This asks lib-provider-for, the same table the runtime resolves against,
;; rather than restating its rules. The previous version mirrored the runtime
;; predicates by hand and had to be kept in step with them.
;;
;; A provider is pulled only when its source is actually on the roots
;; (find-ns-file) — off the roots the runtime's unknown-class message is the
;; contract and the build must keep succeeding exactly as before.
(define (bld-ns-class-providers file)
(let ((src (ldr-read-source file))
(cands '()))
(define (add! class)
(let ((cand (cond ((or (member class jt-library-names) (java-time-prefixed? class))
"jolt.time")
((lib-provider-for class) => (lambda (p) (vector-ref p 0)))
(let ((cand (cond ((lib-provider-for class) => (lambda (p) (vector-ref p 0)))
(else #f))))
(when (and cand (not (member cand cands)))
(set! cands (cons cand cands)))))
Expand Down
23 changes: 18 additions & 5 deletions host/chez/deps-alias-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,20 @@ check "the dot form of a static autoloads too" "fixture-zone:UTC" "$(run -A:time
# the imported simple name did not. malli's transform.cljc builds one that way.
check "constructing a library class autoloads" "fixture-builder" "$(run -A:time run -m appzonector)"

# off the roots the reference still names the dependency to add
# Off the roots the reference reports that nothing provides the class — and
# deliberately does NOT name a library (RFC 0014). Which library supplies
# java.time is not the runtime's to say, and a caller may write the shim
# themselves; naming one would put the removed coupling back as a string.
out="$(runfull run -m appzone)"
case "$out" in
*jolt-lang/time*) check "library miss names the dependency" ok ok ;;
*) check "library miss names the dependency" "message naming jolt-lang/time" "$(printf '%s' "$out" | head -1)" ;;
*"No dependency provides"*) check "library miss reports no provider" ok ok ;;
*) check "library miss reports no provider" "message saying no dependency provides it" "$(printf '%s' "$out" | head -1)" ;;
esac
# The first line only: the traceback below it carries absolute paths, and this
# checkout lives under a directory called jolt-lang.
case "$(printf '%s' "$out" | head -1)" in
*jolt-lang/*) check "library miss names no library" "no library named" "$(printf '%s' "$out" | head -1)" ;;
*) check "library miss names no library" ok ok ;;
esac

# io/resource answers an ABSOLUTE file: URL for a file on a source root, like the
Expand All @@ -319,9 +328,13 @@ case "$out" in
*"failed to load"*) check "broken provider says it failed to load" ok ok ;;
*) check "broken provider says it failed to load" "message saying failed to load" "$(printf '%s' "$out" | head -1)" ;;
esac
# The two cases must not read alike: "declared but broken" is fixed by repairing
# the library, "nothing provides it" by supplying one. Asserting the absence of
# the no-provider wording is what keeps them apart now that neither names a
# coordinate.
case "$out" in
*"Add io.github.jolt-lang/time"*)
check "broken provider is not reported as missing" "no add-the-dependency advice" "$(printf '%s' "$out" | head -1)" ;;
*"No dependency provides"*)
check "broken provider is not reported as missing" "no missing-provider wording" "$(printf '%s' "$out" | head -1)" ;;
*) check "broken provider is not reported as missing" ok ok ;;
esac

Expand Down
Loading
Loading