Permalink
Browse files

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).
  • Loading branch information...
jckarter committed Nov 21, 2011
1 parent f9ba6bf commit 1b91486834fede27620b2e2c0f5f7f1bc6a37cdb
Showing with 8 additions and 4 deletions.
  1. +8 −4 basis/tools/deploy/embed/embed.factor
@@ -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* ;

0 comments on commit 1b91486

Please sign in to comment.