]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/deploy/windows/windows.factor
7fad2414fc43b789227c31bf56ffd7489ec91692
[factor.git] / basis / tools / deploy / windows / windows.factor
1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io io.encodings.binary io.files io.pathnames io.directories
4 io.encodings.ascii kernel namespaces
5 sequences locals system splitting tools.deploy.backend
6 tools.deploy.config tools.deploy.config.editor assocs hashtables
7 prettyprint combinators windows.kernel32 windows.shell32 windows.user32
8 alien.c-types vocabs.metadata vocabs.loader tools.deploy.windows.ico
9 io.files.windows ;
10 IN: tools.deploy.windows
11
12 CONSTANT: app-icon-resource-id "APPICON"
13
14 :: copy-vm ( executable bundle-name extension -- vm )
15     vm "." split1-last drop extension append
16     bundle-name executable ".exe" append append-path
17     [ copy-file ] keep ;
18
19 : create-exe-dir ( vocab bundle-name -- vm )
20     deploy-console? get ".com" ".exe" ? copy-vm ;
21
22 : open-in-explorer ( dir -- )
23     [ f "open" ] dip absolute-path normalize-separators
24     f f SW_SHOWNORMAL ShellExecute drop ;
25
26 : embed-ico ( vm vocab -- )
27     dup vocab-windows-icon-path vocab-append-path dup exists?
28     [ binary file-contents app-icon-resource-id embed-icon-resource ]
29     [ 2drop ] if ;
30
31 M: winnt deploy*
32     "resource:" [
33         dup deploy-config [
34             deploy-name get
35             {
36                 [ create-exe-dir dup ]
37                 [ drop embed-ico ]
38                 [ image-name ]
39                 [ drop namespace make-deploy-image ]
40                 [ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
41                 [ nip open-in-explorer ]
42             } 2cleave 
43         ] bind
44     ] with-directory ;