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
8 IN: tools.deploy.macosx
10 : bundle-dir ( -- dir )
11 vm parent-directory parent-directory ;
13 : copy-bundle-dir ( bundle-name dir -- )
14 bundle-dir over append-path -rot
15 "Contents" prepend-path append-path copy-tree ;
17 : app-plist ( executable bundle-name -- assoc )
19 "6.0" "CFBundleInfoDictionaryVersion" set
20 "APPL" "CFBundlePackageType" set
22 file-name "CFBundleName" set
24 [ "CFBundleExecutable" set ]
25 [ "org.factor." prepend "CFBundleIdentifier" set ] bi
28 : create-app-plist ( executable bundle-name -- )
30 "Contents/Info.plist" append-path
33 : create-app-dir ( vocab bundle-name -- vm )
36 [ "Frameworks" copy-bundle-dir ]
37 [ "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir ]
38 [ "Contents/Resources/" copy-fonts ] tri
41 [ "Contents/MacOS/" append-path "" copy-vm ] 2tri ;
43 : deploy.app-image ( vocab bundle-name -- str )
44 [ % "/Contents/Resources/" % % ".image" % ] "" make ;
46 : bundle-name ( -- string )
47 deploy-name get ".app" append ;
49 : show-in-finder ( path -- )
50 [ NSWorkspace -> sharedWorkspace ]
51 [ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
52 -> selectFile:inFileViewerRootedAtPath: drop ;
54 M: macosx deploy* ( vocab -- )
55 ".app deploy tool" assert.app
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