]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.libraries.finder: More robust finder code that doesn't return f to a
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 8 Jul 2014 17:40:33 +0000 (12:40 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 8 Jul 2014 17:40:33 +0000 (12:40 -0500)
string slot and error out. Use it in yaml.ffi.

basis/alien/libraries/finder/finder.factor
extra/yaml/ffi/ffi.factor

index 5ea6640985c7d185d0e2b9091f6d008e3da9c236..8df7c748efa2a3f7f02bbcfba1031ca98cc3396b 100644 (file)
@@ -6,9 +6,13 @@ HOOK: find-library* os ( name -- path/f )
 
 : find-library ( name -- path/library-not-found )
     dup find-library* [ nip ] when* ;
-    
+
+! Try to find the library from a list, but if it's not found,
+! try to open a library that is the first name in that list anyway
+! or "library_not_found" as a last resort for better debugging. 
 : find-library-from-list ( seq -- path/f )
-    [ find-library* ] map [ ] find nip ;
+    dup [ find-library* ] map
+    [ ] find nip [ nip ] [ ?first "library_not_found" or ] if* ;
 
 {
     { [ os macosx?  ] [ "alien.libraries.finder.macosx"  ] }
index a2177b057204dd36098d3d6fad32721e122301d8..9c74ad3567872acb2bcc320c095bff3ed94d251e 100644 (file)
@@ -3,15 +3,12 @@
 ! adapted from "yaml.h" libYAML 0.1.4
 ! http://pyyaml.org/wiki/LibYAML
 USING: alien alien.c-types alien.destructors alien.libraries
-alien.syntax classes.struct combinators literals system ;
+alien.syntax classes.struct combinators literals system
+alien.libraries.finder ;
 IN: yaml.ffi
 
 <<
-"libyaml" {
-    { [ os windows? ] [ "libyaml.dll" ] }
-    { [ os macosx?  ] [ "libyaml.dylib" ] }
-    { [ os unix?  ] [ "libyaml.so" ] }
-} cond cdecl add-library
+"libyaml" { "yaml" "libyaml-0-2" } find-library-from-list cdecl add-library
 >>
 
 C-TYPE: FILE