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 ;
+io.encodings.utf8 destructors accessors hashtables
+vocabs.metadata.resources ;
IN: tools.deploy.backend
: copy-vm ( executable bundle-name -- vm )
prepend-path vm over copy-file ;
-CONSTANT: theme-path "basis/ui/gadgets/theme/"
-
-: copy-theme ( name dir -- )
- deploy-ui? get [
- append-path
- theme-path append-path
- [ make-directories ]
- [ theme-path "resource:" prepend swap copy-tree ] bi
- ] [ 2drop ] if ;
+: copy-resources ( manifest name dir -- )
+ append-path swap [ copy-vocab-resources ] with each ;
: image-name ( vocab bundle-name -- str )
prepend-path ".image" append ;
[ "deploy-config-" prepend temp-file ] bi
[ utf8 set-file-contents ] keep ;
-: deploy-command-line ( image vocab config -- flags )
+: deploy-command-line ( image vocab manifest-file config -- flags )
[
bootstrap-profile ?make-staging-image
"-i=" bootstrap-profile staging-image-name append ,
"-resource-path=" "" resource-path append ,
"-run=tools.deploy.shaker" ,
+ "-vocab-manifest-out=" prepend ,
[ "-deploy-vocab=" prepend , ]
[ make-deploy-config "-deploy-config=" prepend , ] bi
"-output-image=" prepend ,
] { } make
] bind ;
-: make-deploy-image ( vm image vocab config -- )
+: make-deploy-image ( vm image vocab config -- manifest )
make-boot-image
- deploy-command-line run-factor ;
+ over "vocab-manifest-" prepend temp-file
+ [ swap deploy-command-line run-factor ]
+ [ utf8 file-lines ] bi ;
HOOK: deploy* os ( vocab -- )
[ copy-dll ]
[ copy-nib ]
[ "Contents/Resources" append-path make-directories ]
- [ "Contents/Resources" copy-theme ]
} cleave
]
[ create-app-plist ]
[ bundle-name create-app-dir ] keep
[ bundle-name deploy.app-image ] keep
namespace make-deploy-image
+ bundle-name "Contents/Resources" copy-resources
bundle-name show-in-finder
] bind
] with-directory ;
! Copyright (C) 2007, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: arrays accessors io.backend io.streams.c init fry
-namespaces math make assocs kernel parser parser.notes lexer
-strings.parser vocabs sequences sequences.deep sequences.private
-words memory kernel.private continuations io vocabs.loader
-system strings sets vectors quotations byte-arrays sorting
-compiler.units definitions generic generic.standard
+USING: arrays accessors io.backend io.encodings.utf8 io.files
+io.streams.c init fry namespaces math make assocs kernel parser
+parser.notes lexer strings.parser vocabs sequences sequences.deep
+sequences.private words memory kernel.private continuations io
+vocabs.loader system strings sets vectors quotations byte-arrays
+sorting compiler.units definitions generic generic.standard
generic.single tools.deploy.config combinators classes
classes.builtin slots.private grouping command-line ;
QUALIFIED: bootstrap.stage2
: startup-stripper ( -- )
t "quiet" set-global
- f output-stream set-global ;
+ f output-stream set-global
+ V{ "resource:" } clone vocab-roots set-global ;
: next-method* ( method -- quot )
[ "method-class" word-prop ]
"Clearing megamorphic caches" show
[ clear-megamorphic-cache ] each ;
-: strip ( -- )
+: write-vocab-manifest ( vocab-manifest-out -- )
+ "Writing vocabulary manifest to " write dup print flush
+ vocabs swap utf8 set-file-lines ;
+
+: strip ( vocab-manifest-out -- )
+ [ write-vocab-manifest ] when*
startup-stripper
strip-libc
strip-destructors
1 exit
] recover ; inline
-: (deploy) ( final-image vocab config -- )
+: (deploy) ( final-image vocab-manifest-out vocab config -- )
#! Does the actual work of a deployment in the slave
#! stage2 image
[
"ui.debugger" require
] when
] unless
- deploy-vocab set
- deploy-vocab get require
- deploy-vocab get vocab-main [
- "Vocabulary has no MAIN: word." print flush 1 exit
- ] unless
+ [ deploy-vocab set ] [ require ] [
+ vocab-main [
+ "Vocabulary has no MAIN: word." print flush 1 exit
+ ] unless
+ ] tri
strip
"Saving final image" show
save-image-and-exit
: do-deploy ( -- )
"output-image" get
+ "vocab-manifest-out" get
"deploy-vocab" get
"Deploying " write dup write "..." print
"deploy-config" get parse-file first
IN: vocabs.metadata.resources
<PRIVATE
+
: (expand-vocab-resource) ( resource-path -- filenames )
dup file-info directory?
[ dup '[ _ directory-tree-files [ append-path ] with map ] [ prefix ] bi ]
: filter-resources ( vocab-files resource-globs -- resource-files )
'[ _ [ matches? ] with any? ] filter ;
+
+: copy-vocab-resource ( to from file -- )
+ [ append-path ] curry bi@
+ dup file-info directory?
+ [ drop make-directories ]
+ [ swap [ parent-directory make-directories ] [ copy-file ] bi ] if ;
+
PRIVATE>
+: vocab-dir-in-root ( vocab -- dir )
+ [ find-vocab-root ] [ vocab-dir ] bi append-path ;
+
: expand-vocab-resource-files ( vocab resource-glob-strings -- filenames )
- [ [ find-vocab-root ] [ vocab-dir ] bi append-path ] dip [ <glob> ] map '[
+ [ vocab-dir-in-root ] dip [ <glob> ] map '[
_ filter-resources
[ (expand-vocab-resource) ] map concat
] with-directory-tree-files ;
: vocab-resource-files ( vocab -- filenames )
dup vocab-resources
[ drop f ] [ expand-vocab-resource-files ] if-empty ;
+
+: copy-vocab-resources ( dir vocab -- )
+ dup vocab-resource-files
+ [ 2drop ] [
+ [ [ vocab-dir append-path P ] [ vocab-dir-in-root P ] bi ] dip
+ [ 2drop make-directories ]
+ [ [ copy-vocab-resource ] with with each ] 3bi
+ ] if-empty ;
+