Previous: libutils file-system locators compile, Up: libutils file-system locators [Index]
The source library locator must be selected explicitly with the command
line option --library-locator source
or by setting the parameter
current-library-locator
to source-library-locator
; it is
meant to be used to search for source libraries first and then for
compiled ones. The reference scenario for the source library locator is
this:
$(srcdir)/lib/vicare/this.sls $(srcdir)/lib/vicare/that.sls
we want to compile them under the build directory:
$(builddir)/lib/vicare/this.fasl $(builddir)/lib/vicare/that.fasl
and then install them in a system directory:
/usr/local/lib/vicare-scheme/vicare/this.fasl /usr/local/lib/vicare-scheme/vicare/that.fasl
In the package’s building infrastructure (for example a Makefile managed
by the GNU Autotools) we need to write appropriate invocations of
vicare
to build the libraries locally and pick the
appropriate source libraries and compiled libraries.
This is the gist: we want to automatically generate an include Makefile holding the compilation and installation recipes correctly describing the dependencies among libraries. For this we need to load all the source libraries in the package’s source tree.
(library (vicare this) (export) (import (vicare) (vicare that)) ---) (library (vicare that) (export) (import (vicare) (prefix (vicare posix) px.) (vicare something)) ---)
/usr/local/lib/vicare-scheme/vicare/this.fasl /usr/local/lib/vicare-scheme/vicare/that.fasl
we want these installed libraries to be ignored. It may be that there exist installed source libraries:
/usr/local/lib/vicare-scheme/vicare/this.sls /usr/local/lib/vicare-scheme/vicare/that.sls
we want the libraries under $(srcdir)/lib
to take precedence over
the libraries under /usr/local/lib/vicare-scheme.
At the Scheme level we want the following:
(library-source-search-path) ⇒ ("$(srcdir)/lib")
(library-binary-search-path) ⇒ (... "/usr/local/lib/vicare-scheme" ...)
(current-library-binary-search-path-scanner default-library-binary-search-path-scanner)
which will scan the search path returned by
(library-binary-search-path)
.
(current-library-source-search-path-scanner default-library-source-search-path-scanner)
which will scan the search path returned by
(library-source-search-path)
.
(current-library-locator source-library-locator)
which implements the appropriate policy.
To achieve the desired result, in the Makefile we write rules as follows:
.PHONY: dependencies DEPSCRIPT = $(srcdir)/scripts/build-makefile-rules.sps dependencies: VICARE_SOURCE_PATH=; export VICARE_SOURCE_PATH; \ vicare --library-locator source \ --library-path /usr/local/lib/vicare-scheme \ --source-path $(srcdir)/lib \ --r6rs-script $(DEPSCRIPT) -- \ $(slsdir)/libraries.scm >$(slsdir)/dependencies.make
where the executed Scheme script generates the Makefile rules automatically.
The following bindings are exported by the library (vicare
libraries)
.
Possible value for the parameter current-library-locator
; this
function is meant to be used to search for source libraries first and
for binary libraries later.
Given a R6RS library reference: return a thunk to be used to start
the search for a matching library. The returned thunk uses the current
source library scanner referenced by
current-library-source-search-path-scanner
, with the purpose of
finding a library file that matches a given R6RS library reference.
If no source library is found: the current binary library scanner
referenced by current-library-binary-search-path-scanner
is used.
When successful the returned thunk returns 2 values:
When no matching library is found: the returned thunk returns #f
and #f
.
Previous: libutils file-system locators compile, Up: libutils file-system locators [Index]