; (use-modules
(ice-9 popen) (ice-9 rdelim))
(define (lyp:pread cmd)
(let* ( (port (open-input-pipe cmd)) (output (read-delimited "" port)) ) (close-pipe port) (if (string? output) output (throw 'lyp:failure "lyp:pread" (format "Command failed: ~a" cmd) #f))))
; a hash mapping package refs to entry points (define lyp:package-entry-points (make-hash-table))
; resolve a package reference ; ; The reference is first looked up in the package ref hash table. ; if not found, the resolver is invoked, and the information ; returned (define (lyp:package-entry-point ref)
(catch #t (lambda () (or (hash-ref lyp:package-entry-points ref) (lyp:find-package ref))) (lambda (key . parameters) ; (set! error-thrown #t) (throw 'lyp:failure "lyp:package-entry-point" (format "Failed to resolve dependency ~a" ref) #f) ))
)
(define (lyp:find-package ref)
(let* ( (cmd (string-append "bin/lyp-resolve " ref)) (path (lyp:pread cmd)) ) (hash-set! lyp:package-entry-points ref path) path )
)
(define (lyp:load-package ref)
(let* ( (path (lyp:package-entry-point ref)) ) (lyp:load:ref path #t) )
)