diff --git a/cyclone.scm b/cyclone.scm index a4f1fa32..723a966a 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -73,9 +73,10 @@ (for-each (lambda (include) (set! input-program - (append (read-file (string-append - (lib:import->path lib-name) - include)) + (append (read-file ;(string-append + (lib:import->path lib-name append-dirs prepend-dirs include) + ;include) + ) input-program))) (reverse includes))))) ;; Append code in same order as the library's includes (else diff --git a/scheme/cyclone/libraries.sld b/scheme/cyclone/libraries.sld index 3a3c20f6..b5e375c0 100644 --- a/scheme/cyclone/libraries.sld +++ b/scheme/cyclone/libraries.sld @@ -234,7 +234,7 @@ )) ;; Get path to directory that contains the library -(define (lib:import->path import) +(define (lib:import->path import append-dirs prepend-dirs include) (let* ((import-path (reverse (cdr (reverse import)))) (path (apply @@ -242,10 +242,30 @@ (map (lambda (i) (string-append (lib:atom->string i) "/")) - import-path)))) - (if (tagged-list? 'scheme import) - (string-append (Cyc-installation-dir 'sld) "/" path) ;; Built-in library - path))) + import-path))) + (filename + (string-append path "" include)) + (dir (if (or (tagged-list? 'scheme import) + ;(tagged-list? 'srfi import) + ) + (Cyc-installation-dir 'sld) + ""))) + (call/cc + (lambda (return) + (for-each + (lambda (path) + (let ((f (string-append path "/" filename))) + (if (file-exists? f) + (return f)))) + (append prepend-dirs (list dir) append-dirs)) + ;; Not found, just return base name + (if (> (string-length dir) 0) + (string-append dir "/" filename) + filename))) + ;(if (tagged-list? 'scheme import) + ; (string-append (Cyc-installation-dir 'sld) "/" path) ;; Built-in library + ; path) + )) ;; Given a program's import set, resolve each import to its .o file, then ;; process each import recursively to get the .o files that each one of those