]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://github.com/slavapestov/factor
authorErik Charlebois <erikcharlebois@gmail.com>
Wed, 17 Feb 2010 08:06:27 +0000 (00:06 -0800)
committerErik Charlebois <erikcharlebois@gmail.com>
Wed, 17 Feb 2010 08:06:27 +0000 (00:06 -0800)
43 files changed:
basis/alien/libraries/libraries-docs.factor
basis/alien/libraries/libraries.factor
basis/globs/globs-tests.factor [changed mode: 0644->0755]
basis/globs/globs.factor
basis/math/blas/config/config-docs.factor
basis/math/blas/config/config.factor
basis/math/blas/ffi/ffi.factor
basis/tools/deploy/backend/backend.factor
basis/tools/deploy/libraries/libraries.factor [new file with mode: 0644]
basis/tools/deploy/libraries/tags.txt [new file with mode: 0644]
basis/tools/deploy/libraries/unix/tags.txt [new file with mode: 0644]
basis/tools/deploy/libraries/unix/unix.factor [new file with mode: 0644]
basis/tools/deploy/libraries/windows/windows.factor [new file with mode: 0644]
basis/tools/deploy/macosx/macosx.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/unix/unix.factor
basis/tools/deploy/windows/windows.factor
basis/vocabs/metadata/resources/resources-tests.factor
basis/windows/kernel32/kernel32.factor
extra/gpu/demos/bunny/deploy.factor
extra/morse/morse.factor [changed mode: 0644->0755]
extra/ogg/ogg.factor
extra/ogg/vorbis/vorbis.factor
extra/openal/alut/alut.factor [new file with mode: 0755]
extra/openal/alut/backend/authors.txt [new file with mode: 0755]
extra/openal/alut/backend/backend.factor [new file with mode: 0755]
extra/openal/alut/macosx/authors.txt [new file with mode: 0755]
extra/openal/alut/macosx/macosx.factor [new file with mode: 0755]
extra/openal/alut/macosx/tags.txt [new file with mode: 0644]
extra/openal/alut/other/authors.txt [new file with mode: 0755]
extra/openal/alut/other/other.factor [new file with mode: 0755]
extra/openal/backend/authors.txt [deleted file]
extra/openal/backend/backend.factor [deleted file]
extra/openal/example/example.factor [changed mode: 0644->0755]
extra/openal/macosx/authors.txt [deleted file]
extra/openal/macosx/macosx.factor [deleted file]
extra/openal/macosx/tags.txt [deleted file]
extra/openal/openal.factor [changed mode: 0644->0755]
extra/openal/other/authors.txt [deleted file]
extra/openal/other/other.factor [deleted file]
extra/space-invaders/space-invaders.factor [changed mode: 0644->0755]
extra/synth/example/example.factor [changed mode: 0644->0755]
extra/synth/synth.factor [changed mode: 0644->0755]

index 245565d9edc2204ff5168b824d1915c9255a0470..59142733b93df8fd76f9250a5036328f9036f7b9 100644 (file)
@@ -60,6 +60,10 @@ $nl
 }
 "Note the parse time evaluation with " { $link POSTPONE: << } "." } ;
 
+HELP: deploy-library
+{ $values { "name" string } }
+{ $description "Specifies that the logical library named " { $snippet "name" } " should be included during " { $link "tools.deploy" } ". " { $snippet "name" } " must be the name of a library previously loaded with " { $link add-library } "." } ;
+
 HELP: remove-library
 { $values { "name" string } }
 { $description "Unloads a library and removes it from the internal list of libraries. The " { $snippet "name" } " parameter should be a name that was previously passed to " { $link add-library } ". If no library with that name exists, this word does nothing." } ;
@@ -72,4 +76,9 @@ ARTICLE: "loading-libs" "Loading native libraries"
 }
 "Once a library has been defined, you can try loading it to see if the path name is correct:"
 { $subsections load-library }
-"If the compiler cannot load a library, or cannot resolve a symbol in a library, a linkage error is reported using the compiler error mechanism (see " { $link "compiler-errors" } "). Once you install the right library, reload the source file containing the " { $link add-library } " form to force the compiler to try loading the library again." ;
+"If the compiler cannot load a library, or cannot resolve a symbol in a library, a linkage error is reported using the compiler error mechanism (see " { $link "compiler-errors" } "). Once you install the right library, reload the source file containing the " { $link add-library } " form to force the compiler to try loading the library again."
+$nl
+"Libraries that do not come standard with the operating system need to be included with deployed applications that use them. A word is provided to instruct " { $link "tools.deploy" } " that a library must be so deployed:"
+{ $subsections
+    deploy-library
+} ;
index 0d255b8d076b67ce5b0435eb9e5c346bd91133ea..6f80900da0c54a1e72832dc58c4162e081455e73 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.strings assocs io.backend
-kernel namespaces destructors ;
+kernel namespaces destructors sequences system io.pathnames ;
 IN: alien.libraries
 
 : dlopen ( path -- dll ) native-string>alien (dlopen) ;
@@ -9,11 +9,15 @@ IN: alien.libraries
 : dlsym ( name dll -- alien ) [ string>symbol ] dip (dlsym) ;
 
 SYMBOL: libraries
+SYMBOL: deploy-libraries
 
 libraries [ H{ } clone ] initialize
+deploy-libraries [ V{ } clone ] initialize
 
 TUPLE: library path abi dll ;
 
+ERROR: no-library name ;
+
 : library ( name -- library ) libraries get at ;
 
 : <library> ( path abi -- library )
@@ -31,4 +35,20 @@ M: library dispose dll>> [ dispose ] when* ;
 
 : add-library ( name path abi -- )
     [ 2drop remove-library ]
-    [ <library> swap libraries get set-at ] 3bi ;
\ No newline at end of file
+    [ <library> swap libraries get set-at ] 3bi ;
+
+: deploy-library ( name -- )
+    dup libraries get key?
+    [ deploy-libraries get 2dup member? [ 2drop ] [ push ] if ]
+    [ no-library ] if ;
+
+<PRIVATE
+HOOK: >deployed-library-path os ( path -- path' )
+
+M: windows >deployed-library-path
+    file-name ;
+M: unix >deployed-library-path
+    file-name "$ORIGIN" prepend-path ;
+M: macosx >deployed-library-path
+    file-name "@executable_path/../Frameworks" prepend-path ;
+PRIVATE>
old mode 100644 (file)
new mode 100755 (executable)
index c9903b1..b243275
@@ -30,7 +30,7 @@ IN: globs.tests
 [ t ] [ "fo\\*" glob-pattern? ] unit-test
 [ t ] [ "fo{o,bro}" glob-pattern? ] unit-test
 
-"foo" "bar" append-path 1array
+{ "foo" "bar" } path-separator join 1array
 [ { "foo" "bar" "ba?" } path-separator join glob-parent-directory ] unit-test
 
 [ "foo" ] 
index 72b686c3b1db7cc603037b055d9b7ab02b2dd4d1..9cd6a73891b4e95093dd6b54a80eb944ecb5f5a5 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences io.pathnames kernel regexp.combinators
-strings unicode.case peg.ebnf regexp arrays ;
+strings splitting system unicode.case peg.ebnf regexp arrays ;
 IN: globs
 
 : not-path-separator ( -- sep )
-    "[^" path-separator "]" 3append <regexp> ; foldable
+    os windows? R! [^/\\]! R! [^/]! ? ; foldable
 
 EBNF: <glob>
 
@@ -48,5 +48,5 @@ Main = Concatenation End
     [ "\\*?[{" member? ] any? ;
 
 : glob-parent-directory ( glob -- parent-directory )
-    path-components dup [ glob-pattern? ] find drop head
+    path-separator split harvest dup [ glob-pattern? ] find drop head
     path-separator join ;
index 5c6cef83b8d8e3c5c910d51ed5565370256a1fc5..826f26c64617d5ea0d662389a7a2cf63ee6bde15 100644 (file)
@@ -6,20 +6,25 @@ ARTICLE: "math.blas.config" "Configuring the BLAS interface"
 { $subsections
     blas-library
     blas-fortran-abi
+    deploy-blas?
 }
 "The interface attempts to set default values based on the ones encountered on the Factor project's build machines. If these settings don't work with your system's BLAS, or you wish to use a commercial BLAS, you may change the global values of those variables in your " { $link "factor-rc" } ". For example, to use AMD's ACML library on Windows with " { $snippet "math.blas" } ", your " { $snippet "factor-rc" } " would look like this:"
 { $code """
 USING: math.blas.config namespaces ;
 "X:\\path\\to\\acml.dll" blas-library set-global
 intel-windows-abi blas-fortran-abi set-global
+t deploy-blas? set-global
 """ }
 "To take effect, the " { $snippet "blas-library" } " and " { $snippet "blas-fortran-abi" } " variables must be set before any other " { $snippet "math.blas" } " vocabularies are loaded."
 ;
 
 HELP: blas-library
-{ $description "The name of the shared library containing the BLAS interface to load. The value of this variable must be a valid shared library name that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ;
+{ $var-description "The name of the shared library containing the BLAS interface to load. The value of this variable must be a valid shared library name that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ;
 
 HELP: blas-fortran-abi
-{ $description "The Fortran ABI used by the BLAS interface specified in the " { $link blas-library } " variable. The value of " { $snippet "blas-fortran-abi" } " must be one of the " { $link "alien.fortran-abis" } " that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ;
+{ $var-description "The Fortran ABI used by the BLAS interface specified in the " { $link blas-library } " variable. The value of " { $snippet "blas-fortran-abi" } " must be one of the " { $link "alien.fortran-abis" } " that can be passed to " { $link add-fortran-library } ". To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ;
+
+HELP: deploy-blas?
+{ $var-description "If set to a true value, the BLAS library will be configured to deploy with applications that use it. To take effect, this variable must be set before any other " { $snippet "math.blas" } " vocabularies are loaded. See " { $link "math.blas.config" } " for details and examples." } ;
 
 ABOUT: "math.blas.config"
index bce6e663af63eed8e5bb8e9d0f72131d224dd177..76524d80ee716a838bcd15b10de165080f67b852 100644 (file)
@@ -1,7 +1,7 @@
 USING: alien.fortran combinators kernel namespaces system ;
 IN: math.blas.config
 
-SYMBOLS: blas-library blas-fortran-abi ;
+SYMBOLS: blas-library blas-fortran-abi deploy-blas? ;
 
 blas-library [
     {
@@ -21,3 +21,5 @@ blas-fortran-abi [
         [ f2c-abi ]
     } cond
 ] initialize
+
+deploy-blas? [ os macosx? not ] initialize
index b7748f500f825db77ea536c4d19cfd928a3a7bdf..5cc6a18b6d9996cce1a6e9ae6a09fa1e0b90ba1a 100644 (file)
@@ -1,9 +1,12 @@
 USING: alien.fortran kernel math.blas.config namespaces ;
+FROM: alien.libraries => deploy-library ;
 IN: math.blas.ffi
 
 <<
 "blas" blas-library blas-fortran-abi [ get ] bi@
 add-fortran-library
+
+deploy-blas? get [ "blas" deploy-library ] when
 >>
 
 LIBRARY: blas
index 9d6b8d4c0805fba47028827720827351f05b7aec..fe63071998613d2863e51040bc2e10eb88bd2bdb 100644 (file)
@@ -8,14 +8,27 @@ io.streams.c io.files io.files.temp io.pathnames io.directories
 io.directories.hierarchy io.backend quotations io.launcher
 tools.deploy.config tools.deploy.config.editor bootstrap.image
 io.encodings.utf8 destructors accessors hashtables
-vocabs.metadata.resources ;
+tools.deploy.libraries vocabs.metadata.resources ;
 IN: tools.deploy.backend
 
 : copy-vm ( executable bundle-name -- vm )
     prepend-path vm over copy-file ;
 
+TUPLE: vocab-manifest vocabs libraries ;
+
 : copy-resources ( manifest name dir -- )
-    append-path swap [ copy-vocab-resources ] with each ;
+    append-path swap vocabs>> [ copy-vocab-resources ] with each ;
+
+ERROR: cant-deploy-library-file library ;
+<PRIVATE
+: copy-library ( dir library -- )
+    dup find-library-file
+    [ nip swap over file-name append-path copy-file ]
+    [ cant-deploy-library-file ] if* ;
+PRIVATE>
+
+: copy-libraries ( manifest name dir -- )
+    append-path swap libraries>> [ copy-library ] with each ;
 
 : image-name ( vocab bundle-name -- str )
     prepend-path ".image" append ;
@@ -99,10 +112,16 @@ DEFER: ?make-staging-image
         ] { } make
     ] bind ;
 
+: parse-vocab-manifest-file ( path -- vocab-manifest )
+    utf8 file-lines
+    dup first "VOCABS:" =
+    [ { "LIBRARIES:" } split1 vocab-manifest boa ]
+    [ "invalid vocab manifest!" throw ] if ;
+
 : make-deploy-image ( vm image vocab config -- manifest )
     make-boot-image
     over "vocab-manifest-" prepend temp-file
     [ swap deploy-command-line run-factor ]
-    [ utf8 file-lines ] bi ;
+    [ parse-vocab-manifest-file ] bi ;
 
 HOOK: deploy* os ( vocab -- )
diff --git a/basis/tools/deploy/libraries/libraries.factor b/basis/tools/deploy/libraries/libraries.factor
new file mode 100644 (file)
index 0000000..36fe303
--- /dev/null
@@ -0,0 +1,11 @@
+! (c)2010 Joe Groff bsd license
+USING: alien.libraries io.pathnames io.pathnames.private kernel
+system vocabs.loader ;
+IN: tools.deploy.libraries
+
+HOOK: find-library-file os ( file -- path )
+
+os windows?
+"tools.deploy.libraries.windows"
+"tools.deploy.libraries.unix" ? require
+
diff --git a/basis/tools/deploy/libraries/tags.txt b/basis/tools/deploy/libraries/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/basis/tools/deploy/libraries/unix/tags.txt b/basis/tools/deploy/libraries/unix/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/basis/tools/deploy/libraries/unix/unix.factor b/basis/tools/deploy/libraries/unix/unix.factor
new file mode 100644 (file)
index 0000000..db3e9fa
--- /dev/null
@@ -0,0 +1,16 @@
+! (c)2010 Joe Groff bsd license
+USING: io.files io.pathnames io.pathnames.private kernel
+sequences system tools.deploy.libraries ;
+IN: tools.deploy.libraries.unix
+
+! stupid hack. better ways to find the library name would be open the library,
+! note a symbol address found in the library, then call dladdr (or use
+: ?exists ( path -- path/f )
+    dup exists? [ drop f ] unless ; inline
+
+M: unix find-library-file
+    dup absolute-path? [ ?exists ] [
+        { "/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" "resource:" }
+        [ prepend-path ?exists ] with map-find drop
+    ] if ;
+
diff --git a/basis/tools/deploy/libraries/windows/windows.factor b/basis/tools/deploy/libraries/windows/windows.factor
new file mode 100644 (file)
index 0000000..4698754
--- /dev/null
@@ -0,0 +1,16 @@
+! (c)2010 Joe Groff bsd license
+USING: alien.strings byte-arrays io.encodings.utf16n kernel
+specialized-arrays system tools.deploy.libraries windows.kernel32
+windows.types ;
+FROM: alien.c-types => ushort ;
+SPECIALIZED-ARRAY: ushort
+IN: tools.deploy.libraries.windows
+
+M: windows find-library-file
+    f DONT_RESOLVE_DLL_REFERENCES LoadLibraryEx [
+        [
+            32768 (ushort-array) [ 32768 GetModuleFileName drop ] keep
+            utf16n alien>string
+        ] [ FreeLibrary drop ] bi
+    ] [ f ] if* ;
+
index 8bd3749093404b0dadf39bf64969ca4abb000e81..c02642ba1d1c5db792d5e865a23108b472e656f4 100644 (file)
@@ -81,7 +81,9 @@ M: macosx deploy* ( vocab -- )
             [ bundle-name create-app-dir ] keep
             [ bundle-name deploy.app-image ] keep
             namespace make-deploy-image
-            bundle-name "Contents/Resources" copy-resources
+            bundle-name
+            [ "Contents/Resources" copy-resources ]
+            [ "Contents/Frameworks" copy-libraries ] 2bi
             bundle-name show-in-finder
         ] bind
     ] with-directory ;
index d8a653c02139d927edacaf954d287a9944b153be..54058f1b0d1ca234152aa2c69a1013478ef17b8e 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays accessors io.backend io.encodings.utf8 io.files
+USING: arrays alien.libraries accessors io.backend io.encodings.utf8 io.files
 io.streams.c init fry namespaces math make assocs kernel parser
 parser.notes lexer strings.parser vocabs sequences sequences.deep
 sequences.private words memory kernel.private continuations io
@@ -19,6 +19,7 @@ QUALIFIED: layouts
 QUALIFIED: source-files
 QUALIFIED: source-files.errors
 QUALIFIED: vocabs
+FROM: alien.libraries.private => >deployed-library-path ;
 IN: tools.deploy.shaker
 
 ! This file is some hairy shit.
@@ -505,11 +506,28 @@ SYMBOL: deploy-vocab
 
 : write-vocab-manifest ( vocab-manifest-out -- )
     "Writing vocabulary manifest to " write dup print flush
-    vocabs swap utf8 set-file-lines ;
+    vocabs "VOCABS:" prefix
+    deploy-libraries get [ libraries get at path>> ] map prune "LIBRARIES:" prefix append
+    swap utf8 set-file-lines ;
+
+: prepare-deploy-libraries ( -- )
+    "Preparing deployed libraries" show
+    deploy-libraries get [
+        libraries get [
+            [ path>> >deployed-library-path ] [ abi>> ] bi <library>
+        ] change-at
+    ] each
+    
+    [
+        "deploy-libraries" "alien.libraries" lookup forget
+        "deploy-library" "alien.libraries" lookup forget
+        ">deployed-library-path" "alien.libraries.private" lookup forget
+    ] with-compilation-unit ;
 
 : strip ( vocab-manifest-out -- )
     [ write-vocab-manifest ] when*
     startup-stripper
+    prepare-deploy-libraries
     strip-libc
     strip-destructors
     strip-call
index 2646f2d5a490f6d1451e1e6ed1db37efd56d6a69..1b6b8596e2b691cda181a488de1199cba6f23e0a 100644 (file)
@@ -19,7 +19,7 @@ M: unix deploy* ( vocab -- )
             [ bundle-name create-app-dir ] keep
             [ bundle-name image-name ] keep
             namespace make-deploy-image
-            bundle-name "" copy-resources
+            bundle-name "" [ copy-resources ] [ copy-libraries ] 3bi
             bundle-name normalize-path [ "Binary deployed to " % % "." % ] "" make print
         ] bind
     ] with-directory ;
index 9f0b22847b04b73c9fe5e2766fa7ffa219fb0963..1dd60583fa84d603a679afc58fc5b2cde795565e 100755 (executable)
@@ -36,7 +36,7 @@ M: winnt deploy*
                 [ drop embed-ico ]
                 [ image-name ]
                 [ drop namespace make-deploy-image ]
-                [ nip "" copy-resources ]
+                [ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
                 [ nip open-in-explorer ]
             } 2cleave 
         ] bind
index 36fd13125e4f0a98087ebc43cfaa8a2fb95e7b72..5c50406a264da2db7a508458ec88c293c78a2a20 100644 (file)
@@ -14,6 +14,5 @@ IN: vocabs.metadata.resources.tests
     "resource-dir/bas"
     "resource-dir/bas/zang"
     "resource-dir/bas/zim"
-    "resource-dir/buh"
     "resource-dir/foo"
 } ] [ "vocabs.metadata.resources.test.3" vocab-resource-files natural-sort ] unit-test
index 576fac3a0692334d4e213585a7065788f9b4cef9..db0005e21956733a80dc8211f460f6fed3d9da9f 100644 (file)
@@ -90,6 +90,8 @@ CONSTANT: FILE_ACTION_MODIFIED 3
 CONSTANT: FILE_ACTION_RENAMED_OLD_NAME 4
 CONSTANT: FILE_ACTION_RENAMED_NEW_NAME 5
 
+CONSTANT: DONT_RESOLVE_DLL_REFERENCES 1
+
 STRUCT: FILE_NOTIFY_INFORMATION
     { NextEntryOffset DWORD }
     { Action DWORD }
@@ -1167,7 +1169,7 @@ FUNCTION: BOOL FreeConsole ( ) ;
 ! FUNCTION: FreeEnvironmentStringsA
 FUNCTION: BOOL FreeEnvironmentStringsW ( LPTCH lpszEnvironmentBlock ) ;
 ALIAS: FreeEnvironmentStrings FreeEnvironmentStringsW
-! FUNCTION: FreeLibrary
+FUNCTION: BOOL FreeLibrary ( HMODULE hModule ) ;
 ! FUNCTION: FreeLibraryAndExitThread
 ! FUNCTION: FreeResource
 ! FUNCTION: FreeUserPhysicalPages
@@ -1314,7 +1316,8 @@ FUNCTION: DWORD GetLogicalDrives ( ) ;
 ! FUNCTION: GetLongPathNameW
 ! FUNCTION: GetMailslotInfo
 ! FUNCTION: GetModuleFileNameA
-! FUNCTION: GetModuleFileNameW
+FUNCTION: DWORD GetModuleFileNameW ( HMODULE hModule, LPTSTR lpFilename, DWORD nSize ) ;
+ALIAS: GetModuleFileName GetModuleFileNameW
 FUNCTION: HMODULE GetModuleHandleW ( LPCWSTR lpModuleName ) ;
 ALIAS: GetModuleHandle GetModuleHandleW
 ! FUNCTION: GetModuleHandleExA
index 1289caadb6dfb574184dbd85de958f1594b381ec..048d710a419566cfd4357e95672a34ba64a5494e 100644 (file)
@@ -6,7 +6,7 @@ H{
     { deploy-unicode? f }
     { "stop-after-last-window?" t }
     { deploy-io 3 }
-    { deploy-reflection 2 }
+    { deploy-reflection 1 }
     { deploy-word-props? f }
     { deploy-math? t }
     { deploy-threads? t }
old mode 100644 (file)
new mode 100755 (executable)
index cbe3c0f..c6f1601
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2008, 2009 Alex Chapman, 2009 Diego Martinelli
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors ascii assocs biassocs combinators hashtables kernel lists literals math namespaces make multiline openal parser sequences splitting strings synth synth.buffers ;
+USING: accessors ascii assocs biassocs combinators hashtables kernel lists literals math namespaces make multiline openal openal.alut parser sequences splitting strings synth synth.buffers ;
 IN: morse
 
 ERROR: no-morse-ch ch ;
index 24227167c97e9c05032835e0802681213eb59a92..d7abece8bc4b50da2ee1ea422458ae3b484ef6bd 100644 (file)
@@ -19,6 +19,8 @@ IN: ogg
     { [ os macosx? ] [ "libogg.0.dylib" ] }
     { [ os unix? ]   [ "libogg.so" ] }
 } cond "cdecl" add-library
+
+"ogg" deploy-library
 >>
 
 LIBRARY: ogg
index 8cf79fecafee8d572140331e262752effa256845..d5905dac9e7af006ecba3ea8867b62d53b973029 100644 (file)
@@ -20,6 +20,8 @@ IN: ogg.vorbis
     { [ os macosx? ] [ "libvorbis.0.dylib" ] }
     { [ os unix? ]   [ "libvorbis.so" ] }
 } cond "cdecl" add-library 
+
+"vorbis" deploy-library
 >>
 
 LIBRARY: vorbis
diff --git a/extra/openal/alut/alut.factor b/extra/openal/alut/alut.factor
new file mode 100755 (executable)
index 0000000..d1b8d26
--- /dev/null
@@ -0,0 +1,103 @@
+! Copyright (C) 2007 Chris Double.\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: kernel accessors arrays alien system combinators\r
+alien.syntax namespaces alien.c-types sequences vocabs.loader\r
+shuffle openal openal.alut.backend alien.libraries generalizations\r
+specialized-arrays alien.destructors ;\r
+FROM: alien.c-types => float short ;\r
+SPECIALIZED-ARRAY: uint\r
+IN: openal.alut\r
+\r
+<< "alut" {\r
+        { [ os windows? ]  [ "alut.dll" ] }\r
+        { [ os macosx? ] [\r
+            "/System/Library/Frameworks/OpenAL.framework/OpenAL"\r
+        ] }\r
+        { [ os unix?  ]  [ "libalut.so" ] }\r
+    } cond "cdecl" add-library >>\r
+\r
+<< os macosx? [ "alut" deploy-library ] unless >>\r
+\r
+LIBRARY: alut\r
+\r
+CONSTANT: ALUT_API_MAJOR_VERSION 1\r
+CONSTANT: ALUT_API_MINOR_VERSION 1\r
+CONSTANT: ALUT_ERROR_NO_ERROR 0\r
+CONSTANT: ALUT_ERROR_OUT_OF_MEMORY HEX: 200\r
+CONSTANT: ALUT_ERROR_INVALID_ENUM HEX: 201\r
+CONSTANT: ALUT_ERROR_INVALID_VALUE HEX: 202\r
+CONSTANT: ALUT_ERROR_INVALID_OPERATION HEX: 203\r
+CONSTANT: ALUT_ERROR_NO_CURRENT_CONTEXT HEX: 204\r
+CONSTANT: ALUT_ERROR_AL_ERROR_ON_ENTRY HEX: 205\r
+CONSTANT: ALUT_ERROR_ALC_ERROR_ON_ENTRY HEX: 206\r
+CONSTANT: ALUT_ERROR_OPEN_DEVICE HEX: 207\r
+CONSTANT: ALUT_ERROR_CLOSE_DEVICE HEX: 208\r
+CONSTANT: ALUT_ERROR_CREATE_CONTEXT HEX: 209\r
+CONSTANT: ALUT_ERROR_MAKE_CONTEXT_CURRENT HEX: 20A\r
+CONSTANT: ALUT_ERROR_DESTRY_CONTEXT HEX: 20B\r
+CONSTANT: ALUT_ERROR_GEN_BUFFERS HEX: 20C\r
+CONSTANT: ALUT_ERROR_BUFFER_DATA HEX: 20D\r
+CONSTANT: ALUT_ERROR_IO_ERROR HEX: 20E\r
+CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_TYPE HEX: 20F\r
+CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE HEX: 210\r
+CONSTANT: ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA HEX: 211\r
+CONSTANT: ALUT_WAVEFORM_SINE HEX: 100\r
+CONSTANT: ALUT_WAVEFORM_SQUARE HEX: 101\r
+CONSTANT: ALUT_WAVEFORM_SAWTOOTH HEX: 102\r
+CONSTANT: ALUT_WAVEFORM_WHITENOISE HEX: 103\r
+CONSTANT: ALUT_WAVEFORM_IMPULSE HEX: 104\r
+CONSTANT: ALUT_LOADER_BUFFER HEX: 300\r
+CONSTANT: ALUT_LOADER_MEMORY HEX: 301\r
+\r
+FUNCTION: ALboolean alutInit ( int* argcp, char** argv ) ;\r
+FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, char** argv ) ;\r
+FUNCTION: ALboolean alutExit ( ) ;\r
+FUNCTION: ALenum alutGetError ( ) ;\r
+FUNCTION: char* alutGetErrorString ( ALenum error ) ;\r
+FUNCTION: ALuint alutCreateBufferFromFile ( char* fileName ) ;\r
+FUNCTION: ALuint alutCreateBufferFromFileImage ( void* data, ALsizei length ) ;\r
+FUNCTION: ALuint alutCreateBufferHelloWorld ( ) ;\r
+FUNCTION: ALuint alutCreateBufferWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration ) ;\r
+FUNCTION: void* alutLoadMemoryFromFile ( char* fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ;\r
+FUNCTION: void* alutLoadMemoryFromFileImage ( void* data, ALsizei length, ALenum* format, ALsizei* size, ALfloat* frequency ) ;\r
+FUNCTION: void* alutLoadMemoryHelloWorld ( ALenum* format, ALsizei* size, ALfloat* frequency ) ;\r
+FUNCTION: void* alutLoadMemoryWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum* format, ALsizei* size, ALfloat* freq ) ;\r
+FUNCTION: char* alutGetMIMETypes ( ALenum loader ) ;\r
+FUNCTION: ALint alutGetMajorVersion ( ) ;\r
+FUNCTION: ALint alutGetMinorVersion ( ) ;\r
+FUNCTION: ALboolean alutSleep ( ALfloat duration ) ;\r
+\r
+FUNCTION: void alutUnloadWAV ( ALenum format, void* data, ALsizei size, ALsizei frequency ) ;\r
+\r
+SYMBOL: init\r
+\r
+: init-openal ( -- )\r
+    init get-global expired? [\r
+        f f alutInit 0 = [ "Could not initialize OpenAL" throw ] when\r
+        1337 <alien> init set-global\r
+    ] when ;\r
+\r
+: exit-openal ( -- )\r
+    init get-global expired? [\r
+        alutExit 0 = [ "Could not close OpenAL" throw ] when\r
+        f init set-global\r
+    ] unless ;\r
+\r
+: create-buffer-from-file ( filename -- buffer )\r
+    alutCreateBufferFromFile dup AL_NONE = [\r
+        "create-buffer-from-file failed" throw\r
+    ] when ;\r
+\r
+os macosx? "openal.alut.macosx" "openal.alut.other" ? require\r
+\r
+: create-buffer-from-wav ( filename -- buffer )\r
+    gen-buffer dup rot load-wav-file\r
+    [ alBufferData ] 4 nkeep alutUnloadWAV ;\r
+\r
+: check-error ( -- )\r
+    alGetError dup ALUT_ERROR_NO_ERROR = [\r
+        drop\r
+    ] [\r
+        alGetString throw\r
+    ] if ;\r
+\r
diff --git a/extra/openal/alut/backend/authors.txt b/extra/openal/alut/backend/authors.txt
new file mode 100755 (executable)
index 0000000..44b06f9
--- /dev/null
@@ -0,0 +1 @@
+Chris Double
diff --git a/extra/openal/alut/backend/backend.factor b/extra/openal/alut/backend/backend.factor
new file mode 100755 (executable)
index 0000000..fc50d3d
--- /dev/null
@@ -0,0 +1,4 @@
+USING: namespaces system ;
+IN: openal.alut.backend
+
+HOOK: load-wav-file os ( filename -- format data size frequency )
diff --git a/extra/openal/alut/macosx/authors.txt b/extra/openal/alut/macosx/authors.txt
new file mode 100755 (executable)
index 0000000..44b06f9
--- /dev/null
@@ -0,0 +1 @@
+Chris Double
diff --git a/extra/openal/alut/macosx/macosx.factor b/extra/openal/alut/macosx/macosx.factor
new file mode 100755 (executable)
index 0000000..3c0a467
--- /dev/null
@@ -0,0 +1,14 @@
+! Copyright (C) 2007 Chris Double.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types kernel alien alien.syntax shuffle
+openal openal.alut.backend namespaces system generalizations ;
+IN: openal.alut.macosx
+
+LIBRARY: alut
+
+FUNCTION: void alutLoadWAVFile ( ALbyte* fileName, ALenum* format, void** data, ALsizei* size, ALsizei* frequency ) ;
+
+M: macosx load-wav-file ( path -- format data size frequency )
+    0 <int> f <void*> 0 <int> 0 <int>
+    [ alutLoadWAVFile ] 4 nkeep
+    [ [ [ *int ] dip *void* ] dip *int ] dip *int ;
diff --git a/extra/openal/alut/macosx/tags.txt b/extra/openal/alut/macosx/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/openal/alut/other/authors.txt b/extra/openal/alut/other/authors.txt
new file mode 100755 (executable)
index 0000000..44b06f9
--- /dev/null
@@ -0,0 +1 @@
+Chris Double
diff --git a/extra/openal/alut/other/other.factor b/extra/openal/alut/other/other.factor
new file mode 100755 (executable)
index 0000000..b195792
--- /dev/null
@@ -0,0 +1,14 @@
+! Copyright (C) 2007 Chris Double.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.syntax combinators generalizations
+kernel openal openal.alut.backend ;
+IN: openal.alut.other
+
+LIBRARY: alut
+
+FUNCTION: void alutLoadWAVFile ( ALbyte* fileName, ALenum* format, void** data, ALsizei* size, ALsizei* frequency, ALboolean* looping ) ;
+
+M: object load-wav-file ( filename -- format data size frequency )
+    0 <int> f <void*> 0 <int> 0 <int>
+    [ 0 <char> alutLoadWAVFile ] 4 nkeep
+    { [ *int ] [ *void* ] [ *int ] [ *int ] } spread ;
diff --git a/extra/openal/backend/authors.txt b/extra/openal/backend/authors.txt
deleted file mode 100755 (executable)
index 44b06f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Chris Double
diff --git a/extra/openal/backend/backend.factor b/extra/openal/backend/backend.factor
deleted file mode 100644 (file)
index 41069dc..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: namespaces system ;
-IN: openal.backend
-
-HOOK: load-wav-file os ( filename -- format data size frequency )
old mode 100644 (file)
new mode 100755 (executable)
index 4d979a8..7789ee6
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007 Chris Double.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-USING: calendar kernel openal sequences threads ;\r
+USING: calendar kernel openal openal.alut sequences threads ;\r
 IN: openal.example\r
 \r
 : play-hello ( -- )\r
diff --git a/extra/openal/macosx/authors.txt b/extra/openal/macosx/authors.txt
deleted file mode 100755 (executable)
index 44b06f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Chris Double
diff --git a/extra/openal/macosx/macosx.factor b/extra/openal/macosx/macosx.factor
deleted file mode 100644 (file)
index f0a6b92..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-! Copyright (C) 2007 Chris Double.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types kernel alien alien.syntax shuffle
-openal openal.backend namespaces system generalizations ;
-IN: openal.macosx
-
-LIBRARY: alut
-
-FUNCTION: void alutLoadWAVFile ( ALbyte* fileName, ALenum* format, void** data, ALsizei* size, ALsizei* frequency ) ;
-
-M: macosx load-wav-file ( path -- format data size frequency )
-    0 <int> f <void*> 0 <int> 0 <int>
-    [ alutLoadWAVFile ] 4 nkeep
-    [ [ [ *int ] dip *void* ] dip *int ] dip *int ;
diff --git a/extra/openal/macosx/tags.txt b/extra/openal/macosx/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
old mode 100644 (file)
new mode 100755 (executable)
index 85b150c..bbe61f9
@@ -2,20 +2,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors arrays alien system combinators
 alien.syntax namespaces alien.c-types sequences vocabs.loader
-shuffle openal.backend alien.libraries generalizations
+shuffle alien.libraries generalizations
 specialized-arrays alien.destructors ;
 FROM: alien.c-types => float short ;
 SPECIALIZED-ARRAY: uint
 IN: openal
 
-<< "alut" {
-        { [ os windows? ]  [ "alut.dll" ] }
-        { [ os macosx? ] [
-            "/System/Library/Frameworks/OpenAL.framework/OpenAL"
-        ] }
-        { [ os unix?  ]  [ "libalut.so" ] }
-    } cond "cdecl" add-library >>
-
 << "openal" {
         { [ os windows? ]  [ "OpenAL32.dll" ] }
         { [ os macosx? ] [
@@ -24,6 +16,8 @@ IN: openal
         { [ os unix?  ]  [ "libopenal.so" ] }
     } cond "cdecl" add-library >>
 
+<< os macosx? [ "openal" deploy-library ] unless >>
+
 LIBRARY: openal
 
 TYPEDEF: char ALboolean 
@@ -252,71 +246,6 @@ FUNCTION: void alcCaptureSamples ( ALCdevice* device, void* buf, ALCsizei samps
 DESTRUCTOR: alcCloseDevice*
 DESTRUCTOR: alcDestroyContext
 
-LIBRARY: alut
-
-CONSTANT: ALUT_API_MAJOR_VERSION 1
-CONSTANT: ALUT_API_MINOR_VERSION 1
-CONSTANT: ALUT_ERROR_NO_ERROR 0
-CONSTANT: ALUT_ERROR_OUT_OF_MEMORY HEX: 200
-CONSTANT: ALUT_ERROR_INVALID_ENUM HEX: 201
-CONSTANT: ALUT_ERROR_INVALID_VALUE HEX: 202
-CONSTANT: ALUT_ERROR_INVALID_OPERATION HEX: 203
-CONSTANT: ALUT_ERROR_NO_CURRENT_CONTEXT HEX: 204
-CONSTANT: ALUT_ERROR_AL_ERROR_ON_ENTRY HEX: 205
-CONSTANT: ALUT_ERROR_ALC_ERROR_ON_ENTRY HEX: 206
-CONSTANT: ALUT_ERROR_OPEN_DEVICE HEX: 207
-CONSTANT: ALUT_ERROR_CLOSE_DEVICE HEX: 208
-CONSTANT: ALUT_ERROR_CREATE_CONTEXT HEX: 209
-CONSTANT: ALUT_ERROR_MAKE_CONTEXT_CURRENT HEX: 20A
-CONSTANT: ALUT_ERROR_DESTRY_CONTEXT HEX: 20B
-CONSTANT: ALUT_ERROR_GEN_BUFFERS HEX: 20C
-CONSTANT: ALUT_ERROR_BUFFER_DATA HEX: 20D
-CONSTANT: ALUT_ERROR_IO_ERROR HEX: 20E
-CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_TYPE HEX: 20F
-CONSTANT: ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE HEX: 210
-CONSTANT: ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA HEX: 211
-CONSTANT: ALUT_WAVEFORM_SINE HEX: 100
-CONSTANT: ALUT_WAVEFORM_SQUARE HEX: 101
-CONSTANT: ALUT_WAVEFORM_SAWTOOTH HEX: 102
-CONSTANT: ALUT_WAVEFORM_WHITENOISE HEX: 103
-CONSTANT: ALUT_WAVEFORM_IMPULSE HEX: 104
-CONSTANT: ALUT_LOADER_BUFFER HEX: 300
-CONSTANT: ALUT_LOADER_MEMORY HEX: 301
-
-FUNCTION: ALboolean alutInit ( int* argcp, char** argv ) ;
-FUNCTION: ALboolean alutInitWithoutContext ( int* argcp, char** argv ) ;
-FUNCTION: ALboolean alutExit ( ) ;
-FUNCTION: ALenum alutGetError ( ) ;
-FUNCTION: char* alutGetErrorString ( ALenum error ) ;
-FUNCTION: ALuint alutCreateBufferFromFile ( char* fileName ) ;
-FUNCTION: ALuint alutCreateBufferFromFileImage ( void* data, ALsizei length ) ;
-FUNCTION: ALuint alutCreateBufferHelloWorld ( ) ;
-FUNCTION: ALuint alutCreateBufferWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration ) ;
-FUNCTION: void* alutLoadMemoryFromFile ( char* fileName, ALenum* format, ALsizei* size, ALfloat* frequency ) ;
-FUNCTION: void* alutLoadMemoryFromFileImage ( void* data, ALsizei length, ALenum* format, ALsizei* size, ALfloat* frequency ) ;
-FUNCTION: void* alutLoadMemoryHelloWorld ( ALenum* format, ALsizei* size, ALfloat* frequency ) ;
-FUNCTION: void* alutLoadMemoryWaveform ( ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum* format, ALsizei* size, ALfloat* freq ) ;
-FUNCTION: char* alutGetMIMETypes ( ALenum loader ) ;
-FUNCTION: ALint alutGetMajorVersion ( ) ;
-FUNCTION: ALint alutGetMinorVersion ( ) ;
-FUNCTION: ALboolean alutSleep ( ALfloat duration ) ;
-
-FUNCTION: void alutUnloadWAV ( ALenum format, void* data, ALsizei size, ALsizei frequency ) ;
-
-SYMBOL: init
-
-: init-openal ( -- )
-    init get-global expired? [
-        f f alutInit 0 = [ "Could not initialize OpenAL" throw ] when
-        1337 <alien> init set-global
-    ] when ;
-
-: exit-openal ( -- )
-    init get-global expired? [
-        alutExit 0 = [ "Could not close OpenAL" throw ] when
-        f init set-global
-    ] unless ;
-
 : gen-sources ( size -- seq )
     dup <uint-array> [ alGenSources ] keep ;
 
@@ -325,17 +254,6 @@ SYMBOL: init
 
 : gen-buffer ( -- buffer ) 1 gen-buffers first ;
 
-: create-buffer-from-file ( filename -- buffer )
-    alutCreateBufferFromFile dup AL_NONE = [
-        "create-buffer-from-file failed" throw
-    ] when ;
-
-os macosx? "openal.macosx" "openal.other" ? require
-
-: create-buffer-from-wav ( filename -- buffer )
-    gen-buffer dup rot load-wav-file
-    [ alBufferData ] 4 nkeep alutUnloadWAV ;
-
 : queue-buffers ( source buffers -- )
     [ length ] [ >uint-array ] bi alSourceQueueBuffers ;
 
@@ -358,12 +276,5 @@ os macosx? "openal.macosx" "openal.other" ? require
 
 : source-stop ( source -- ) alSourceStop ;
 
-: check-error ( -- )
-    alGetError dup ALUT_ERROR_NO_ERROR = [
-        drop
-    ] [
-        alGetString throw
-    ] if ;
-
 : source-playing? ( source -- bool )
     AL_SOURCE_STATE get-source-param AL_PLAYING = ;
diff --git a/extra/openal/other/authors.txt b/extra/openal/other/authors.txt
deleted file mode 100755 (executable)
index 44b06f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Chris Double
diff --git a/extra/openal/other/other.factor b/extra/openal/other/other.factor
deleted file mode 100644 (file)
index ada8d6b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-! Copyright (C) 2007 Chris Double.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax combinators generalizations
-kernel openal openal.backend ;
-IN: openal.other
-
-LIBRARY: alut
-
-FUNCTION: void alutLoadWAVFile ( ALbyte* fileName, ALenum* format, void** data, ALsizei* size, ALsizei* frequency, ALboolean* looping ) ;
-
-M: object load-wav-file ( filename -- format data size frequency )
-    0 <int> f <void*> 0 <int> 0 <int>
-    [ 0 <char> alutLoadWAVFile ] 4 nkeep
-    { [ *int ] [ *void* ] [ *int ] [ *int ] } spread ;
old mode 100644 (file)
new mode 100755 (executable)
index 17e277f..01bf621
@@ -18,6 +18,7 @@ USING:
     math
     math.order
     openal
+    openal.alut
     opengl.gl
     sequences
     ui
old mode 100644 (file)
new mode 100755 (executable)
index 747cfb9..e09d903
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel namespaces make openal sequences
+USING: accessors arrays kernel namespaces make openal openal.alut sequences
 synth synth.buffers ;
 IN: synth.example
 
old mode 100644 (file)
new mode 100755 (executable)
index def610d..90645e3
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel locals math math.constants math.functions memoize openal synth.buffers sequences sequences.modified sequences.repeating ;
+USING: accessors kernel locals math math.constants math.functions memoize openal openal.alut synth.buffers sequences sequences.modified sequences.repeating ;
 IN: synth
 
 MEMO: single-sine-wave ( samples/wave -- seq )