| 
									
										
										
										
											2010-02-17 09:57:10 -05:00
										 |  |  | ! Copyright (C) 2007, 2010 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2008-09-10 21:07:00 -04:00
										 |  |  | USING: namespaces make continuations.private kernel.private init | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | assocs kernel vocabs words sequences memory io system arrays | 
					
						
							|  |  |  | continuations math definitions mirrors splitting parser classes | 
					
						
							| 
									
										
										
										
											2009-04-26 03:42:37 -04:00
										 |  |  | summary layouts vocabs.loader prettyprint.config prettyprint debugger | 
					
						
							|  |  |  | 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 | 
					
						
							| 
									
										
										
										
											2010-02-14 14:29:37 -05:00
										 |  |  | io.encodings.utf8 destructors accessors hashtables | 
					
						
							| 
									
										
										
										
											2011-11-21 14:44:27 -05:00
										 |  |  | tools.deploy.libraries vocabs.metadata.resources | 
					
						
							|  |  |  | tools.deploy.embed locals ;
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | IN: tools.deploy.backend | 
					
						
							| 
									
										
										
										
											2008-05-10 16:22:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-28 02:57:46 -05:00
										 |  |  | : copy-vm ( executable bundle-name -- vm )
 | 
					
						
							| 
									
										
										
										
											2009-02-09 21:19:18 -05:00
										 |  |  |     prepend-path vm over copy-file ;
 | 
					
						
							| 
									
										
										
										
											2008-05-10 16:22:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-16 16:32:14 -05:00
										 |  |  | TUPLE: vocab-manifest vocabs libraries ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-14 14:29:37 -05:00
										 |  |  | : copy-resources ( manifest name dir -- )
 | 
					
						
							| 
									
										
										
										
											2010-02-16 16:32:14 -05:00
										 |  |  |     append-path swap vocabs>> [ copy-vocab-resources ] with each ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-17 09:57:10 -05:00
										 |  |  | ERROR: can't-deploy-library-file library ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-16 16:32:14 -05:00
										 |  |  | : copy-library ( dir library -- )
 | 
					
						
							|  |  |  |     dup find-library-file | 
					
						
							| 
									
										
										
										
											2010-02-17 09:57:10 -05:00
										 |  |  |     [ swap over file-name append-path copy-file ] | 
					
						
							|  |  |  |     [ can't-deploy-library-file ] ?if ;
 | 
					
						
							| 
									
										
										
										
											2010-02-16 16:32:14 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : copy-libraries ( manifest name dir -- )
 | 
					
						
							|  |  |  |     append-path swap libraries>> [ copy-library ] with each ;
 | 
					
						
							| 
									
										
										
										
											2008-05-10 16:22:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-21 14:44:27 -05:00
										 |  |  | : deployed-image-name ( vocab -- str )
 | 
					
						
							|  |  |  |     ".image" append temp-file ;
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-18 19:20:26 -04:00
										 |  |  | : copy-lines ( -- )
 | 
					
						
							|  |  |  |     readln [ print flush copy-lines ] when* ;
 | 
					
						
							| 
									
										
										
										
											2008-01-29 03:03:06 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-03 21:36:04 -05:00
										 |  |  | : run-with-output ( arguments -- )
 | 
					
						
							| 
									
										
										
										
											2008-03-06 21:44:52 -05:00
										 |  |  |     <process> | 
					
						
							|  |  |  |         swap >>command | 
					
						
							|  |  |  |         +stdout+ >>stderr | 
					
						
							|  |  |  |         +closed+ >>stdin | 
					
						
							| 
									
										
										
										
											2008-03-26 16:59:11 -04:00
										 |  |  |         +low-priority+ >>priority | 
					
						
							| 
									
										
										
										
											2008-09-18 19:20:26 -04:00
										 |  |  |     utf8 [ copy-lines ] with-process-reader ;
 | 
					
						
							| 
									
										
										
										
											2008-01-29 03:03:06 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : make-boot-image ( -- )
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  |     #! If stage1 image doesn't exist, create one. | 
					
						
							| 
									
										
										
										
											2008-02-07 18:55:31 -05:00
										 |  |  |     my-boot-image-name resource-path exists? | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  |     [ my-arch make-image ] unless ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-13 04:46:25 -04:00
										 |  |  | : bootstrap-profile ( -- profile )
 | 
					
						
							| 
									
										
										
										
											2009-05-11 01:32:22 -04:00
										 |  |  |     [ | 
					
						
							|  |  |  |         deploy-math? get [ "math" , ] when
 | 
					
						
							|  |  |  |         deploy-threads? get [ "threads" , ] when
 | 
					
						
							|  |  |  |         "compiler" , | 
					
						
							| 
									
										
										
										
											2011-08-04 17:27:29 -04:00
										 |  |  |         deploy-help? get [ "help" , ] when
 | 
					
						
							| 
									
										
										
										
											2009-05-11 01:32:22 -04:00
										 |  |  |         deploy-ui? get [ "ui" , ] when
 | 
					
						
							|  |  |  |         deploy-unicode? get [ "unicode" , ] when
 | 
					
						
							|  |  |  |         native-io? [ "io" , ] when
 | 
					
						
							|  |  |  |     ] { } make ;
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  | : staging-image-name ( profile -- name )
 | 
					
						
							| 
									
										
										
										
											2012-06-19 20:13:33 -04:00
										 |  |  |     "-" join "." my-arch 3append
 | 
					
						
							|  |  |  |     "staging." ".image" surround cache-file ;
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  | DEFER: ?make-staging-image | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : staging-command-line ( profile -- flags )
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  |     [ | 
					
						
							| 
									
										
										
										
											2008-11-22 20:58:05 -05:00
										 |  |  |         "-staging" , | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  |         dup empty? [ | 
					
						
							| 
									
										
										
										
											2008-03-13 04:46:25 -04:00
										 |  |  |             "-i=" my-boot-image-name append , | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  |         ] [ | 
					
						
							| 
									
										
										
										
											2008-05-07 02:38:34 -04:00
										 |  |  |             dup but-last ?make-staging-image | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  |             "-resource-path=" "" resource-path append , | 
					
						
							| 
									
										
										
										
											2008-05-07 02:38:34 -04:00
										 |  |  |             "-i=" over but-last staging-image-name append , | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  |             "-run=tools.deploy.restage" , | 
					
						
							|  |  |  |         ] if
 | 
					
						
							|  |  |  |         "-output-image=" over staging-image-name append , | 
					
						
							|  |  |  |         "-include=" swap " " join append , | 
					
						
							|  |  |  |         "-no-user-init" , | 
					
						
							| 
									
										
										
										
											2009-12-02 06:33:22 -05:00
										 |  |  |         "-pic=0" , | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  |     ] { } make ;
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-29 03:03:06 -05:00
										 |  |  | : run-factor ( vm flags -- )
 | 
					
						
							| 
									
										
										
										
											2008-03-31 20:18:05 -04:00
										 |  |  |     swap prefix dup . run-with-output ; inline
 | 
					
						
							| 
									
										
										
										
											2008-01-29 03:03:06 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  | : make-staging-image ( profile -- )
 | 
					
						
							| 
									
										
										
										
											2008-03-14 18:39:57 -04:00
										 |  |  |     vm swap staging-command-line run-factor ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  | : ?make-staging-image ( profile -- )
 | 
					
						
							|  |  |  |     dup staging-image-name exists? | 
					
						
							| 
									
										
										
										
											2008-03-14 18:39:57 -04:00
										 |  |  |     [ drop ] [ make-staging-image ] if ;
 | 
					
						
							| 
									
										
										
										
											2008-01-29 03:03:06 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-08 15:58:00 -05:00
										 |  |  | : make-deploy-config ( vocab -- file )
 | 
					
						
							| 
									
										
										
										
											2009-04-07 22:47:57 -04:00
										 |  |  |     [ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ] | 
					
						
							| 
									
										
										
										
											2008-12-08 17:02:31 -05:00
										 |  |  |     [ "deploy-config-" prepend temp-file ] bi
 | 
					
						
							| 
									
										
										
										
											2008-12-08 15:58:00 -05:00
										 |  |  |     [ utf8 set-file-contents ] keep ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-14 14:29:37 -05:00
										 |  |  | : deploy-command-line ( image vocab manifest-file config -- flags )
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  |     [ | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  |         bootstrap-profile ?make-staging-image | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-13 04:46:25 -04:00
										 |  |  |         [ | 
					
						
							| 
									
										
										
										
											2008-03-20 22:11:53 -04:00
										 |  |  |             "-i=" bootstrap-profile staging-image-name append , | 
					
						
							|  |  |  |             "-resource-path=" "" resource-path append , | 
					
						
							| 
									
										
										
										
											2008-03-13 04:46:25 -04:00
										 |  |  |             "-run=tools.deploy.shaker" , | 
					
						
							| 
									
										
										
										
											2010-02-14 14:29:37 -05:00
										 |  |  |             "-vocab-manifest-out=" prepend , | 
					
						
							| 
									
										
										
										
											2008-12-08 15:58:00 -05:00
										 |  |  |             [ "-deploy-vocab=" prepend , ] | 
					
						
							|  |  |  |             [ make-deploy-config "-deploy-config=" prepend , ] bi
 | 
					
						
							| 
									
										
										
										
											2008-03-19 20:15:32 -04:00
										 |  |  |             "-output-image=" prepend , | 
					
						
							| 
									
										
										
										
											2009-12-02 06:33:22 -05:00
										 |  |  |             "-pic=0" , | 
					
						
							| 
									
										
										
										
											2008-03-13 04:46:25 -04:00
										 |  |  |         ] { } make | 
					
						
							|  |  |  |     ] bind ;
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-16 16:32:14 -05:00
										 |  |  | : parse-vocab-manifest-file ( path -- vocab-manifest )
 | 
					
						
							| 
									
										
										
										
											2011-11-06 21:57:12 -05:00
										 |  |  |     utf8 file-lines [ "empty vocab manifest!" throw ] [ | 
					
						
							|  |  |  |         unclip-slice "VOCABS:" =
 | 
					
						
							|  |  |  |         [ { "LIBRARIES:" } split1 vocab-manifest boa ] | 
					
						
							|  |  |  |         [ "invalid vocab manifest!" throw ] if
 | 
					
						
							|  |  |  |     ] if-empty ;
 | 
					
						
							| 
									
										
										
										
											2010-02-16 16:32:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-21 17:20:57 -05:00
										 |  |  | :: make-deploy-image ( vm image vocab config -- manifest )
 | 
					
						
							| 
									
										
										
										
											2008-02-04 21:49:59 -05:00
										 |  |  |     make-boot-image | 
					
						
							| 
									
										
										
										
											2011-11-21 14:44:27 -05:00
										 |  |  |     vocab "vocab-manifest-" prepend temp-file :> manifest-file | 
					
						
							|  |  |  |     image vocab manifest-file config deploy-command-line :> flags | 
					
						
							|  |  |  |     vm flags run-factor | 
					
						
							|  |  |  |     manifest-file parse-vocab-manifest-file ;
 | 
					
						
							| 
									
										
										
										
											2008-01-05 19:37:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-21 17:20:57 -05:00
										 |  |  | :: make-deploy-image-executable ( vm image vocab config -- manifest )
 | 
					
						
							|  |  |  |     vm image vocab config make-deploy-image | 
					
						
							|  |  |  |     image vm embed-image ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-02 20:46:37 -04:00
										 |  |  | HOOK: deploy* os ( vocab -- )
 |