alien.inline.compiler: use g++ for C++ files
parent
da01ae5cda
commit
994b142f74
|
@ -21,23 +21,33 @@ SYMBOL: C++
|
||||||
{ C++ [ ".cpp" ] }
|
{ C++ [ ".cpp" ] }
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
|
: compiler ( lang -- str )
|
||||||
|
{
|
||||||
|
{ C [ "gcc" ] }
|
||||||
|
{ C++ [ "g++" ] }
|
||||||
|
} case ;
|
||||||
|
|
||||||
|
: 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 ;
|
||||||
|
|
||||||
:: compile-to-object ( lang contents name -- )
|
:: compile-to-object ( lang contents name -- )
|
||||||
name ".o" append temp-file
|
name ".o" append temp-file
|
||||||
contents name lang src-suffix append temp-file
|
contents name lang src-suffix append temp-file
|
||||||
[ ascii set-file-contents ] keep 2array
|
[ ascii set-file-contents ] keep 2array
|
||||||
{ "gcc" "-fPIC" "-c" "-o" } prepend try-process ;
|
{ "-fPIC" "-c" "-o" } lang compiler prefix prepend
|
||||||
|
try-process ;
|
||||||
|
|
||||||
: link-object ( args name -- )
|
:: link-object ( lang args name -- )
|
||||||
[ "lib" prepend library-suffix append ] [ ".o" append ] bi
|
args name [ "lib" prepend library-suffix append ]
|
||||||
[ temp-file ] bi@ 2array
|
[ ".o" append ] bi [ temp-file ] bi@ 2array
|
||||||
os {
|
lang link-command try-process ;
|
||||||
{ [ dup linux? ]
|
|
||||||
[ drop { "gcc" "-shared" "-o" } ] }
|
|
||||||
{ [ dup macosx? ]
|
|
||||||
[ drop { "gcc" "-g" "-prebind" "-dynamiclib" "-o" } ] }
|
|
||||||
[ name>> "unimplemented for: " prepend throw ]
|
|
||||||
} cond prepend prepend try-process ;
|
|
||||||
|
|
||||||
:: compile-to-library ( lang args contents name -- )
|
:: compile-to-library ( lang args contents name -- )
|
||||||
lang contents name compile-to-object
|
lang contents name compile-to-object
|
||||||
args name link-object ;
|
lang args name link-object ;
|
||||||
|
|
Loading…
Reference in New Issue