Next: libutils file-system locators source, Previous: libutils file-system locators run, Up: libutils file-system locators [Index]
The compile–time library locator must be selected explicitly with the
command line option --library-locator compile-time
or by setting
the parameter current-library-locator
to
compile-time-library-locator
; it is meant to be used from the
build directory of a package while compiling libraries for development
or future installation. The reference scenario for the compile–time
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.
(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 the libraries under $(builddir)/lib
to take precedence
over the libraries under /usr/local/lib/vicare-scheme. 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" ...)
(compiled-libraries-build-directory) ⇒ "$(builddir)/lib
(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 compile-time-library-locator)
which implements the appropriate policy.
Assuming Makefiles generated by GNU Automake: to achieve the desired result, we have two options:
lib/vicare/that.fasl: lib/vicare/that.sls VICARE_SOURCE_PATH=; export VICARE_SOURCE_PATH; \ vicare --library-locator compile-time \ --library-path /usr/local/lib/vicare-scheme \ --source-path $(srcdir)/lib \ --build-directory $(builddir)/lib \ -o $@ -c $< lib/vicare/this.fasl: lib/vicare/this.sls lib/vicare/that.fasl VICARE_SOURCE_PATH=; export VICARE_SOURCE_PATH; \ vicare --library-locator compile-time \ --library-path /usr/local/lib/vicare-scheme \ --source-path $(srcdir)/lib \ --build-directory $(builddir)/lib \ -o $@ -c $<
this is the solution to prefer, because it allows parallel builds.
(import (only (vicare that)) (only (vicare this)))
write a single Makefile rule that compiles in the build directory all the dependencies of the script:
.PHONY: vfasl vfasl: VICARE_SOURCE_PATH=; export VICARE_SOURCE_PATH; \ vicare --library-locator compile-time \ --library-path /usr/local/lib/vicare-scheme \ --source-path $(srcdir)/lib \ --build-directory $(builddir)/lib \ --compile-dependencies compile-all.sps
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 libraries to be compiled for
installation.
Given a R6RS library reference: return a thunk to be used to start
the search for a matching library. The search for source libraries is
performed using the library source file scanner in
current-library-source-search-path-scanner
. The search for
compiled libraries is performed using the library binary file scanner in
current-library-binary-search-path-scanner
.
The returned thunk does the following:
compiled-libraries-build-directory
:
Remember that the binary file can be rejected if it has been compiled by another boot image or it has the wrong library UID.
When successful (a source or binary file matching libref is found) the returned thunk returns 2 values:
When no matching library is found: the returned thunk returns #f
and #f
.
Next: libutils file-system locators source, Previous: libutils file-system locators run, Up: libutils file-system locators [Index]