From 047be9cd5209c70e9f21b9b338883844f8a117d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sat, 2 Apr 2016 04:56:04 +0200 Subject: [PATCH] tools.deploy.*: refactoring to not use dynamic variables in make-deploy-image --- .../tools/deploy/backend/backend-tests.factor | 2 +- basis/tools/deploy/backend/backend.factor | 43 ++++++------------- basis/tools/deploy/config/config-tests.factor | 6 +++ basis/tools/deploy/config/config.factor | 14 +++++- basis/tools/deploy/deploy-tests.factor | 8 ++-- 5 files changed, 36 insertions(+), 37 deletions(-) create mode 100644 basis/tools/deploy/config/config-tests.factor diff --git a/basis/tools/deploy/backend/backend-tests.factor b/basis/tools/deploy/backend/backend-tests.factor index b47bfc3b3e..0a31795329 100644 --- a/basis/tools/deploy/backend/backend-tests.factor +++ b/basis/tools/deploy/backend/backend-tests.factor @@ -1,4 +1,4 @@ -USING: kernel pcre sequences tools.deploy.backend tools.test ; +USING: pcre sequences tools.deploy.backend tools.test ; IN: tools.deploy.backend.tests : complete-match? ( str regexp -- ? ) diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index ccd2e0c6bf..90db441dc6 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -1,15 +1,10 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces make continuations.private kernel.private init -assocs kernel vocabs words sequences memory io system arrays -continuations math definitions mirrors splitting parser classes -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 -io.encodings.utf8 destructors accessors hashtables -tools.deploy.libraries vocabs.metadata.resources -tools.deploy.embed locals ; +USING: accessors assocs bootstrap.image hashtables io io.directories +io.encodings.utf8 io.files io.files.temp io.launcher io.pathnames +kernel locals make namespaces prettyprint sequences splitting system +tools.deploy.config tools.deploy.config.editor tools.deploy.embed +tools.deploy.libraries vocabs.loader vocabs.metadata.resources ; IN: tools.deploy.backend : copy-vm ( executable bundle-name -- vm-path ) @@ -49,18 +44,6 @@ ERROR: can't-deploy-library-file library ; my-boot-image-name resource-path exists? [ make-my-image ] unless ; -: bootstrap-profile ( -- profile ) - [ - deploy-math? get [ "math" , ] when - deploy-threads? get [ "threads" , ] when - "compiler" , - deploy-help? get [ "help" , ] when - native-io? [ "io" , ] when - deploy-ui? get [ "ui" , ] when - deploy-unicode? get [ "unicode" , ] when - - ] { } make ; - : staging-image-name ( profile -- name ) "-" join "." my-arch-name 3append "staging." ".image" surround cache-file ; @@ -126,14 +109,14 @@ DEFER: ?make-staging-image :: make-deploy-image ( vm image vocab config -- manifest ) make-boot-image - config [ - bootstrap-profile :> profile - vocab "vocab-manifest-" prepend temp-file :> manifest-file - image vocab manifest-file profile deploy-command-line :> flags - profile ?make-staging-image - vm flags run-factor - manifest-file parse-vocab-manifest-file - ] with-variables ; + + config config>profile :> profile + vocab "vocab-manifest-" prepend temp-file :> manifest-file + image vocab manifest-file profile deploy-command-line :> flags + + profile ?make-staging-image + vm flags run-factor + manifest-file parse-vocab-manifest-file ; :: make-deploy-image-executable ( vm image vocab config -- manifest ) vm image vocab config make-deploy-image diff --git a/basis/tools/deploy/config/config-tests.factor b/basis/tools/deploy/config/config-tests.factor new file mode 100644 index 0000000000..9ba9f2c3b8 --- /dev/null +++ b/basis/tools/deploy/config/config-tests.factor @@ -0,0 +1,6 @@ +USING: tools.deploy.config tools.test ; +IN: tools.deploy.config.tests + +{ { "math" "threads" "compiler" "io" } } [ + "hello-ui" default-config config>profile +] unit-test diff --git a/basis/tools/deploy/config/config.factor b/basis/tools/deploy/config/config.factor index 950b2da2a1..16a8e90635 100644 --- a/basis/tools/deploy/config/config.factor +++ b/basis/tools/deploy/config/config.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs hashtables kernel math namespaces vocabs ; +USING: assocs combinators.smart hashtables kernel math namespaces +sequences vocabs ; IN: tools.deploy.config SYMBOL: deploy-name @@ -69,3 +70,14 @@ SYMBOL: deploy-image SYMBOL: deploy-directory "resource:" deploy-directory set-global + +: config>profile ( config -- profile ) + { + [ deploy-math? of "math" f ? ] + [ deploy-threads? of "threads" f ? ] + [ drop "compiler" ] + [ deploy-help? of "help" f ? ] + [ deploy-io of 3 = "io" f ? ] + [ deploy-ui? of "ui" f ? ] + [ deploy-unicode? of "unicode" f ? ] + } cleave>array sift ; diff --git a/basis/tools/deploy/deploy-tests.factor b/basis/tools/deploy/deploy-tests.factor index 1267d4c5b5..213267a69b 100644 --- a/basis/tools/deploy/deploy-tests.factor +++ b/basis/tools/deploy/deploy-tests.factor @@ -37,10 +37,8 @@ delete-staging-images { } [ "hello-ui" shake-and-bake 2242000 small-enough? ] unit-test { "math-threads-compiler-io-ui" } [ - "hello-ui" deploy-config [ - bootstrap-profile staging-image-name file-name - "." split second - ] with-variables + "hello-ui" deploy-config config>profile + staging-image-name file-name "." split second ] unit-test ! [ ] [ "maze" shake-and-bake 1520000 small-enough? ] unit-test @@ -157,7 +155,7 @@ os macosx? [ { t } [ "tools.deploy.test.18" shake-and-bake deploy-test-command ascii [ readln ] with-process-reader - test-image temp-file = + test-image-path = ] unit-test { } [ "resource:LICENSE.txt" "license.txt" temp-file copy-file ] unit-test