]> gitweb.factorcode.org Git - factor.git/commitdiff
Improve deployment tool
authorSlava Pestov <slava@oberon.internal.stack-effects.com>
Fri, 21 Mar 2008 02:11:53 +0000 (21:11 -0500)
committerSlava Pestov <slava@oberon.internal.stack-effects.com>
Fri, 21 Mar 2008 02:11:53 +0000 (21:11 -0500)
13 files changed:
extra/bunny/deploy.factor
extra/hello-ui/deploy.factor
extra/hello-world/deploy.factor
extra/sudoku/deploy.factor
extra/tools/deploy/backend/backend.factor
extra/tools/deploy/config/config-docs.factor
extra/tools/deploy/config/config.factor
extra/tools/deploy/restage/restage.factor [new file with mode: 0644]
extra/tools/deploy/shaker/shaker.factor
extra/tools/deploy/test/1/deploy.factor
extra/tools/deploy/test/2/deploy.factor
extra/tools/deploy/test/3/deploy.factor
extra/ui/tools/deploy/deploy.factor

index a3f61747266e30a8d093cef8e4fa194d88a91e05..643737b23c9af9561209ea8f079db09fe93d5d87 100755 (executable)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-math? t }
-    { deploy-reflection 1 }
+    { deploy-word-defs? f }
+    { deploy-random? f }
     { deploy-name "Bunny" }
     { deploy-threads? t }
-    { deploy-word-props? f }
-    { "stop-after-last-window?" t }
-    { deploy-ui? t }
-    { deploy-io 3 }
     { deploy-compiler? t }
-    { deploy-word-defs? f }
+    { deploy-math? t }
     { deploy-c-types? f }
+    { deploy-io 3 }
+    { deploy-reflection 1 }
+    { deploy-ui? t }
+    { "stop-after-last-window?" t }
+    { deploy-word-props? f }
 }
index 43d8ca21efd878c7d10defa5c6b747ce9256ab79..0ec9c1950311df3fad2bba44bf9e1db342872af7 100755 (executable)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-io 1 }
-    { deploy-compiler? t }
     { deploy-word-defs? f }
-    { deploy-word-props? f }
-    { deploy-math? t }
+    { deploy-random? t }
     { deploy-name "Hello world" }
-    { deploy-c-types? f }
-    { deploy-ui? t }
     { deploy-threads? t }
+    { deploy-compiler? t }
+    { deploy-math? t }
+    { deploy-c-types? f }
+    { deploy-io 1 }
     { deploy-reflection 1 }
+    { deploy-ui? t }
     { "stop-after-last-window?" t }
+    { deploy-word-props? f }
 }
index 2341aabc9ddf302ff44eb74f7b1c7d92f8365835..77421938a986b5182c712bfc2c3cdfc68dd2717f 100755 (executable)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
+    { deploy-word-defs? f }
+    { deploy-random? f }
     { deploy-name "Hello world (console)" }
     { deploy-threads? f }
-    { deploy-c-types? f }
     { deploy-compiler? f }
-    { deploy-ui? f }
     { deploy-math? f }
-    { deploy-reflection 1 }
-    { deploy-word-defs? f }
+    { deploy-c-types? f }
     { deploy-io 2 }
-    { deploy-word-props? f }
+    { deploy-reflection 1 }
+    { deploy-ui? f }
     { "stop-after-last-window?" t }
+    { deploy-word-props? f }
 }
index 11a06f46bc685bd9e1c0a020f2668f892d4a436f..ba1ac1a32a69372ae47c15658a12c0b35cfbd5f1 100755 (executable)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
+    { deploy-word-defs? f }
+    { deploy-random? f }
     { deploy-name "Sudoku" }
     { deploy-threads? f }
-    { deploy-c-types? f }
     { deploy-compiler? t }
-    { deploy-ui? f }
     { deploy-math? f }
-    { deploy-reflection 1 }
-    { deploy-word-defs? f }
+    { deploy-c-types? f }
     { deploy-io 2 }
-    { deploy-word-props? f }
+    { deploy-reflection 1 }
+    { deploy-ui? f }
     { "stop-after-last-window?" t }
+    { deploy-word-props? f }
 }
index 2476077ba90283e1873393aac240954aae94a355..172a80b612abdcec46e98abe3b9ba142f6887105 100755 (executable)
@@ -40,42 +40,57 @@ IN: tools.deploy.backend
         "compiler" deploy-compiler? get ?,
         "ui" deploy-ui? get ?,
         "io" native-io? ?,
+        "random" deploy-random? get ?,
     ] { } make ;
 
-: staging-image-name ( -- name )
+: staging-image-name ( profile -- name )
     "staging."
-    bootstrap-profile strip-word-names? [ "strip" add ] when
-    "-" join ".image" 3append ;
+    swap strip-word-names? [ "strip" add ] when
+    "-" join ".image" 3append temp-file ;
 
-: staging-command-line ( config -- flags )
+DEFER: ?make-staging-image
+
+: staging-command-line ( profile -- flags )
     [
-        [
+        dup empty? [
             "-i=" my-boot-image-name append ,
+        ] [
+            dup 1 head* ?make-staging-image
 
-            "-output-image=" staging-image-name append ,
+            "-resource-path=" "" resource-path append ,
 
-            "-include=" bootstrap-profile " " join append ,
+            "-i=" over 1 head* staging-image-name append ,
 
-            strip-word-names? [ "-no-stack-traces" , ] when
+            "-run=tools.deploy.restage" ,
+        ] if
 
-            "-no-user-init" ,
-        ] { } make
-    ] bind ;
+        "-output-image=" over staging-image-name append ,
+
+        "-include=" swap " " join append ,
+
+        strip-word-names? [ "-no-stack-traces" , ] when
+
+        "-no-user-init" ,
+    ] { } make ;
 
 : run-factor ( vm flags -- )
     swap add* dup . run-with-output ; inline
 
-: make-staging-image ( config -- )
+: make-staging-image ( profile -- )
     vm swap staging-command-line run-factor ;
 
-: ?make-staging-image ( config -- )
-    dup [ staging-image-name ] bind exists?
+: ?make-staging-image ( profile -- )
+    dup staging-image-name exists?
     [ drop ] [ make-staging-image ] if ;
 
 : deploy-command-line ( image vocab config -- flags )
     [
+        bootstrap-profile ?make-staging-image
+
         [
-            "-i=" staging-image-name append ,
+            "-i=" bootstrap-profile staging-image-name append ,
+
+            "-resource-path=" "" resource-path append ,
 
             "-run=tools.deploy.shaker" ,
 
@@ -89,7 +104,6 @@ IN: tools.deploy.backend
 
 : make-deploy-image ( vm image vocab config -- )
     make-boot-image
-    dup ?make-staging-image
     deploy-command-line run-factor ;
 
 SYMBOL: deploy-implementation
index 846bb5c274729b6e1ff5b9370d263f738e3840dd..4af1219daf27b0ad4fe00538c7efacccb9ecd789 100755 (executable)
@@ -16,6 +16,8 @@ ARTICLE: "deploy-flags" "Deployment flags"
 "There are two sets of deployment flags. The first set controls the major subsystems which are to be included in the deployment image:"
 { $subsection deploy-math?     }
 { $subsection deploy-compiler? }
+{ $subsection deploy-random?   }
+{ $subsection deploy-threads?  }
 { $subsection deploy-ui?       }
 "The second set of flags controls the level of stripping to be performed on the deployment image; there is a trade-off between image size, and retaining functionality which is required by the application:"
 { $subsection deploy-io          }
@@ -66,16 +68,21 @@ HELP: deploy-math?
 $nl
 "On by default. Often the programmer will use rationals without realizing it. A small amount of space can be saved by stripping these features out, but some code may require changes to work properly." } ;
 
-HELP: deploy-threads?
-{ $description "Deploy flag. If set, the deployed image will contain support for threads."
-$nl
-"On by default. Often the programmer will use threads without realizing it. A small amount of space can be saved by stripping this feature out, but some code may require changes to work properly." } ;
-
 HELP: deploy-compiler?
 { $description "Deploy flag. If set, words in the deployed image will be compiled with the optimizing compiler when possible."
 $nl
 "On by default. Most programs should be compiled, not only for performance but because features which depend on the C library interface only function after compilation." } ;
 
+HELP: deploy-random?
+{ $description "Deploy flag. If set, the random number generator protocol is included, together with two implementations: a native OS-specific random number generator, and the Mersenne Twister."
+$nl
+"On by default. If your program does not generate random numbers you can disable this to save some space." } ;
+
+HELP: deploy-threads?
+{ $description "Deploy flag. If set, thread support will be included in the final image."
+$nl
+"On by default. Most programs depend on libraries which use threads even if they don't use threads directly; for example, alarms, non-blocking I/O, and the UI are built on top of threads. If after testing your program still works without threads, you can disable this feature to save some space." } ;
+
 HELP: deploy-ui?
 { $description "Deploy flag. If set, the Factor UI will be included in the deployed image."
 $nl
index c527cb945c89fd08a78077b4c993f68422ef0a30..7ebedf7ca14f130a96714b41033a812c9abceeea 100755 (executable)
@@ -10,6 +10,7 @@ SYMBOL: deploy-name
 SYMBOL: deploy-ui?
 SYMBOL: deploy-compiler?
 SYMBOL: deploy-math?
+SYMBOL: deploy-random?
 SYMBOL: deploy-threads?
 
 SYMBOL: deploy-io
@@ -57,6 +58,7 @@ SYMBOL: deploy-image
         { deploy-reflection         1 }
         { deploy-compiler?          t }
         { deploy-threads?           t }
+        { deploy-random?            t }
         { deploy-math?              t }
         { deploy-word-props?        f }
         { deploy-word-defs?         f }
diff --git a/extra/tools/deploy/restage/restage.factor b/extra/tools/deploy/restage/restage.factor
new file mode 100644 (file)
index 0000000..c75abf9
--- /dev/null
@@ -0,0 +1,8 @@
+IN: tools.deploy.restage
+USING: bootstrap.stage2 namespaces memory ;
+
+: restage ( -- )
+    load-components
+    "output-image" get save-image-and-exit ;
+
+MAIN: restage
index d31a3460ca810f0e7c200b3e8c89efcc5feefbe6..76e4a212b209a0d62ac0e007a346ce9f0ee14a76 100755 (executable)
@@ -19,7 +19,6 @@ QUALIFIED: libc.private
 QUALIFIED: libc.private
 QUALIFIED: listener
 QUALIFIED: prettyprint.config
-QUALIFIED: random
 QUALIFIED: source-files
 QUALIFIED: threads
 QUALIFIED: vocabs
@@ -108,8 +107,6 @@ IN: tools.deploy.shaker
 
 : stripped-globals ( -- seq )
     [
-        random:random-generator ,
-
         {
             bootstrap.stage2:bootstrap-time
             continuations:error
@@ -145,12 +142,14 @@ IN: tools.deploy.shaker
                 vocabs:dictionary
                 lexer-factory
                 vocabs:load-vocab-hook
+                root-cache
                 layouts:num-tags
                 layouts:num-types
                 layouts:tag-mask
                 layouts:tag-numbers
                 layouts:type-numbers
                 classes:typemap
+                classes:class-map
                 vocab-roots
                 definitions:crossref
                 compiled-crossref
index f06bcbc0f0737b89d973f8b3a8452ed34d51e7c8..490c21a067c34856e786bdf5b130950d8d9a5702 100755 (executable)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-c-types? f }
-    { deploy-io 2 }
-    { deploy-reflection 1 }
-    { deploy-threads? t }
-    { deploy-word-props? f }
     { deploy-word-defs? f }
+    { deploy-random? f }
     { deploy-name "tools.deploy.test.1" }
-    { deploy-math? t }
+    { deploy-threads? t }
     { deploy-compiler? t }
-    { "stop-after-last-window?" t }
+    { deploy-math? t }
+    { deploy-c-types? f }
+    { deploy-io 2 }
+    { deploy-reflection 1 }
     { deploy-ui? f }
+    { "stop-after-last-window?" t }
+    { deploy-word-props? f }
 }
index bd087d65bf2478a72b2f91dc572b2fe674cb1838..b8c37af20a01dac1ce9a2440ee1ae847afd663cb 100755 (executable)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-c-types? f }
-    { deploy-io 2 }
-    { deploy-reflection 1 }
-    { deploy-threads? t }
-    { deploy-word-props? f }
     { deploy-word-defs? f }
+    { deploy-random? f }
     { deploy-name "tools.deploy.test.2" }
-    { deploy-math? t }
+    { deploy-threads? t }
     { deploy-compiler? t }
-    { "stop-after-last-window?" t }
+    { deploy-math? t }
+    { deploy-c-types? f }
+    { deploy-io 2 }
+    { deploy-reflection 1 }
     { deploy-ui? f }
+    { "stop-after-last-window?" t }
+    { deploy-word-props? f }
 }
index b8b8bf4aa2dbfedbb0f20865a3b2b4238c3a7373..dde82916585de0f1e7ca2a08e2a7281ba7ea0942 100755 (executable)
@@ -1,14 +1,15 @@
 USING: tools.deploy.config ;
 H{
-    { deploy-math? t }
-    { deploy-reflection 1 }
+    { deploy-word-defs? f }
+    { deploy-random? f }
     { deploy-name "tools.deploy.test.3" }
     { deploy-threads? t }
-    { deploy-word-props? f }
-    { "stop-after-last-window?" t }
-    { deploy-ui? f }
-    { deploy-io 3 }
     { deploy-compiler? t }
-    { deploy-word-defs? f }
+    { deploy-math? t }
     { deploy-c-types? f }
+    { deploy-io 3 }
+    { deploy-reflection 1 }
+    { deploy-ui? f }
+    { "stop-after-last-window?" t }
+    { deploy-word-props? f }
 }
index 9aa763d7ec7a73826551f7e569794e6a62f0a207..eca5740bbc2f43a166f9f01bf6a18afa31ba9475 100755 (executable)
@@ -35,6 +35,7 @@ TUPLE: deploy-gadget vocab settings ;
     deploy-compiler? get "Use optimizing compiler" <checkbox> gadget,
     deploy-math? get "Rational and complex number support" <checkbox> gadget,
     deploy-threads? get "Threading support" <checkbox> gadget,
+    deploy-random? get "Random number generator support" <checkbox> gadget,
     deploy-word-props? get "Retain all word properties" <checkbox> gadget,
     deploy-word-defs? get "Retain all word definitions" <checkbox> gadget,
     deploy-c-types? get "Retain all C types" <checkbox> gadget, ;