diff --git a/basis/alien/inline/compiler/compiler.factor b/basis/alien/inline/compiler/compiler.factor index 2f5fd29aff..d9f87a9f3b 100644 --- a/basis/alien/inline/compiler/compiler.factor +++ b/basis/alien/inline/compiler/compiler.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays combinators fry generalizations io.encodings.ascii io.files io.files.temp io.launcher kernel -locals sequences system words ; +locals make sequences system vocabs.parser words ; IN: alien.inline.compiler SYMBOL: C @@ -15,6 +15,12 @@ SYMBOL: C++ { [ dup windows? ] [ drop ".dll" ] } } cond ; +: library-path ( str -- str' ) + '[ + "lib-" % current-vocab name>> % + "-" % _ % library-suffix % + ] "" make temp-file ; + : src-suffix ( lang -- str ) { { C [ ".c" ] } @@ -52,8 +58,8 @@ M: macosx link-descr try-process ; :: link-object ( lang args name -- ) - args name [ "lib" prepend library-suffix append ] - [ ".o" append ] bi [ temp-file ] bi@ 2array + args name [ library-path ] + [ ".o" append temp-file ] bi 2array lang link-command try-process ; :: compile-to-library ( lang args contents name -- ) diff --git a/basis/alien/inline/inline-tests.factor b/basis/alien/inline/inline-tests.factor index acd2d615cd..60e6b3b594 100644 --- a/basis/alien/inline/inline-tests.factor +++ b/basis/alien/inline/inline-tests.factor @@ -15,7 +15,8 @@ C-FUNCTION: const-int add ( int a, int b ) { 2 1 } [ add ] must-infer-as [ 5 ] [ 2 3 add ] unit-test -<< library-path dup exists? [ delete-file ] [ drop ] if >> +<< c-library get library-path dup exists? +[ delete-file ] [ drop ] if >> C-LIBRARY: cpplib @@ -34,7 +35,8 @@ C-FUNCTION: const-char* hello ( ) { 0 1 } [ hello ] must-infer-as [ "hello world" ] [ hello ] unit-test -<< library-path dup exists? [ delete-file ] [ drop ] if >> +<< c-library get library-path dup exists? +[ delete-file ] [ drop ] if >> C-LIBRARY: compile-error @@ -45,4 +47,5 @@ C-FUNCTION: char* breakme ( ) << [ compile-c-library ] must-fail >> -<< library-path dup exists? [ delete-file ] [ drop ] if >> +<< c-library get library-path dup exists? +[ delete-file ] [ drop ] if >> diff --git a/basis/alien/inline/inline.factor b/basis/alien/inline/inline.factor index 365b56ca28..5ddd95a4cd 100644 --- a/basis/alien/inline/inline.factor +++ b/basis/alien/inline/inline.factor @@ -41,13 +41,8 @@ SYMBOL: c-strings : append-function-body ( prototype-str -- str ) " {\n" append parse-here append "\n}\n" append ; - -: library-path ( -- str ) - "lib" c-library get library-suffix - 3array concat temp-file ; - : compile-library? ( -- ? ) - library-path dup exists? [ + c-library get library-path dup exists? [ file get path>> [ file-info modified>> ] bi@ <=> +lt+ = ] [ drop t ] if ; @@ -66,7 +61,7 @@ PRIVATE> : compile-c-library ( -- ) compile-library? [ compile-library ] when - c-library get library-path "cdecl" add-library ; + c-library get dup library-path "cdecl" add-library ; : define-c-function ( function types effect -- ) [ factor-function define-declared ] 3keep prototype-string