factor/basis/tools/deploy/macosx/macosx.factor

65 lines
2.0 KiB
Factor
Raw Normal View History

2008-01-05 19:37:13 -05:00
! Copyright (C) 2007, 2008 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: io io.files kernel namespaces make sequences
2008-01-05 19:37:13 -05:00
system tools.deploy.backend tools.deploy.config assocs
2008-02-21 19:05:04 -05:00
hashtables prettyprint io.unix.backend cocoa io.encodings.utf8
2008-04-05 09:30:02 -04:00
io.backend cocoa.application cocoa.classes cocoa.plists
qualified ;
IN: tools.deploy.macosx
2007-09-20 18:09:08 -04:00
: bundle-dir ( -- dir )
vm parent-directory parent-directory ;
2007-09-20 18:09:08 -04:00
2008-03-07 22:28:51 -05:00
: copy-bundle-dir ( bundle-name dir -- )
bundle-dir over append-path -rot
"Contents" prepend-path append-path copy-tree ;
2007-11-24 19:40:43 -05:00
2008-04-05 09:30:02 -04:00
: app-plist ( executable bundle-name -- assoc )
2007-09-20 18:09:08 -04:00
[
2008-04-05 09:30:02 -04:00
"6.0" "CFBundleInfoDictionaryVersion" set
"APPL" "CFBundlePackageType" set
2007-09-20 18:09:08 -04:00
file-name "CFBundleName" set
2008-04-05 09:30:02 -04:00
[ "CFBundleExecutable" set ]
[ "org.factor." prepend "CFBundleIdentifier" set ] bi
] H{ } make-assoc ;
2007-09-20 18:09:08 -04:00
2008-04-05 09:30:02 -04:00
: create-app-plist ( executable bundle-name -- )
2008-03-07 22:28:51 -05:00
[ app-plist ] keep
"Contents/Info.plist" append-path
2008-04-05 09:30:02 -04:00
write-plist ;
2007-09-20 18:09:08 -04:00
: create-app-dir ( vocab bundle-name -- vm )
2008-04-20 01:49:42 -04:00
[
nip
[ "Frameworks" copy-bundle-dir ]
[ "Resources/English.lproj/MiniFactor.nib" copy-bundle-dir ]
[ "Contents/Resources/" copy-fonts ] tri
]
[ create-app-plist ]
[ "Contents/MacOS/" append-path "" copy-vm ] 2tri ;
2007-09-20 18:09:08 -04:00
: deploy.app-image ( vocab bundle-name -- str )
[ % "/Contents/Resources/" % % ".image" % ] "" make ;
: bundle-name ( -- string )
deploy-name get ".app" append ;
2007-11-24 16:39:16 -05:00
: show-in-finder ( path -- )
2008-04-20 01:49:42 -04:00
[ NSWorkspace -> sharedWorkspace ]
[ normalize-path [ <NSString> ] [ parent-directory <NSString> ] bi ] bi*
2007-11-24 16:39:16 -05:00
-> selectFile:inFileViewerRootedAtPath: drop ;
2008-04-02 20:46:37 -04:00
M: macosx deploy* ( vocab -- )
2007-09-20 18:09:08 -04:00
".app deploy tool" assert.app
2008-03-27 18:19:48 -04:00
"resource:" [
dup deploy-config [
bundle-name dup exists? [ delete-tree ] [ drop ] if
[ bundle-name create-app-dir ] keep
[ bundle-name deploy.app-image ] keep
namespace make-deploy-image
2008-04-20 01:49:42 -04:00
bundle-name show-in-finder
2008-03-27 18:19:48 -04:00
] bind
] with-directory ;