]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/deploy/windows/windows.factor
io.files: exists? -> file-exists? and rename primitive.
[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: combinators io.backend io.directories io.encodings.binary
4 io.files io.pathnames kernel locals namespaces sequences splitting
5 system tools.deploy.backend tools.deploy.config
6 tools.deploy.config.editor tools.deploy.windows.ico vocabs.loader
7 webbrowser ;
8 IN: tools.deploy.windows
9
10 CONSTANT: app-icon-resource-id "APPICON"
11
12 :: copy-vm ( executable bundle-name extension -- vm-path )
13     vm-path "." split1-last drop extension append
14     bundle-name executable ".exe" append append-path
15     [ copy-file ] keep normalize-path ;
16
17 : create-exe-dir ( vocab bundle-name -- vm-path )
18     deploy-console? get ".com" ".exe" ? copy-vm ;
19
20 : vocab-windows-icon-path ( vocab -- string )
21     vocab-dir "icon.ico" append-path ;
22
23 : embed-ico ( vm-path vocab -- )
24     dup vocab-windows-icon-path vocab-append-path dup file-exists?
25     [ binary file-contents app-icon-resource-id embed-icon-resource ]
26     [ 2drop ] if ;
27
28 M: windows deploy*
29     deploy-name get
30     {
31         [ create-exe-dir dup ]
32         [ drop embed-ico ]
33         [ drop deployed-image-name ]
34         [ drop namespace make-deploy-image-executable ]
35         [ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
36         [ nip maybe-open-deploy-directory ]
37     } 2cleave ;
38
39 M: windows deploy-path
40     deploy-directory get [
41         dup deploy-config [
42             deploy-name get
43             swap ".exe" append append-path
44             normalize-path
45         ] with-variables
46     ] with-directory ;