tools.deploy.embed: useful factors

Separate the embedding of an image into a VM executable (embed-image) from the copy-and-embed logic (make-embedded-image).
db4
Joe Groff 2011-11-21 11:10:06 -08:00
parent de5cc96286
commit 19e1046479
1 changed files with 8 additions and 4 deletions

View File

@ -4,14 +4,18 @@ bootstrap.image.private destructors io io.directories
io.encodings.binary io.files locals system ;
IN: tools.deploy.embed
:: embed-image ( from-image to-executable -- )
vm to-executable copy-file
to-executable binary <file-appender> [| out |
:: embed-image ( image executable -- )
executable binary <file-appender> [| out |
out stream-tell :> offset
from-image binary <file-reader> [| in |
image binary <file-reader> [| in |
in out stream-copy*
] with-disposal
image-magic uintptr_t <ref> out stream-write
offset uintptr_t <ref> out stream-write
] with-disposal ;
: make-embedded-image* ( from-image from-executable to-executable -- )
swap [ copy-file ] keep embed-image ;
: make-embedded-image ( from-image to-executable -- )
vm swap make-embedded-image* ;