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

90 lines
2.8 KiB
Factor
Raw Normal View History

! Copyright (C) 2007, 2009 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: io io.files io.files.info.unix io.pathnames
io.directories io.directories.hierarchy kernel namespaces make
sequences system tools.deploy.backend tools.deploy.config
2008-12-08 17:02:31 -05:00
tools.deploy.config.editor assocs hashtables prettyprint
io.backend.unix cocoa io.encodings.utf8 io.backend
cocoa.application cocoa.classes cocoa.plists
combinators vocabs.metadata vocabs.loader ;
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 -- )
2008-12-22 06:41:01 -05:00
[ bundle-dir prepend-path swap ] keep
"Contents" prepend-path append-path copy-tree ;
2007-11-24 19:40:43 -05:00
: app-plist ( icon? 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
[ "Icon.icns" "CFBundleIconFile" set ] when
2008-04-05 09:30:02 -04:00
] H{ } make-assoc ;
2007-09-20 18:09:08 -04:00
: create-app-plist ( icon? 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
: copy-dll ( bundle-name -- )
"Frameworks/libfactor.dylib" copy-bundle-dir ;
: copy-nib ( bundle-name -- )
deploy-ui? get [
"Resources/English.lproj/MiniFactor.nib" copy-bundle-dir
] [ drop ] if ;
: copy-icns ( vocab bundle-name -- icon? )
swap dup vocab-mac-icon-path vocab-append-path dup exists?
[ swap "Contents/Resources/Icon.icns" append-path copy-file t ]
[ 2drop f ] if ;
2007-09-20 18:09:08 -04:00
: create-app-dir ( vocab bundle-name -- vm )
{
[
nip {
[ copy-dll ]
[ copy-nib ]
[ "Contents/Resources" append-path make-directories ]
} cleave
]
[ copy-icns ]
[ create-app-plist ]
[ "Contents/MacOS/" append-path copy-vm ]
} 2cleave
dup OCT: 755 set-file-permissions ;
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
bundle-name
[ "Contents/Resources" copy-resources ]
[ "Contents/Frameworks" copy-libraries ] 2bi
2008-04-20 01:49:42 -04:00
bundle-name show-in-finder
2008-03-27 18:19:48 -04:00
] bind
] with-directory ;