1 ! Copyright (C) 2007, 2010 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 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
9 combinators vocabs.metadata vocabs.loader webbrowser ;
10 QUALIFIED-WITH: tools.deploy.unix unix
11 IN: tools.deploy.macosx
13 : bundle-dir ( -- dir )
15 [ vm-path parent-directory parent-directory parent-directory ]
16 [ "resource:Factor.app" ]
19 : copy-bundle-dir ( bundle-name dir -- )
20 [ bundle-dir prepend-path swap ] keep
21 append-path copy-tree ;
23 : app-plist ( icon? executable bundle-name -- assoc )
25 "6.0" "CFBundleInfoDictionaryVersion" ,,
26 "APPL" "CFBundlePackageType" ,,
28 file-name "CFBundleName" ,,
30 [ "CFBundleExecutable" ,, ]
31 [ "org.factor." prepend "CFBundleIdentifier" ,, ] bi
33 [ "Icon.icns" "CFBundleIconFile" ,, ] when
35 t "NSHighResolutionCapable" ,,
38 : create-app-plist ( icon? executable bundle-name -- )
40 "Contents/Info.plist" append-path
43 : copy-nib ( bundle-name -- )
45 "Contents/Resources/English.lproj/MiniFactor.nib" copy-bundle-dir
48 : vocab-mac-icon-path ( vocab -- string )
49 vocab-dir "icon.icns" append-path ;
51 : copy-icns ( vocab bundle-name -- icon? )
52 swap dup vocab-mac-icon-path vocab-append-path dup file-exists?
53 [ swap "Contents/Resources/Icon.icns" append-path copy-file t ]
56 : create-app-dir ( vocab bundle-name -- vm )
61 [ "Contents/Resources" append-path make-directories ]
62 [ "Contents/Frameworks" append-path make-directories ] tri
66 [ "Contents/MacOS/" append-path copy-vm ]
68 dup 0o755 set-file-permissions ;
70 : bundle-name ( -- string )
71 deploy-name get ".app" append ;
73 : deploy.app-image-name ( vocab bundle-name -- str )
74 [ % "/Contents/Resources/" % % ".image" % ] "" make ;
76 : deploy-app-bundle ( vocab -- )
77 bundle-name dup file-exists? [ delete-tree ] [ drop ] if
78 [ bundle-name create-app-dir ] keep
79 [ bundle-name deploy.app-image-name ] keep
80 namespace make-deploy-image
82 [ "Contents/Resources" copy-resources ]
83 [ "Contents/Frameworks" copy-libraries ] 2bi
84 bundle-name maybe-open-deploy-directory ;
86 : deploy-app-bundle? ( vocab -- ? )
87 deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;
90 ! pass off to M: unix deploy* if we're building a console app
91 dup deploy-app-bundle? [
98 dup deploy-app-bundle? [
99 deploy-directory get [
101 bundle-name "Contents/MacOS/" append-path
102 swap append-path normalize-path