alien.compile: use locals in some words
parent
4473ac9921
commit
94f519b12c
|
@ -1,6 +1,6 @@
|
||||||
USING: accessors arrays combinators fry generalizations
|
USING: accessors arrays combinators fry generalizations
|
||||||
io.encodings.ascii io.files io.files.temp io.launcher kernel
|
io.encodings.ascii io.files io.files.temp io.launcher kernel
|
||||||
sequences system ;
|
locals sequences system ;
|
||||||
IN: alien.compile
|
IN: alien.compile
|
||||||
|
|
||||||
: library-suffix ( -- str )
|
: library-suffix ( -- str )
|
||||||
|
@ -12,16 +12,15 @@ IN: alien.compile
|
||||||
|
|
||||||
: src-suffix ( lang -- str )
|
: src-suffix ( lang -- str )
|
||||||
{
|
{
|
||||||
{ "C" [ ".c" ] }
|
{ C [ ".c" ] }
|
||||||
{ "C++" [ ".cpp" ] }
|
{ C++ [ ".cpp" ] }
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
: compile-to-object ( lang contents name -- )
|
:: compile-to-object ( lang contents name -- )
|
||||||
rot '[ _ src-suffix append ] [ ".o" append ] bi
|
name ".o" append temp-file
|
||||||
[ temp-file ] bi@
|
contents name lang src-suffix append temp-file
|
||||||
[ tuck ascii set-file-contents ] dip
|
[ ascii set-file-contents ] keep 2array
|
||||||
swap 2array { "gcc" "-fPIC" "-c" "-o" } prepend
|
{ "gcc" "-fPIC" "-c" "-o" } prepend try-process ;
|
||||||
try-process ;
|
|
||||||
|
|
||||||
: link-object ( args name -- )
|
: link-object ( args name -- )
|
||||||
[ "lib" prepend library-suffix append ] [ ".o" append ] bi
|
[ "lib" prepend library-suffix append ] [ ".o" append ] bi
|
||||||
|
@ -34,6 +33,6 @@ IN: alien.compile
|
||||||
[ name>> "unimplemented for: " prepend throw ]
|
[ name>> "unimplemented for: " prepend throw ]
|
||||||
} cond prepend prepend try-process ;
|
} cond prepend prepend try-process ;
|
||||||
|
|
||||||
: compile-to-library ( lang args contents name -- )
|
:: compile-to-library ( lang args contents name -- )
|
||||||
[ [ nip ] dip compile-to-object ] 4 nkeep
|
lang contents name compile-to-object
|
||||||
nip link-object drop ;
|
args name link-object ;
|
||||||
|
|
Loading…
Reference in New Issue