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 system
4 tools.deploy.backend tools.deploy.config
5 tools.deploy.config.editor assocs hashtables prettyprint
6 io.unix.backend cocoa io.encodings.utf8 io.backend
7 cocoa.application cocoa.classes cocoa.plists qualified
9 IN: tools.deploy.macosx
11 : bundle-dir ( -- dir )
12 vm parent-directory parent-directory ;
14 : copy-bundle-dir ( bundle-name dir -- )
15 bundle-dir over append-path -rot
16 "Contents" prepend-path append-path copy-tree ;
18 : app-plist ( executable bundle-name -- assoc )
20 "6.0" "CFBundleInfoDictionaryVersion" set
21 "APPL" "CFBundlePackageType" set
23 file-name "CFBundleName" set
25 [ "CFBundleExecutable" set ]
26 [ "org.factor." prepend "CFBundleIdentifier" set ] bi
29 : create-app-plist ( executable bundle-name -- )
31 "Contents/Info.plist" append-path
34 : copy-dll ( bundle-name -- )
35 "Frameworks/libfactor.dylib" copy-bundle-dir ;
37 : copy-freetype ( bundle-name -- )
38 deploy-ui? get [ "Frameworks" copy-bundle-dir ] [ drop ] if ;
40 : copy-nib ( bundle-name -- )
42 "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir
45 : create-app-dir ( vocab bundle-name -- vm )
51 [ "Contents/Resources/" copy-fonts ]
52 [ "Contents/Resources" append-path make-directories ]
56 [ "Contents/MacOS/" append-path "" copy-vm ] 2tri ;
58 : deploy.app-image ( vocab bundle-name -- str )
59 [ % "/Contents/Resources/" % % ".image" % ] "" make ;
61 : bundle-name ( -- string )
62 deploy-name get ".app" append ;
64 : show-in-finder ( path -- )
65 [ NSWorkspace -> sharedWorkspace ]
66 [ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
67 -> selectFile:inFileViewerRootedAtPath: drop ;
69 M: macosx deploy* ( vocab -- )
70 ".app deploy tool" assert.app
73 bundle-name dup exists? [ delete-tree ] [ drop ] if
74 [ bundle-name create-app-dir ] keep
75 [ bundle-name deploy.app-image ] keep
76 namespace make-deploy-image
77 bundle-name show-in-finder