alien.inline.compiler: x86_64 check and hook methods
parent
994b142f74
commit
e76229a8f6
|
@ -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 ;
|
||||
locals sequences system words ;
|
||||
IN: alien.inline.compiler
|
||||
|
||||
SYMBOL: C
|
||||
|
@ -27,20 +27,28 @@ SYMBOL: C++
|
|||
{ C++ [ "g++" ] }
|
||||
} case ;
|
||||
|
||||
HOOK: compiler-descr os ( lang -- descr )
|
||||
|
||||
M: word compiler-descr compiler 1array ;
|
||||
M: macosx compiler-descr
|
||||
call-next-method cpu x86.64?
|
||||
[ { "-arch" "x86_64" } append ] when ;
|
||||
|
||||
HOOK: link-descr os ( -- descr )
|
||||
|
||||
M: word link-descr { "-shared" "-o" } ;
|
||||
M: macosx link-descr
|
||||
{ "-g" "-prebind" "-dynamiclib" "-o" }
|
||||
cpu x86.64? [ { "-arch" "x86_64" } prepend ] when ;
|
||||
|
||||
: link-command ( in out lang -- descr )
|
||||
compiler os {
|
||||
{ [ dup linux? ]
|
||||
[ drop { "-shared" "-o" } ] }
|
||||
{ [ dup macosx? ]
|
||||
[ drop { "-g" "-prebind" "-dynamiclib" "-o" } ] }
|
||||
[ name>> "unimplemented for: " prepend throw ]
|
||||
} cond swap prefix prepend prepend ;
|
||||
compiler-descr link-descr append prepend prepend ;
|
||||
|
||||
:: compile-to-object ( lang contents name -- )
|
||||
name ".o" append temp-file
|
||||
contents name lang src-suffix append temp-file
|
||||
[ ascii set-file-contents ] keep 2array
|
||||
{ "-fPIC" "-c" "-o" } lang compiler prefix prepend
|
||||
lang compiler-descr { "-fPIC" "-c" "-o" } append prepend
|
||||
try-process ;
|
||||
|
||||
:: link-object ( lang args name -- )
|
||||
|
|
Loading…
Reference in New Issue