]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/libraries/finder/finder.factor
factor: more top level forms.
[factor.git] / basis / alien / libraries / finder / finder.factor
1 USING: accessors alien.libraries kernel lexer parser sequences
2 system vocabs vocabs.platforms ;
3 IN: alien.libraries.finder
4
5 HOOK: find-library* os ( name -- path/f )
6
7 : find-library ( name -- path/library-not-found )
8     dup find-library* [ nip ] when* ;
9
10 : ?update-library ( name path abi -- )
11     pick lookup-library [ dll>> dll-valid? ] [ f ] if* [
12         3drop
13     ] [
14         [ find-library ] [ update-library ] bi*
15     ] if ;
16
17 ! Try to find the library from a list, but if it's not found,
18 ! try to open a library that is the first name in that list anyway
19 ! or "library_not_found" as a last resort for better debugging.
20 : find-library-from-list ( seq -- path/f )
21     dup [ find-library* ] map-find drop
22     [ ] [ ?first "library_not_found" or ] ?if ;
23
24 SYNTAX: ADD-FIRST-LIBRARY:
25     scan-token scan-word scan-object
26     find-library-from-list swap add-library ;
27
28 USE-OS-SUFFIX: alien.libraries.finder