]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/deploy/macosx/macosx.factor
Fix permission bits
[factor.git] / basis / tools / deploy / macosx / macosx.factor
1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io io.files kernel namespaces make sequences
4 system tools.deploy.backend tools.deploy.config assocs
5 hashtables prettyprint io.unix.backend cocoa io.encodings.utf8
6 io.backend cocoa.application cocoa.classes cocoa.plists
7 qualified ;
8 IN: tools.deploy.macosx
9
10 : bundle-dir ( -- dir )
11     vm parent-directory parent-directory ;
12
13 : copy-bundle-dir ( bundle-name dir -- )
14     bundle-dir over append-path -rot
15     "Contents" prepend-path append-path copy-tree ;
16
17 : app-plist ( executable bundle-name -- assoc )
18     [
19         "6.0" "CFBundleInfoDictionaryVersion" set
20         "APPL" "CFBundlePackageType" set
21
22         file-name "CFBundleName" set
23
24         [ "CFBundleExecutable" set ]
25         [ "org.factor." prepend "CFBundleIdentifier" set ] bi
26     ] H{ } make-assoc ;
27
28 : create-app-plist ( executable bundle-name -- )
29     [ app-plist ] keep
30     "Contents/Info.plist" append-path
31     write-plist ;
32
33 : create-app-dir ( vocab bundle-name -- vm )
34     [
35         nip
36         [ "Frameworks" copy-bundle-dir ]
37         [ "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir ]
38         [ "Contents/Resources/" copy-fonts ] tri
39     ]
40     [ create-app-plist ]
41     [ "Contents/MacOS/" append-path "" copy-vm ] 2tri ;
42
43 : deploy.app-image ( vocab bundle-name -- str )
44     [ % "/Contents/Resources/" % % ".image" % ] "" make ;
45
46 : bundle-name ( -- string )
47     deploy-name get ".app" append ;
48
49 : show-in-finder ( path -- )
50     [ NSWorkspace -> sharedWorkspace ]
51     [ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
52     -> selectFile:inFileViewerRootedAtPath: drop ;
53
54 M: macosx deploy* ( vocab -- )
55     ".app deploy tool" assert.app
56     "resource:" [
57         dup deploy-config [
58             bundle-name dup exists? [ delete-tree ] [ drop ] if
59             [ bundle-name create-app-dir ] keep
60             [ bundle-name deploy.app-image ] keep
61             namespace make-deploy-image
62             bundle-name show-in-finder
63         ] bind
64     ] with-directory ;