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

View File

@ -1,7 +1,7 @@
! (c)2010 Joe Groff bsd license ! (c)2010 Joe Groff bsd license
USING: alien.c-types alien.data bootstrap.image USING: alien.c-types alien.data bootstrap.image
bootstrap.image.private destructors io io.directories 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 IN: tools.deploy.embed
:: embed-image ( image executable -- ) :: 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 io.backend.unix cocoa io.encodings.utf8 io.backend
cocoa.application cocoa.classes cocoa.plists cocoa.application cocoa.classes cocoa.plists
combinators vocabs.metadata vocabs.loader ; combinators vocabs.metadata vocabs.loader ;
QUALIFIED-WITH: tools.deploy.unix unix
IN: tools.deploy.macosx IN: tools.deploy.macosx
: bundle-dir ( -- dir ) : bundle-dir ( -- dir )
running.app? running.app?
[ vm parent-directory parent-directory ] [ vm parent-directory parent-directory parent-directory ]
[ "resource:Factor.app" ] [ "resource:Factor.app" ]
if ; if ;
@ -61,9 +62,6 @@ IN: tools.deploy.macosx
} 2cleave } 2cleave
dup 0o755 set-file-permissions ; dup 0o755 set-file-permissions ;
: deploy.app-image ( vocab bundle-name -- str )
[ % "/Contents/Resources/" % % ".image" % ] "" make ;
: bundle-name ( -- string ) : bundle-name ( -- string )
deploy-name get ".app" append ; deploy-name get ".app" append ;
@ -72,16 +70,22 @@ IN: tools.deploy.macosx
[ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi* [ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
-> selectFile:inFileViewerRootedAtPath: drop ; -> selectFile:inFileViewerRootedAtPath: drop ;
M: macosx deploy* ( vocab -- ) : deploy-app-bundle ( vocab -- )
"resource:" [ "resource:" [
dup deploy-config [ dup deploy-config [
bundle-name dup exists? [ delete-tree ] [ drop ] if bundle-name dup exists? [ delete-tree ] [ drop ] if
[ bundle-name create-app-dir ] keep [ bundle-name create-app-dir ] keep
[ bundle-name deploy.app-image ] keep [ deployed-image-name ] keep
namespace make-deploy-image namespace make-deploy-image-executable
bundle-name bundle-name
[ "Contents/Resources" copy-resources ] [ "Contents/Resources" copy-resources ]
[ "Contents/Frameworks" copy-libraries ] 2bi [ "Contents/Frameworks" copy-libraries ] 2bi
bundle-name show-in-finder bundle-name show-in-finder
] bind ] bind
] with-directory ; ] 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 USING: io io.backend io.directories io.files.info.unix kernel
namespaces sequences system tools.deploy.backend namespaces sequences system tools.deploy.backend
tools.deploy.config tools.deploy.config.editor ; tools.deploy.config tools.deploy.config.editor ;
QUALIFIED: webbrowser
IN: tools.deploy.unix IN: tools.deploy.unix
: create-app-dir ( vocab bundle-name -- vm ) : create-app-dir ( vocab bundle-name -- vm )
@ -16,9 +17,10 @@ M: unix deploy* ( vocab -- )
"resource:" [ "resource:" [
dup deploy-config [ dup deploy-config [
[ bundle-name create-app-dir ] keep [ bundle-name create-app-dir ] keep
[ bundle-name image-name ] keep [ deployed-image-name ] keep
namespace make-deploy-image namespace make-deploy-image-executable
bundle-name "" [ copy-resources ] [ copy-libraries ] 3bi bundle-name "" [ copy-resources ] [ copy-libraries ] 3bi
bundle-name normalize-path "Binary deployed to " "." surround print bundle-name normalize-path "Binary deployed to " "." surround print
bundle-name webbrowser:open-file
] bind ] bind
] with-directory ; ] with-directory ;

View File

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