tools.deploy: embed image into deployed VM

Also, use the unix backend to deploy non-UI applications on macosx
db4
Joe Groff 2011-11-21 11:44:27 -08:00
parent 19e1046479
commit d9a9155a80
5 changed files with 28 additions and 19 deletions

View File

@ -8,7 +8,8 @@ io.streams.c io.files io.files.temp io.pathnames io.directories
io.directories.hierarchy io.backend quotations io.launcher
tools.deploy.config tools.deploy.config.editor bootstrap.image
io.encodings.utf8 destructors accessors hashtables
tools.deploy.libraries vocabs.metadata.resources ;
tools.deploy.libraries vocabs.metadata.resources
tools.deploy.embed locals ;
IN: tools.deploy.backend
: copy-vm ( executable bundle-name -- vm )
@ -29,8 +30,8 @@ ERROR: can't-deploy-library-file library ;
: copy-libraries ( manifest name dir -- )
append-path swap libraries>> [ copy-library ] with each ;
: image-name ( vocab bundle-name -- str )
prepend-path ".image" append ;
: deployed-image-name ( vocab -- str )
".image" append temp-file ;
: copy-lines ( -- )
readln [ print flush copy-lines ] when* ;
@ -119,10 +120,12 @@ DEFER: ?make-staging-image
[ "invalid vocab manifest!" throw ] if
] if-empty ;
: make-deploy-image ( vm image vocab config -- manifest )
:: make-deploy-image-executable ( vm image vocab config -- manifest )
make-boot-image
over "vocab-manifest-" prepend temp-file
[ swap deploy-command-line run-factor ]
[ parse-vocab-manifest-file ] bi ;
vocab "vocab-manifest-" prepend temp-file :> manifest-file
image vocab manifest-file config deploy-command-line :> flags
vm flags run-factor
image vm embed-image
manifest-file parse-vocab-manifest-file ;
HOOK: deploy* os ( vocab -- )

View File

@ -1,7 +1,7 @@
! (c)2010 Joe Groff bsd license
USING: alien.c-types alien.data bootstrap.image
bootstrap.image.private destructors io io.directories
io.encodings.binary io.files locals system ;
io.encodings.binary io.files locals system kernel ;
IN: tools.deploy.embed
:: embed-image ( image executable -- )

View File

@ -7,11 +7,12 @@ tools.deploy.config.editor assocs hashtables prettyprint
io.backend.unix cocoa io.encodings.utf8 io.backend
cocoa.application cocoa.classes cocoa.plists
combinators vocabs.metadata vocabs.loader ;
QUALIFIED-WITH: tools.deploy.unix unix
IN: tools.deploy.macosx
: bundle-dir ( -- dir )
running.app?
[ vm parent-directory parent-directory ]
[ vm parent-directory parent-directory parent-directory ]
[ "resource:Factor.app" ]
if ;
@ -61,9 +62,6 @@ IN: tools.deploy.macosx
} 2cleave
dup 0o755 set-file-permissions ;
: deploy.app-image ( vocab bundle-name -- str )
[ % "/Contents/Resources/" % % ".image" % ] "" make ;
: bundle-name ( -- string )
deploy-name get ".app" append ;
@ -72,16 +70,22 @@ IN: tools.deploy.macosx
[ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
-> selectFile:inFileViewerRootedAtPath: drop ;
M: macosx deploy* ( vocab -- )
: deploy-app-bundle ( vocab -- )
"resource:" [
dup deploy-config [
bundle-name dup exists? [ delete-tree ] [ drop ] if
[ bundle-name create-app-dir ] keep
[ bundle-name deploy.app-image ] keep
namespace make-deploy-image
[ deployed-image-name ] keep
namespace make-deploy-image-executable
bundle-name
[ "Contents/Resources" copy-resources ]
[ "Contents/Frameworks" copy-libraries ] 2bi
bundle-name show-in-finder
] bind
] with-directory ;
M: macosx deploy* ( vocab -- )
! pass off to M: unix deploy* if we're building a console app
deploy-console? get
[ call-next-method ]
[ deploy-app-bundle ] if ;

View File

@ -3,6 +3,7 @@
USING: io io.backend io.directories io.files.info.unix kernel
namespaces sequences system tools.deploy.backend
tools.deploy.config tools.deploy.config.editor ;
QUALIFIED: webbrowser
IN: tools.deploy.unix
: create-app-dir ( vocab bundle-name -- vm )
@ -16,9 +17,10 @@ M: unix deploy* ( vocab -- )
"resource:" [
dup deploy-config [
[ bundle-name create-app-dir ] keep
[ bundle-name image-name ] keep
namespace make-deploy-image
[ deployed-image-name ] keep
namespace make-deploy-image-executable
bundle-name "" [ copy-resources ] [ copy-libraries ] 3bi
bundle-name normalize-path "Binary deployed to " "." surround print
bundle-name webbrowser:open-file
] bind
] with-directory ;

View File

@ -35,8 +35,8 @@ M: windows deploy*
{
[ create-exe-dir dup ]
[ drop embed-ico ]
[ image-name ]
[ drop namespace make-deploy-image ]
[ drop deployed-image-name ]
[ drop namespace make-deploy-image-executable ]
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
[ nip open-in-explorer ]
} 2cleave