1 ! Copyright (C) 2007, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: cocoa.application cocoa.plists combinators io.backend
4 io.directories io.files io.files.info.unix io.pathnames kernel
5 make namespaces sequences system tools.deploy.backend
6 tools.deploy.config tools.deploy.config.editor vocabs.loader ;
7 QUALIFIED-WITH: tools.deploy.unix unix
8 IN: tools.deploy.macosx
10 : bundle-dir ( -- dir )
12 [ vm-path parent-directory parent-directory parent-directory ]
13 [ "resource:Factor.app" ]
16 : copy-bundle-dir ( bundle-name dir -- )
17 [ bundle-dir prepend-path swap ] keep
18 append-path copy-tree ;
20 : app-plist ( icon? executable bundle-name -- assoc )
22 "6.0" "CFBundleInfoDictionaryVersion" ,,
23 "APPL" "CFBundlePackageType" ,,
25 file-name "CFBundleName" ,,
27 [ "CFBundleExecutable" ,, ]
28 [ "org.factor." prepend "CFBundleIdentifier" ,, ] bi
30 [ "Icon.icns" "CFBundleIconFile" ,, ] when
32 t "NSHighResolutionCapable" ,,
35 : create-app-plist ( icon? executable bundle-name -- )
37 "Contents/Info.plist" append-path
40 : copy-nib ( bundle-name -- )
42 "Contents/Resources/English.lproj/MiniFactor.nib" copy-bundle-dir
45 : vocab-mac-icon-path ( vocab -- string )
46 vocab-dir "icon.icns" append-path ;
48 : copy-icns ( vocab bundle-name -- icon? )
49 swap dup vocab-mac-icon-path vocab-append-path dup file-exists?
50 [ swap "Contents/Resources/Icon.icns" append-path copy-file t ]
53 : create-app-dir ( vocab bundle-name -- vm )
58 [ "Contents/Resources" append-path make-directories ]
59 [ "Contents/Frameworks" append-path make-directories ] tri
63 [ "Contents/MacOS/" append-path copy-vm ]
65 dup 0o755 set-file-permissions ;
67 : bundle-name ( -- string )
68 deploy-name get ".app" append ;
70 : deploy.app-image-name ( vocab bundle-name -- str )
71 [ % "/Contents/Resources/" % % ".image" % ] "" make ;
73 : deploy-app-bundle ( vocab -- )
74 bundle-name dup file-exists? [ delete-tree ] [ drop ] if
75 [ bundle-name create-app-dir ] keep
76 [ bundle-name deploy.app-image-name ] keep
77 namespace make-deploy-image
79 [ "Contents/Resources" copy-resources ]
80 [ "Contents/Frameworks" copy-libraries ] 2bi
81 bundle-name maybe-open-deploy-directory ;
83 : deploy-app-bundle? ( vocab -- ? )
84 deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;
87 ! pass off to M: unix deploy* if we're building a console app
88 dup deploy-app-bundle? [
95 dup deploy-app-bundle? [
96 deploy-directory get [
98 bundle-name "Contents/MacOS/" append-path
99 swap append-path normalize-path