From af2d0abb0e9226c95be6a9e96a0a2e6ed66d8352 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 31 Oct 2007 01:09:24 -0400 Subject: [PATCH] UI deploy tool --- extra/tools/deploy/config/config-docs.factor | 68 +++++---------- extra/tools/deploy/config/config.factor | 68 +++++++++------ extra/tools/deploy/deploy.factor | 15 ++-- extra/tools/deploy/shaker/shaker.factor | 41 +++------ extra/ui/tools/deploy/deploy.factor | 91 ++++++++++++++++++++ extra/ui/tools/operations/operations.factor | 5 +- 6 files changed, 177 insertions(+), 111 deletions(-) create mode 100644 extra/ui/tools/deploy/deploy.factor diff --git a/extra/tools/deploy/config/config-docs.factor b/extra/tools/deploy/config/config-docs.factor index 6f683f9c44..1528fe0015 100644 --- a/extra/tools/deploy/config/config-docs.factor +++ b/extra/tools/deploy/config/config-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax words alien.c-types assocs -kernel ; +kernel math ; IN: tools.deploy.config ARTICLE: "deploy-config" "Deployment configuration" @@ -14,17 +14,13 @@ ARTICLE: "deploy-config" "Deployment configuration" ARTICLE: "deploy-flags" "Deployment flags" "There are two types of flags. The first set controls the major subsystems which are to be included in the deployment image:" { $subsection deploy-math? } -{ $subsection deploy-compiled? } -{ $subsection deploy-io? } +{ $subsection deploy-compiler? } { $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 strip-globals? } -{ $subsection strip-word-props? } -{ $subsection strip-word-names? } -{ $subsection strip-dictionary? } -{ $subsection strip-debugger? } -{ $subsection strip-prettyprint? } -{ $subsection strip-c-types? } ; +{ $subsection deploy-io } +{ $subsection deploy-reflection } +{ $subsection deploy-word-props? } +{ $subsection deploy-c-types? } ; ARTICLE: "prepare-deploy" "Preparing to deploy an application" "In order to deploy an application as a stand-alone image, the application's vocabulary must first be given a " { $link POSTPONE: MAIN: } " hook. Then, a " { $emphasis "deployment configuration" } " must be created." @@ -33,47 +29,22 @@ ARTICLE: "prepare-deploy" "Preparing to deploy an application" ABOUT: "prepare-deploy" -HELP: strip-globals? -{ $description "Deploy flag. If set, the deploy tool applies various heuristics to strip out un-needed variables from the global namespace." +HELP: deploy-word-props? +{ $description "Deploy flag. If set, the deploy tool retains all word properties. Otherwise, it applies various heuristics to strip out un-needed word properties from words in the dictionary." $nl -"On by default. Disable this if the heuristics strip out required variables." } ; +"Off by default. Enable this if the heuristics strip out required word properties." } ; -HELP: strip-word-props? -{ $description "Deploy flag. If set, the deploy tool applies various heuristics to strip out un-needed word properties from words in the dictionary." +HELP: deploy-c-types? +{ $description "Deploy flag. If set, the deploy tool retains the " { $link c-types } " table." $nl -"On by default. Disable this if the heuristics strip out required word properties." } ; - -HELP: strip-word-names? -{ $description "Deploy flag. If set, the deploy tool strips word names from words in the dictionary." -$nl -"On by default. Disable this if your program calls " { $link word-name } "." } ; - -HELP: strip-dictionary? -{ $description "Deploy flag. If set, the deploy tool strips unused words." -$nl -"On by default. Disable this if your program calls " { $link lookup } " to look up words by name, or needs to parse code at run-time." } ; - -HELP: strip-debugger? -{ $description "Deploy flag. If set, the deploy tool strips the verbose error reporting facility; any errors thrown by the program will start the low-level debugger in the VM." -$nl -"On by default. Disable this if you need to debug a problem which only occurs when your program is running deployed." } ; - -HELP: strip-prettyprint? -{ $description "Deploy flag. If set, the deploy tool strips variables used by the prettyprinter." -$nl -"On by default. Disable this if your program uses the prettyprinter." } ; - -HELP: strip-c-types? -{ $description "Deploy flag. If set, the deploy tool strips out the " { $link c-types } " table." -$nl -"On by default. Disable this if your program calls " { $link c-type } ", " { $link heap-size } ", " { $link } ", " { $link } ", " { $link malloc-object } ", or " { $link malloc-array } " with a C type name which is not a literal pushed directly at the call site. In this situation, the compiler is unable to fold away the C type lookup, and thus must use the global table at runtime." } ; +"Off by default. Disable this if your program calls " { $link c-type } ", " { $link heap-size } ", " { $link } ", " { $link } ", " { $link malloc-object } ", or " { $link malloc-array } " with a C type name which is not a literal pushed directly at the call site. In this situation, the compiler is unable to fold away the C type lookup, and thus must use the global table at runtime." } ; HELP: deploy-math? -{ $description "Deploy flag. If set, the deployed image will contain the full number tower." +{ $description "Deploy flag. If set, the deployed image will contain support for " { $link ratio } " and " { $link complex } " types." $nl -"On by default. Most programs require the number tower, in particular, any program deployed with " { $link deploy-compiled? } " set." } ; +"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-compiled? +HELP: deploy-compiler? { $description "Deploy flag. If set, words in the deployed image will be compiled 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." } ; @@ -83,10 +54,11 @@ HELP: deploy-ui? $nl "Off by default. Programs wishing to use the UI must be deployed with this flag on." } ; -HELP: deploy-io? -{ $description "Deploy flag. If set, support for non-blocking I/O and networking will be included in the deployed image." -$nl -"Off by default. Programs wishing to use non-blocking I/O or networking must be deployed with this flag on." } ; +HELP: deploy-io +{ $description "The level of I/O support required by the deployed image." } ; + +HELP: deploy-reflection +{ $description "The level of reflection support required by the deployed image." } ; HELP: default-config { $values { "assoc" assoc } } diff --git a/extra/tools/deploy/config/config.factor b/extra/tools/deploy/config/config.factor index 2b7353ad03..db20a24cf8 100644 --- a/extra/tools/deploy/config/config.factor +++ b/extra/tools/deploy/config/config.factor @@ -1,40 +1,58 @@ ! Copyright (C) 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: vocabs.loader io.files io kernel sequences assocs -splitting parser prettyprint ; +splitting parser prettyprint namespaces math ; IN: tools.deploy.config -SYMBOL: strip-io? -SYMBOL: strip-globals? -SYMBOL: strip-word-props? -SYMBOL: strip-word-names? -SYMBOL: strip-dictionary? -SYMBOL: strip-debugger? -SYMBOL: strip-prettyprint? -SYMBOL: strip-c-types? - -SYMBOL: deploy-math? -SYMBOL: deploy-compiled? -SYMBOL: deploy-io? SYMBOL: deploy-ui? +SYMBOL: deploy-compiler? +SYMBOL: deploy-math? + +SYMBOL: deploy-io + +: deploy-io-options + { + { 1 "Level 1 - No input/output" } + { 2 "Level 2 - Basic ANSI C streams" } + { 3 "Level 3 - Non-blocking streams and networking" } + } ; + +: strip-io? deploy-io get zero? ; + +: native-io? deploy-io get 3 = ; + +SYMBOL: deploy-reflection + +: deploy-reflection-options + { + { 1 "Level 1 - No reflection" } + { 2 "Level 2 - Retain word names" } + { 3 "Level 3 - Prettyprinter" } + { 4 "Level 4 - Debugger" } + { 5 "Level 5 - Parser" } + { 6 "Level 6 - Full environment" } + } ; + +: strip-word-names? deploy-reflection get 2 < ; +: strip-prettyprint? deploy-reflection get 3 < ; +: strip-debugger? deploy-reflection get 4 < ; +: strip-dictionary? deploy-reflection get 5 < ; +: strip-globals? deploy-reflection get 6 < ; + +SYMBOL: deploy-word-props? +SYMBOL: deploy-c-types? SYMBOL: deploy-vm SYMBOL: deploy-image : default-config ( -- assoc ) V{ - { strip-io? f } - { strip-prettyprint? t } - { strip-globals? t } - { strip-word-props? t } - { strip-word-names? t } - { strip-dictionary? t } - { strip-debugger? t } - { strip-c-types? t } - { deploy-math? t } - { deploy-compiled? t } - { deploy-io? f } - { deploy-ui? f } + { deploy-io 2 } + { deploy-reflection 1 } + { deploy-compiler? t } + { deploy-math? t } + { deploy-word-props? f } + { deploy-c-types? f } ! default value for deploy.app { "stop-after-last-window?" t } } clone ; diff --git a/extra/tools/deploy/deploy.factor b/extra/tools/deploy/deploy.factor index 5701d0fa1b..2832551a34 100644 --- a/extra/tools/deploy/deploy.factor +++ b/extra/tools/deploy/deploy.factor @@ -30,13 +30,16 @@ IN: tools.deploy dup duplex-stream-out stream-close copy-lines ; +: ?append swap [ append ] [ drop ] if ; + : profile-string ( config -- string ) - { - { deploy-math? "math" } - { deploy-compiled? "compiler" } - { deploy-ui? "ui" } - { deploy-io? "io" } - } swap [ nip at ] curry assoc-subset values " " join ; + [ + "" + deploy-math? get " math" ?append + deploy-compiler? get " compiler" ?append + native-io? " io" ?append + deploy-ui? get " ui" ?append + ] bind ; : deploy-command-line ( vm image vocab config -- vm flags ) [ diff --git a/extra/tools/deploy/shaker/shaker.factor b/extra/tools/deploy/shaker/shaker.factor index d19c8f4a2b..73c00cbd50 100644 --- a/extra/tools/deploy/shaker/shaker.factor +++ b/extra/tools/deploy/shaker/shaker.factor @@ -16,10 +16,10 @@ IN: tools.deploy.shaker : strip-init-hooks ( -- ) "Stripping startup hooks" show "command-line" init-hooks get delete-at - strip-io? get [ "io.backend" init-hooks get delete-at ] when ; + strip-io? [ "io.backend" init-hooks get delete-at ] when ; : strip-debugger ( -- ) - strip-debugger? get [ + strip-debugger? [ "Stripping debugger" show "resource:extra/tools/deploy/shaker/strip-debugger.factor" run-file @@ -65,23 +65,13 @@ IN: tools.deploy.shaker : strip-words ( props -- ) [ word? ] instances - strip-word-props? get [ tuck strip-word-props ] [ nip ] if - strip-word-names? get [ dup strip-word-names ] when + deploy-word-props? get [ nip ] [ tuck strip-word-props ] if + strip-word-names? [ dup strip-word-names ] when strip-word-defs ; -USING: bit-arrays byte-arrays io.streams.nested ; - -: strip-classes ( -- ) - "Stripping classes" show - io-backend get [ - c-reader forget - c-writer forget - ] when - { style-stream mirror enum } [ forget ] each ; - : strip-environment ( retain-globals -- ) "Stripping environment" show - strip-globals? get [ + strip-globals? [ global strip-assoc 21 setenv ] [ drop ] if ; @@ -103,16 +93,16 @@ SYMBOL: deploy-vocab \ boot , init-hooks get values concat % , - strip-io? get [ \ flush , ] unless + strip-io? [ \ flush , ] unless ] [ ] make "Boot quotation: " write dup . flush set-boot-quot ; : retained-globals ( -- seq ) [ builtins , - strip-io? get [ io-backend , ] unless + strip-io? [ io-backend , ] unless - strip-dictionary? get [ + strip-dictionary? [ { builtins dictionary @@ -129,14 +119,14 @@ SYMBOL: deploy-vocab } % ] unless - strip-prettyprint? get [ + strip-prettyprint? [ { tab-size margin } % ] unless - strip-c-types? get not deploy-ui? get or [ + deploy-c-types? get deploy-ui? get or [ "c-types" "alien.c-types" lookup , ] when @@ -150,18 +140,7 @@ SYMBOL: deploy-vocab ] when ] { } make dup . ; -: normalize-strip-flags - strip-prettyprint? get [ - strip-word-names? off - ] unless - strip-dictionary? get [ - strip-prettyprint? off - strip-word-names? off - strip-word-props? off - ] unless ; - : strip ( -- ) - normalize-strip-flags strip-cocoa strip-debugger strip-init-hooks diff --git a/extra/ui/tools/deploy/deploy.factor b/extra/ui/tools/deploy/deploy.factor new file mode 100644 index 0000000000..3214b84d93 --- /dev/null +++ b/extra/ui/tools/deploy/deploy.factor @@ -0,0 +1,91 @@ +! Copyright (C) 2007 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: ui.gadgets colors kernel ui.render namespaces +ui.gadgets.controls models sequences ui.gadgets.buttons +ui.gadgets.packs ui.gadgets.labels tools.deploy.config +namespaces ui.gadgets.editors ui.gadgets.borders ui.gestures +ui.commands assocs ui.gadgets.tracks ui ui.tools.listener +tools.deploy.app vocabs ; +IN: ui.tools.deploy + +TUPLE: deploy-gadget vocab settings ; + +: bundle-name ( -- ) + "bundle-name" get "Bundle name:" label-on-left gadget, ; + +: exit-when-windows-closed ( -- ) + "stop-after-last-window?" get + "Exit when last UI window closed" gadget, ; + +: io-settings ( -- ) + "Input/output support:"