From 17d819a3997f236c9da5d11394627bc3b26cbafa Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 2 Feb 2017 00:10:54 -0500 Subject: [PATCH] Issue #165 - `-A` and `-I` options --- CHANGELOG.md | 10 ++++++++++ cyclone.scm | 2 +- scheme/cyclone/libraries.sld | 8 ++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50dba0f9..7d4cbef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ Features - Koz Ross added an implementation of SRFI 60. +- Added the `-A` and `-I` compiler options from SRFI 138 to `cyclone`: + + > `-A directory` + > + > Append directory to the list of directories that are searched in order to locate imported libraries. + > + > `-I directory` + > + > Prepend directory to the list of directories that are searched in order to locate imported libraries. + - Updated the garbage collector to enhance performance for programs with a high allocation rate, and to scale better to multiple concurrent threads. - Improved error handling by `display` and `write`. - Removed the `make_int` C macro which was deprecated and could cause problems when used in FFI functions. diff --git a/cyclone.scm b/cyclone.scm index 82651700..a4f1fa32 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -304,7 +304,7 @@ (lib-deps (if (and program? (tagged-list? 'import (car in-prog))) - (lib:get-all-import-deps (cdar in-prog)) + (lib:get-all-import-deps (cdar in-prog) append-dirs prepend-dirs) '())) (exec-file (basename in-file)) (src-file (string-append exec-file ".c")) diff --git a/scheme/cyclone/libraries.sld b/scheme/cyclone/libraries.sld index 24d46ce8..3a3c20f6 100644 --- a/scheme/cyclone/libraries.sld +++ b/scheme/cyclone/libraries.sld @@ -265,9 +265,9 @@ ;; Given a single import from an import-set, open the corresponding ;; library file and retrieve the library's import-set. -(define (lib:read-imports import) +(define (lib:read-imports import append-dirs prepend-dirs) (let* ((lib-name (lib:import->library-name import)) - (dir (lib:import->filename lib-name)) + (dir (lib:import->filename lib-name ".sld" append-dirs prepend-dirs)) (fp (open-input-file dir)) (lib (read-all fp)) (imports (lib:imports (car lib)))) @@ -471,7 +471,7 @@ ;; Given an import set, get all dependant import names that are required ;; The list of deps is intended to be returned in order, such that the ;; libraries can be initialized properly in sequence. -(define (lib:get-all-import-deps imports) +(define (lib:get-all-import-deps imports append-dirs prepend-dirs) (letrec ((libraries/deps '()) (find-deps! (lambda (import-sets) @@ -483,7 +483,7 @@ ;; Prevent cycles by only processing new libraries ((not (assoc lib-name libraries/deps)) ;; Find all dependencies of i (IE, libraries it imports) - (let* ((deps (lib:read-imports import-set)) + (let* ((deps (lib:read-imports import-set append-dirs prepend-dirs)) (dep-libs (map lib:import->library-name deps))) (set! libraries/deps