1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io io.files io.files.info.unix io.pathnames
4 io.directories io.directories.hierarchy kernel namespaces make
5 sequences system tools.deploy.backend tools.deploy.config
6 tools.deploy.config.editor assocs hashtables prettyprint
7 io.backend.unix cocoa io.encodings.utf8 io.backend
8 cocoa.application cocoa.classes cocoa.plists
10 IN: tools.deploy.macosx
12 : bundle-dir ( -- dir )
13 vm parent-directory parent-directory ;
15 : copy-bundle-dir ( bundle-name dir -- )
16 [ bundle-dir prepend-path swap ] keep
17 "Contents" prepend-path append-path copy-tree ;
19 : app-plist ( executable bundle-name -- assoc )
21 "6.0" "CFBundleInfoDictionaryVersion" set
22 "APPL" "CFBundlePackageType" set
24 file-name "CFBundleName" set
26 [ "CFBundleExecutable" set ]
27 [ "org.factor." prepend "CFBundleIdentifier" set ] bi
30 : create-app-plist ( executable bundle-name -- )
32 "Contents/Info.plist" append-path
35 : copy-dll ( bundle-name -- )
36 "Frameworks/libfactor.dylib" copy-bundle-dir ;
38 : copy-nib ( bundle-name -- )
40 "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir
43 : create-app-dir ( vocab bundle-name -- vm )
48 [ "Contents/Resources" append-path make-directories ]
49 [ "Contents/Resources" copy-theme ]
53 [ "Contents/MacOS/" append-path copy-vm ] 2tri
54 dup OCT: 755 set-file-permissions ;
56 : deploy.app-image ( vocab bundle-name -- str )
57 [ % "/Contents/Resources/" % % ".image" % ] "" make ;
59 : bundle-name ( -- string )
60 deploy-name get ".app" append ;
62 : show-in-finder ( path -- )
63 [ NSWorkspace -> sharedWorkspace ]
64 [ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
65 -> selectFile:inFileViewerRootedAtPath: drop ;
67 M: macosx deploy* ( vocab -- )
68 ".app deploy tool" assert.app
71 bundle-name dup exists? [ delete-tree ] [ drop ] if
72 [ bundle-name create-app-dir ] keep
73 [ bundle-name deploy.app-image ] keep
74 namespace make-deploy-image
75 bundle-name show-in-finder