Next: , Up: libutils file-system locators   [Index]


7.8.6.1 Run–time library file locator

The run–time library locator is the default; it can be selected explicitly with the command line option --library-locator run-time or by setting the parameter current-library-locator to run-time-library-locator; it is meant to be used by an installation of Vicare to run applications. The reference scenario for the run–time library locator is this:

  1. We install the package Vicare Scheme, compiling bundled libraries and putting them in some system directory; the libraries might be installed with pathnames like:
    /usr/local/lib/vicare-scheme/vicare/posix.fasl
  2. We install additional packages, compiling distributed libraries and putting them in some system directory; the libraries might be installed with pathnames like:
    /usr/local/lib/vicare-scheme/vicare/something.fasl
  3. We configure the library binary search path to make sure that it includes the system directory:
    (library-binary-search-path)
    ⇒ (... "/usr/local/lib/vicare-scheme" ...)
    
  4. We configure the library binary file scanner parameter:
    (current-library-binary-search-path-scanner
       default-library-binary-search-path-scanner)
    

    which will scan the search path returned by (library-binary-search-path).

  5. We compose a Scheme program demo.sps which imports the libraries:
    (import (vicare)
      (prefix (vicare posix) px.)
      (vicare something))
    

    and we execute it selecting the run–time library locator:

    $ vicare --library-locator run-time --r6rs-script demo.sps
    

    the command line option --library-locator will put run-time-library-locator in the parameter current-library-locator.

the result is that Vicare will search the binary libraries search path for library files.

The following bindings are exported by the library (vicare libraries).

Function: run-time-library-locator libref

Possible value for the parameter current-library-locator; this function is meant to be used to search for libraries when running an application.

Given a R6RS library reference: return a thunk to be used to start the search for a matching library. The returned thunk scans the search path for compiled libraries in search of a matching binary file; if a matching compiled library is not found: it scans the search path for source libraries in search of a matching source file.

When successful the returned thunk returns 2 values:

  1. An input port from which the library can be read; if the port is binary: a compiled library can be read from it; if the port is textual a source library can be read from it. It is responsibility of the caller to close the returned port when no more needed.
  2. A thunk to be called to continue the search. This thunk allows the caller to reject a library if it does not meet some additional constraints; for example: if its version number does not conform to libref.

When no matching library is found: the returned thunk returns #f and #f.


Next: , Up: libutils file-system locators   [Index]