Merge branch 'inlinec' into marshall

* inlinec:
  moved alien.inline tests to inline-tests.factor
  alien.inline: file get path>> instead of vocab-source-path
  alien.inline.compiler: x86_64 check and hook methods

Conflicts:
	basis/alien/inline/inline.factor
db4
Jeremy Hughes 2009-07-07 17:22:56 +12:00
commit 811a7c54eb
3 changed files with 23 additions and 15 deletions

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
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
locals sequences system ; locals sequences system words ;
IN: alien.inline.compiler IN: alien.inline.compiler
SYMBOL: C SYMBOL: C
@ -27,20 +27,28 @@ SYMBOL: C++
{ C++ [ "g++" ] } { C++ [ "g++" ] }
} case ; } 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 ) : link-command ( in out lang -- descr )
compiler os { compiler-descr link-descr append prepend prepend ;
{ [ 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
{ "-fPIC" "-c" "-o" } lang compiler prefix prepend lang compiler-descr { "-fPIC" "-c" "-o" } append prepend
try-process ; try-process ;
:: link-object ( lang args name -- ) :: link-object ( lang args name -- )

View File

@ -1,11 +1,11 @@
! Copyright (C) 2009 Jeremy Hughes. ! Copyright (C) 2009 Jeremy Hughes.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.inline.compiler alien.inline.types USING: accessors alien.inline.compiler alien.inline.types
alien.libraries alien.parser arrays assocs alien.libraries alien.parser arrays assocs combinators effects
combinators effects fry generalizations grouping io.files fry generalizations grouping io.files io.files.info io.files.temp
io.files.info io.files.temp kernel lexer locals math math.order kernel lexer locals math math.order math.ranges multiline
math.ranges multiline namespaces quotations sequences splitting namespaces quotations sequences source-files splitting strings
strings system vocabs.loader vocabs.parser words ; system vocabs.loader vocabs.parser words ;
IN: alien.inline IN: alien.inline
SYMBOL: c-library SYMBOL: c-library
@ -27,7 +27,7 @@ SYMBOL: c-strings
: compile-library? ( -- ? ) : compile-library? ( -- ? )
library-path dup exists? [ library-path dup exists? [
current-vocab vocab-source-path file get path>>
[ file-info modified>> ] bi@ <=> +lt+ = [ file-info modified>> ] bi@ <=> +lt+ =
] [ drop t ] if ; ] [ drop t ] if ;